diff --git a/apps/calculation/calculation.cpp b/apps/calculation/calculation.cpp index ecf6bc65d..e21e4abcd 100644 --- a/apps/calculation/calculation.cpp +++ b/apps/calculation/calculation.cpp @@ -54,31 +54,13 @@ void Calculation::setContent(const char * c, Context * context, Expression ansEx KDCoordinate Calculation::height(Context * context) { if (m_height < 0) { LayoutRef inputLayout = createInputLayout(); - if (inputLayout.isAllocationFailure()) { - /* If there is not enough tree pool space to create the layout, return a - * default height. Do not store it in m_height in case some memory gets - * freed afterwards. */ - return k_heightComputationFailureHeight; - } KDCoordinate inputHeight = inputLayout.layoutSize().height(); LayoutRef approximateLayout = createApproximateOutputLayout(context); - if (approximateLayout.isAllocationFailure()) { - /* If there is not enough tree pool space to create the layout, return a - * default height. Do not store it in m_height in case some memory gets - * freed afterwards. */ - return k_heightComputationFailureHeight; - } KDCoordinate approximateOutputHeight = approximateLayout.layoutSize().height(); if (shouldOnlyDisplayApproximateOutput(context)) { m_height = inputHeight+approximateOutputHeight; } else { LayoutRef exactLayout = createExactOutputLayout(context); - if (exactLayout.isAllocationFailure()) { - /* If there is not enough tree pool space to create the layout, return a - * default height. Do not store it in m_height in case some memory gets - * freed afterwards. */ - return k_heightComputationFailureHeight; - } KDCoordinate exactOutputHeight = exactLayout.layoutSize().height(); KDCoordinate outputHeight = max(exactLayout.baseline(), approximateLayout.baseline()) + max(exactOutputHeight-exactLayout.baseline(), approximateOutputHeight-approximateLayout.baseline()); m_height = inputHeight + outputHeight; diff --git a/escher/src/layout_field.cpp b/escher/src/layout_field.cpp index 1f5d80dd2..1574218ca 100644 --- a/escher/src/layout_field.cpp +++ b/escher/src/layout_field.cpp @@ -43,10 +43,6 @@ void LayoutField::reload() { } bool LayoutField::handleEventWithText(const char * text, bool indentation, bool forceCursorRightOfText) { - if (m_contentView.cursor()->layoutReference().isAllocationFailure()) { - return false; - } - if (text[0] == 0) { // The text is empty return true; @@ -60,8 +56,6 @@ bool LayoutField::handleEventWithText(const char * text, bool indentation, bool return true; } - LayoutRef rootRef = m_contentView.expressionView()->layoutRef(); - // Handle special cases if (strcmp(text, Ion::Events::Division.text()) == 0) { m_contentView.cursor()->addFractionLayoutAndCollapseSiblings(); @@ -108,17 +102,10 @@ bool LayoutField::handleEventWithText(const char * text, bool indentation, bool insertLayoutAtCursor(resultLayoutRef, pointedLayoutRef, forceCursorRightOfText); } } - if (rootRef.isAllocationFailure()) { - m_contentView.cursor()->setLayoutReference(rootRef); - } return true; } bool LayoutField::handleEvent(Ion::Events::Event event) { - if (m_contentView.cursor()->layoutReference().isAllocationFailure()) { - return false; - } - LayoutRef rootRef = m_contentView.expressionView()->layoutRef(); bool didHandleEvent = false; bool shouldRecomputeLayout = m_contentView.cursor()->showEmptyLayoutIfNeeded(); bool moveEventChangedLayout = false; @@ -133,9 +120,6 @@ bool LayoutField::handleEvent(Ion::Events::Event event) { didHandleEvent = true; } if (didHandleEvent) { - if (rootRef.isAllocationFailure()) { - m_contentView.cursor()->setLayoutReference(rootRef); - } shouldRecomputeLayout = m_contentView.cursor()->hideEmptyLayoutIfNeeded() || shouldRecomputeLayout; if (!shouldRecomputeLayout) { m_contentView.cursorPositionChanged(); @@ -248,7 +232,7 @@ void LayoutField::scrollToBaselinedRect(KDRect rect, KDCoordinate baseline) { } void LayoutField::insertLayoutAtCursor(LayoutRef layoutR, LayoutRef pointedLayoutR, bool forceCursorRightOfLayout) { - if (layoutR.isUninitialized() || layoutRef().isAllocationFailure()) { + if (layoutR.isUninitialized()) { return; } @@ -262,9 +246,7 @@ void LayoutField::insertLayoutAtCursor(LayoutRef layoutR, LayoutRef pointedLayou m_contentView.cursor()->addLayoutAndMoveCursor(layoutR); // Move the cursor if needed - if (layoutRef().isAllocationFailure()) { - m_contentView.cursor()->setLayoutReference(layoutRef()); - } else if(!forceCursorRightOfLayout) { + if(!forceCursorRightOfLayout) { if (!pointedLayoutR.isUninitialized() && (!layoutWillBeMerged || pointedLayoutR != layoutR)) { // Make sure the layout was inserted (its parent is not uninitialized) m_contentView.cursor()->setLayoutReference(pointedLayoutR); @@ -280,9 +262,6 @@ void LayoutField::insertLayoutAtCursor(LayoutRef layoutR, LayoutRef pointedLayou // Handle matrices m_contentView.cursor()->layoutReference().addGreySquaresToAllMatrixAncestors(); - if (layoutRef().isAllocationFailure()) { - m_contentView.cursor()->setLayoutReference(layoutRef()); - } // Handle empty layouts m_contentView.cursor()->hideEmptyLayoutIfNeeded(); diff --git a/escher/src/selectable_table_view.cpp b/escher/src/selectable_table_view.cpp index e5525220d..9d80e8f37 100644 --- a/escher/src/selectable_table_view.cpp +++ b/escher/src/selectable_table_view.cpp @@ -129,7 +129,7 @@ bool SelectableTableView::handleEvent(Ion::Events::Event event) { return true; } Poincare::LayoutRef layoutR = cell->layoutRef(); - if (!layoutR.isUninitialized() && !layoutR.isAllocationFailure()) { + if (!layoutR.isUninitialized()) { Clipboard::sharedClipboard()->store(layoutR); return true; } diff --git a/poincare/Makefile b/poincare/Makefile index c00337617..55e0b7a9c 100644 --- a/poincare/Makefile +++ b/poincare/Makefile @@ -3,7 +3,6 @@ SFLAGS += -Ipoincare/include #include poincare/src/simplify/Makefile #include poincare/src/simplification/Makefile objs += $(addprefix poincare/src/,\ - absolute_value_layout_node.o\ binomial_coefficient_layout_node.o\ bracket_layout_node.o\ bracket_pair_layout_node.o\ diff --git a/poincare/include/poincare/absolute_value.h b/poincare/include/poincare/absolute_value.h index 0fddbeb80..c8716c2fa 100644 --- a/poincare/include/poincare/absolute_value.h +++ b/poincare/include/poincare/absolute_value.h @@ -10,9 +10,6 @@ namespace Poincare { class AbsoluteValueNode : public ExpressionNode { public: - // Allocation Failure - static AbsoluteValueNode * FailedAllocationStaticNode(); - AbsoluteValueNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(AbsoluteValueNode); } int numberOfChildren() const override { return 1; } diff --git a/poincare/include/poincare/absolute_value_layout_node.h b/poincare/include/poincare/absolute_value_layout_node.h index 276ce39f5..1e2362231 100644 --- a/poincare/include/poincare/absolute_value_layout_node.h +++ b/poincare/include/poincare/absolute_value_layout_node.h @@ -1,7 +1,6 @@ #ifndef POINCARE_ABSOLUTE_VALUE_LAYOUT_NODE_H #define POINCARE_ABSOLUTE_VALUE_LAYOUT_NODE_H -#include #include #include @@ -17,8 +16,6 @@ public: } // TreeNode - static AbsoluteValueLayoutNode * FailedAllocationStaticNode(); - AbsoluteValueLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } size_t size() const override { return sizeof(AbsoluteValueLayoutNode); } #if POINCARE_TREE_LOG virtual void logNodeName(std::ostream & stream) const override { diff --git a/poincare/include/poincare/addition.h b/poincare/include/poincare/addition.h index 5e82454b6..29e05bd15 100644 --- a/poincare/include/poincare/addition.h +++ b/poincare/include/poincare/addition.h @@ -2,7 +2,6 @@ #define POINCARE_ADDITION_H #include -#include #include #include #include @@ -16,8 +15,6 @@ public: using NAryExpressionNode::NAryExpressionNode; // Tree - static AdditionNode * FailedAllocationStaticNode(); - AdditionNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } size_t size() const override { return sizeof(AdditionNode); } #if POINCARE_TREE_LOG virtual void logNodeName(std::ostream & stream) const override { diff --git a/poincare/include/poincare/allocation_failure_evaluation_node.h b/poincare/include/poincare/allocation_failure_evaluation_node.h deleted file mode 100644 index 6f73f073a..000000000 --- a/poincare/include/poincare/allocation_failure_evaluation_node.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef POINCARE_ALLOCATION_FAILURE_EVALUATION_NODE_H -#define POINCARE_ALLOCATION_FAILURE_EVALUATION_NODE_H - -#include -#include -#include - -namespace Poincare { - -template class T, class U> -class AllocationFailureEvaluationNode : public ExceptionEvaluationNode { -public: - // EvaluationNode - typename EvaluationNode::Type type() const override { return EvaluationNode::Type::AllocationFailure; } - - // TreeNode - bool isAllocationFailure() const override { return true; } - size_t size() const override { return sizeof(AllocationFailureEvaluationNode); } - TreeNode * uninitializedStaticNode() const override { assert(false); return nullptr; } -#if POINCARE_TREE_LOG - virtual void logNodeName(std::ostream & stream) const override { - stream << "AllocationFailureEvaluation"; - T::logNodeName(stream); - } -#endif -}; - -} - -#endif diff --git a/poincare/include/poincare/allocation_failure_expression_node.h b/poincare/include/poincare/allocation_failure_expression_node.h deleted file mode 100644 index 7d998223d..000000000 --- a/poincare/include/poincare/allocation_failure_expression_node.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef POINCARE_ALLOCATION_FAILURE_EXPRESSION_NODE_H -#define POINCARE_ALLOCATION_FAILURE_EXPRESSION_NODE_H - -#include - -namespace Poincare { - -template -class AllocationFailureExpressionNode : public ExceptionExpressionNode { -public: - // ExpressionNode - ExpressionNode::Type type() const override { return ExpressionNode::Type::AllocationFailure; } - // TreeNode - void incrementNumberOfChildren(int increment = 1) override {} - void decrementNumberOfChildren(int decrement = 1) override {} - size_t size() const override { return sizeof(AllocationFailureExpressionNode); } - bool isAllocationFailure() const override { return true; } - TreeNode * uninitializedStaticNode() const override { assert(false); return nullptr; } -#if POINCARE_TREE_LOG - virtual void logNodeName(std::ostream & stream) const override { - stream << "AllocationFailureExpression"; - T::logNodeName(stream); - } -#endif -}; - -} - -#endif diff --git a/poincare/include/poincare/allocation_failure_layout_node.h b/poincare/include/poincare/allocation_failure_layout_node.h deleted file mode 100644 index 411cbdb2d..000000000 --- a/poincare/include/poincare/allocation_failure_layout_node.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef POINCARE_ALLOCATION_FAILURE_LAYOUT_NODE_H -#define POINCARE_ALLOCATION_FAILURE_LAYOUT_NODE_H - -#include - -namespace Poincare { - -template -class AllocationFailureLayoutNode : public ExceptionLayoutNode { -public: - size_t size() const override { return sizeof(AllocationFailureLayoutNode); } - bool isAllocationFailure() const override { return true; } - TreeNode * uninitializedStaticNode() const override { assert(false); return nullptr; } -#if POINCARE_TREE_LOG - virtual void logNodeName(std::ostream & stream) const override { - stream << "AllocationFailureLayout"; - T::logNodeName(stream); - } -#endif -}; - -/* -template -class AllocationFailureLayoutRef : public LayoutReference { -public: - AllocationFailedLayoutRef() : LayoutReference(TreePool::sharedPool()->createTreeNode>()) {} -}; -*/ - -} - -#endif diff --git a/poincare/include/poincare/arc_cosine.h b/poincare/include/poincare/arc_cosine.h index a8c6db4db..7f80d150d 100644 --- a/poincare/include/poincare/arc_cosine.h +++ b/poincare/include/poincare/arc_cosine.h @@ -10,9 +10,6 @@ namespace Poincare { class ArcCosineNode : public ExpressionNode { public: - // Allocation Failure - static ArcCosineNode * FailedAllocationStaticNode(); - ArcCosineNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(ArcCosineNode); } diff --git a/poincare/include/poincare/arc_sine.h b/poincare/include/poincare/arc_sine.h index d03acf3a6..6bead5ca3 100644 --- a/poincare/include/poincare/arc_sine.h +++ b/poincare/include/poincare/arc_sine.h @@ -10,9 +10,6 @@ namespace Poincare { class ArcSineNode : public ExpressionNode { public: - // Allocation Failure - static ArcSineNode * FailedAllocationStaticNode(); - ArcSineNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(ArcSineNode); } diff --git a/poincare/include/poincare/arc_tangent.h b/poincare/include/poincare/arc_tangent.h index 0a3e9250d..91d194a62 100644 --- a/poincare/include/poincare/arc_tangent.h +++ b/poincare/include/poincare/arc_tangent.h @@ -10,9 +10,6 @@ namespace Poincare { class ArcTangentNode : public ExpressionNode { public: - // Allocation Failure - static ArcTangentNode * FailedAllocationStaticNode(); - ArcTangentNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(ArcTangentNode); } diff --git a/poincare/include/poincare/binomial_coefficient.h b/poincare/include/poincare/binomial_coefficient.h index d53fd6681..a6fe7edab 100644 --- a/poincare/include/poincare/binomial_coefficient.h +++ b/poincare/include/poincare/binomial_coefficient.h @@ -9,8 +9,6 @@ namespace Poincare { class BinomialCoefficientNode : public ExpressionNode { public: - static BinomialCoefficientNode * FailedAllocationStaticNode(); - BinomialCoefficientNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(BinomialCoefficientNode); } diff --git a/poincare/include/poincare/binomial_coefficient_layout_node.h b/poincare/include/poincare/binomial_coefficient_layout_node.h index 01df2c639..729304bfb 100644 --- a/poincare/include/poincare/binomial_coefficient_layout_node.h +++ b/poincare/include/poincare/binomial_coefficient_layout_node.h @@ -22,8 +22,6 @@ public: int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override; // TreeNode - static BinomialCoefficientLayoutNode * FailedAllocationStaticNode(); - BinomialCoefficientLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } size_t size() const override { return sizeof(BinomialCoefficientLayoutNode); } int numberOfChildren() const override { return 2; } #if POINCARE_TREE_LOG diff --git a/poincare/include/poincare/ceiling.h b/poincare/include/poincare/ceiling.h index f4a95f6dd..8ee7d169c 100644 --- a/poincare/include/poincare/ceiling.h +++ b/poincare/include/poincare/ceiling.h @@ -8,9 +8,6 @@ namespace Poincare { class CeilingNode : public ExpressionNode { public: - // Allocation Failure - static CeilingNode * FailedAllocationStaticNode(); - CeilingNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(CeilingNode); } diff --git a/poincare/include/poincare/ceiling_layout_node.h b/poincare/include/poincare/ceiling_layout_node.h index cc297f623..ed4ea45fc 100644 --- a/poincare/include/poincare/ceiling_layout_node.h +++ b/poincare/include/poincare/ceiling_layout_node.h @@ -16,8 +16,6 @@ public: } // TreeNode - static CeilingLayoutNode * FailedAllocationStaticNode(); - CeilingLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } size_t size() const override { return sizeof(CeilingLayoutNode); } #if POINCARE_TREE_LOG virtual void logNodeName(std::ostream & stream) const override { diff --git a/poincare/include/poincare/char_layout_node.h b/poincare/include/poincare/char_layout_node.h index 1c02db04d..11341cf69 100644 --- a/poincare/include/poincare/char_layout_node.h +++ b/poincare/include/poincare/char_layout_node.h @@ -1,7 +1,6 @@ #ifndef POINCARE_CHAR_LAYOUT_NODE_H #define POINCARE_CHAR_LAYOUT_NODE_H -#include #include #include #include @@ -28,10 +27,6 @@ public: int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override; bool isCollapsable(int * numberOfOpenParenthesis, bool goingLeft) const override; - // AllocationFailure - static CharLayoutNode * FailedAllocationStaticNode(); - CharLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } - // TreeNode size_t size() const override { return sizeof(CharLayoutNode); } int numberOfChildren() const override { return 0; } @@ -59,11 +54,6 @@ private: KDText::FontSize m_fontSize; }; -class AllocationFailureCharLayoutNode : public AllocationFailureLayoutNode { -public: - void setChar(char c) override {} -}; - class CharLayoutRef : public LayoutReference { public: CharLayoutRef(char c, KDText::FontSize fontSize = KDText::FontSize::Large) : diff --git a/poincare/include/poincare/complex.h b/poincare/include/poincare/complex.h index 9f36faf88..4d8592578 100644 --- a/poincare/include/poincare/complex.h +++ b/poincare/include/poincare/complex.h @@ -12,9 +12,6 @@ template class ComplexNode : public std::complex, public EvaluationNode { public: ComplexNode() : std::complex(NAN, NAN) {} - // AllocationFailure - static ComplexNode * FailedAllocationStaticNode(); - ComplexNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(ComplexNode); } diff --git a/poincare/include/poincare/complex_argument.h b/poincare/include/poincare/complex_argument.h index 4ba1b404a..0420f015c 100644 --- a/poincare/include/poincare/complex_argument.h +++ b/poincare/include/poincare/complex_argument.h @@ -8,9 +8,6 @@ namespace Poincare { class ComplexArgumentNode : public ExpressionNode { public: - // Allocation Failure - static ComplexArgumentNode * FailedAllocationStaticNode(); - ComplexArgumentNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(ComplexArgumentNode); } diff --git a/poincare/include/poincare/condensed_sum_layout_node.h b/poincare/include/poincare/condensed_sum_layout_node.h index 043c86275..20bbeaa84 100644 --- a/poincare/include/poincare/condensed_sum_layout_node.h +++ b/poincare/include/poincare/condensed_sum_layout_node.h @@ -29,8 +29,6 @@ public: } // TreeNode - static CondensedSumLayoutNode * FailedAllocationStaticNode(); - CondensedSumLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } size_t size() const override { return sizeof(CondensedSumLayoutNode); } int numberOfChildren() const override { return 3; } #if POINCARE_TREE_LOG diff --git a/poincare/include/poincare/confidence_interval.h b/poincare/include/poincare/confidence_interval.h index 3c4ade042..f67fd89e8 100644 --- a/poincare/include/poincare/confidence_interval.h +++ b/poincare/include/poincare/confidence_interval.h @@ -7,8 +7,6 @@ namespace Poincare { class ConfidenceIntervalNode : public ExpressionNode { public: - static ConfidenceIntervalNode * FailedAllocationStaticNode(); - ConfidenceIntervalNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(ConfidenceIntervalNode); } @@ -39,8 +37,6 @@ private: class SimplePredictionIntervalNode : public ConfidenceIntervalNode { public: - static SimplePredictionIntervalNode * FailedAllocationStaticNode(); - SimplePredictionIntervalNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } private: const char * name() const override { return "prediction"; } }; diff --git a/poincare/include/poincare/conjugate.h b/poincare/include/poincare/conjugate.h index 7d0186b13..38b170e2e 100644 --- a/poincare/include/poincare/conjugate.h +++ b/poincare/include/poincare/conjugate.h @@ -8,9 +8,6 @@ namespace Poincare { class ConjugateNode : public ExpressionNode { public: - // Allocation Failure - static ConjugateNode * FailedAllocationStaticNode(); - ConjugateNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(ConjugateNode); } diff --git a/poincare/include/poincare/conjugate_layout_node.h b/poincare/include/poincare/conjugate_layout_node.h index fbf752798..c383c69ea 100644 --- a/poincare/include/poincare/conjugate_layout_node.h +++ b/poincare/include/poincare/conjugate_layout_node.h @@ -18,8 +18,6 @@ public: bool shouldCollapseSiblingsOnRight() const override { return true; } // TreeNode - static ConjugateLayoutNode * FailedAllocationStaticNode(); - ConjugateLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } size_t size() const override { return sizeof(ConjugateLayoutNode); } int numberOfChildren() const override { return 1; } #if POINCARE_TREE_LOG diff --git a/poincare/include/poincare/cosine.h b/poincare/include/poincare/cosine.h index 565594e8c..91f25f7c8 100644 --- a/poincare/include/poincare/cosine.h +++ b/poincare/include/poincare/cosine.h @@ -10,9 +10,6 @@ namespace Poincare { class CosineNode : public ExpressionNode { public: - // Allocation Failure - static CosineNode * FailedAllocationStaticNode(); - CosineNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(CosineNode); } diff --git a/poincare/include/poincare/decimal.h b/poincare/include/poincare/decimal.h index 94b327110..0454ce9e5 100644 --- a/poincare/include/poincare/decimal.h +++ b/poincare/include/poincare/decimal.h @@ -3,7 +3,6 @@ #include #include -#include namespace Poincare { @@ -26,10 +25,6 @@ public: virtual void setValue(const native_uint_t * mantissaDigits, size_t mantissaSize, int exponent, bool negative); - // Allocation Failure - static DecimalNode * FailedAllocationStaticNode(); - DecimalNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } - Integer signedMantissa() const; Integer unsignedMantissa() const; int exponent() const { return m_exponent; } @@ -85,11 +80,6 @@ private: native_uint_t m_mantissa[0]; }; -class AllocationFailureDecimalNode : public AllocationFailureExpressionNode { -public: - void setValue(const native_uint_t * mantissaDigits, size_t mantissaSize, int exponent, bool negative) override {} -}; - class Decimal : public Number { friend class Number; friend class DecimalNode; diff --git a/poincare/include/poincare/derivative.h b/poincare/include/poincare/derivative.h index dd96fb382..d4c4f4212 100644 --- a/poincare/include/poincare/derivative.h +++ b/poincare/include/poincare/derivative.h @@ -10,9 +10,6 @@ namespace Poincare { class DerivativeNode : public ExpressionNode { public: - // Allocation Failure - static DerivativeNode * FailedAllocationStaticNode(); - DerivativeNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(DerivativeNode); } diff --git a/poincare/include/poincare/determinant.h b/poincare/include/poincare/determinant.h index 8f2da9488..65f19b2b1 100644 --- a/poincare/include/poincare/determinant.h +++ b/poincare/include/poincare/determinant.h @@ -8,9 +8,6 @@ namespace Poincare { class DeterminantNode : public ExpressionNode { public: - // Allocation Failure - static DeterminantNode * FailedAllocationStaticNode(); - DeterminantNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(DeterminantNode); } diff --git a/poincare/include/poincare/division.h b/poincare/include/poincare/division.h index 40bb066d1..cd6f840db 100644 --- a/poincare/include/poincare/division.h +++ b/poincare/include/poincare/division.h @@ -13,9 +13,6 @@ class DivisionNode : public ExpressionNode { template friend class LogarithmNode; public: - // Allocation Failure - static DivisionNode * FailedAllocationStaticNode(); - DivisionNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(DivisionNode); } diff --git a/poincare/include/poincare/division_quotient.h b/poincare/include/poincare/division_quotient.h index 4d192f41e..0fd5e4d77 100644 --- a/poincare/include/poincare/division_quotient.h +++ b/poincare/include/poincare/division_quotient.h @@ -7,8 +7,6 @@ namespace Poincare { class DivisionQuotientNode : public ExpressionNode { public: - static DivisionQuotientNode * FailedAllocationStaticNode(); - DivisionQuotientNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(DivisionQuotientNode); } diff --git a/poincare/include/poincare/division_remainder.h b/poincare/include/poincare/division_remainder.h index 66049634f..ee384a569 100644 --- a/poincare/include/poincare/division_remainder.h +++ b/poincare/include/poincare/division_remainder.h @@ -8,8 +8,6 @@ namespace Poincare { class DivisionRemainderNode : public ExpressionNode { public: - static DivisionRemainderNode * FailedAllocationStaticNode(); - DivisionRemainderNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(DivisionRemainderNode); } diff --git a/poincare/include/poincare/empty_expression.h b/poincare/include/poincare/empty_expression.h index dfa39aca0..f1e5a2bab 100644 --- a/poincare/include/poincare/empty_expression.h +++ b/poincare/include/poincare/empty_expression.h @@ -9,9 +9,6 @@ namespace Poincare { class EmptyExpressionNode : public ExpressionNode { public: - // Allocation Failure - static EmptyExpressionNode * FailedAllocationStaticNode(); - EmptyExpressionNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(EmptyExpressionNode); } diff --git a/poincare/include/poincare/empty_layout_node.h b/poincare/include/poincare/empty_layout_node.h index 4df6a4dd7..d0679627f 100644 --- a/poincare/include/poincare/empty_layout_node.h +++ b/poincare/include/poincare/empty_layout_node.h @@ -39,8 +39,6 @@ public: bool hasText() const override { return false; } // TreeNode - static EmptyLayoutNode * FailedAllocationStaticNode(); - EmptyLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } size_t size() const override { return sizeof(EmptyLayoutNode); } int numberOfChildren() const override { return 0; } #if POINCARE_TREE_LOG diff --git a/poincare/include/poincare/equal.h b/poincare/include/poincare/equal.h index 7a5cc013a..170dca933 100644 --- a/poincare/include/poincare/equal.h +++ b/poincare/include/poincare/equal.h @@ -7,8 +7,6 @@ namespace Poincare { class EqualNode : public ExpressionNode { public: - static EqualNode * FailedAllocationStaticNode(); - EqualNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(EqualNode); } diff --git a/poincare/include/poincare/evaluation.h b/poincare/include/poincare/evaluation.h index f7bdde0e0..1c4aa3107 100644 --- a/poincare/include/poincare/evaluation.h +++ b/poincare/include/poincare/evaluation.h @@ -20,7 +20,6 @@ class EvaluationNode : public TreeNode { public: enum class Type : uint8_t { Exception, - AllocationFailure, Complex, MatrixComplex }; diff --git a/poincare/include/poincare/exception_expression_node.h b/poincare/include/poincare/exception_expression_node.h index 127598373..e764a0b09 100644 --- a/poincare/include/poincare/exception_expression_node.h +++ b/poincare/include/poincare/exception_expression_node.h @@ -1,6 +1,7 @@ #ifndef POINCARE_EXCEPTION_EXPRESSION_NODE_H #define POINCARE_EXCEPTION_EXPRESSION_NODE_H +#include #include #include #include @@ -28,8 +29,7 @@ public: return PrintFloat::convertFloatToText(NAN, buffer, bufferSize, numberOfSignificantDigits, floatDisplayMode); } - LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override { return LayoutRef(CharLayoutNode::FailedAllocationStaticNode()); } //TODO ? - // OLD FIXME: Use EmptyLayoutNode here above, once EmptyLayout has been cleaned up + LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override { assert(false); return CharLayoutRef('a'); } //TODO ? Expression denominator(Context & context, Preferences::AngleUnit angleUnit) const override { return Expression(this).clone(); } }; diff --git a/poincare/include/poincare/expression.h b/poincare/include/poincare/expression.h index 1c644097f..f43374188 100644 --- a/poincare/include/poincare/expression.h +++ b/poincare/include/poincare/expression.h @@ -105,7 +105,7 @@ public: /* Properties */ ExpressionNode::Type type() const { return node()->type(); } ExpressionNode::Sign sign() const { return node()->sign(); } - bool isUndefinedOrAllocationFailure() const { return node()->type() == ExpressionNode::Type::Undefined || node()->type() == ExpressionNode::Type::AllocationFailure; } + bool isUndefined() const { return node()->type() == ExpressionNode::Type::Undefined; } bool isNumber() const { return node()->isNumber(); } bool isRationalZero() const; bool isRationalOne() const; diff --git a/poincare/include/poincare/expression_node.h b/poincare/include/poincare/expression_node.h index 4499bcee7..b3dd53953 100644 --- a/poincare/include/poincare/expression_node.h +++ b/poincare/include/poincare/expression_node.h @@ -21,10 +21,9 @@ class ExpressionNode : public TreeNode, public SerializationHelperInterface { friend class SymbolNode; public: enum class Type : uint8_t { - AllocationFailure = 0, - Uninitialized = 1, - Undefined = 2, - Integer = 3, + Uninitialized = 0, + Undefined = 1, + Integer = 2, Rational, Decimal, Float, diff --git a/poincare/include/poincare/factor.h b/poincare/include/poincare/factor.h index 0b29ec8f7..d832892ef 100644 --- a/poincare/include/poincare/factor.h +++ b/poincare/include/poincare/factor.h @@ -12,9 +12,6 @@ namespace Poincare { class FactorNode : public ExpressionNode { public: - // Allocation Failure - static FactorNode * FailedAllocationStaticNode(); - FactorNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(FactorNode); } int numberOfChildren() const override { return 1; } diff --git a/poincare/include/poincare/factorial.h b/poincare/include/poincare/factorial.h index 42b989de0..f9bcce1fc 100644 --- a/poincare/include/poincare/factorial.h +++ b/poincare/include/poincare/factorial.h @@ -9,9 +9,6 @@ namespace Poincare { class FactorialNode : public ExpressionNode { public: - // Allocation Failure - static FactorialNode * FailedAllocationStaticNode(); - FactorialNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(FactorialNode); } diff --git a/poincare/include/poincare/float.h b/poincare/include/poincare/float.h index 602596682..54b77bb72 100644 --- a/poincare/include/poincare/float.h +++ b/poincare/include/poincare/float.h @@ -22,8 +22,6 @@ class FloatNode : public NumberNode { public: FloatNode() : m_value(0.0) {} - static FloatNode * FailedAllocationStaticNode(); - FloatNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } void setFloat(T a) { m_value = a; } T value() const { return m_value; } diff --git a/poincare/include/poincare/floor.h b/poincare/include/poincare/floor.h index 95239d69e..c51f2d27d 100644 --- a/poincare/include/poincare/floor.h +++ b/poincare/include/poincare/floor.h @@ -8,9 +8,6 @@ namespace Poincare { class FloorNode : public ExpressionNode { public: - // Allocation Failure - static FloorNode * FailedAllocationStaticNode(); - FloorNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(FloorNode); } diff --git a/poincare/include/poincare/floor_layout_node.h b/poincare/include/poincare/floor_layout_node.h index 5cd90cfce..d5670968d 100644 --- a/poincare/include/poincare/floor_layout_node.h +++ b/poincare/include/poincare/floor_layout_node.h @@ -15,8 +15,6 @@ public: } // TreeNode - static FloorLayoutNode * FailedAllocationStaticNode(); - FloorLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } size_t size() const override { return sizeof(FloorLayoutNode); } #if POINCARE_TREE_LOG virtual void logNodeName(std::ostream & stream) const override { diff --git a/poincare/include/poincare/frac_part.h b/poincare/include/poincare/frac_part.h index ed9821ab9..de2245f21 100644 --- a/poincare/include/poincare/frac_part.h +++ b/poincare/include/poincare/frac_part.h @@ -8,9 +8,6 @@ namespace Poincare { class FracPartNode : public ExpressionNode { public: - // Allocation Failure - static FracPartNode * FailedAllocationStaticNode(); - FracPartNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(FracPartNode); } diff --git a/poincare/include/poincare/fraction_layout_node.h b/poincare/include/poincare/fraction_layout_node.h index f1e016fc7..7e81167ae 100644 --- a/poincare/include/poincare/fraction_layout_node.h +++ b/poincare/include/poincare/fraction_layout_node.h @@ -11,10 +11,6 @@ class FractionLayoutNode : public LayoutNode { public: using LayoutNode::LayoutNode; - // AllocationFailure - static FractionLayoutNode * FailedAllocationStaticNode(); - FractionLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } - // LayoutNode void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override; void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override; diff --git a/poincare/include/poincare/ghost_node.h b/poincare/include/poincare/ghost_node.h index b2b761f8a..604bbb146 100644 --- a/poincare/include/poincare/ghost_node.h +++ b/poincare/include/poincare/ghost_node.h @@ -18,25 +18,10 @@ public: // Ghost bool isGhost() const override { return true; } - // Allocation Failure - static GhostNode * FailedAllocationStaticNode(); - TreeNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // Uninitialized TreeNode * uninitializedStaticNode() const override; }; -class AllocationFailedGhostNode : public GhostNode { -public: - // TreeNode - size_t size() const override { return sizeof(AllocationFailedGhostNode); } -#if POINCARE_TREE_LOG - virtual void logNodeName(std::ostream & stream) const override { - stream << "AllocationFailedGhost"; - } -#endif - bool isAllocationFailure() const override { return true; } -}; - } #endif diff --git a/poincare/include/poincare/great_common_divisor.h b/poincare/include/poincare/great_common_divisor.h index b9c3dbd2a..9123f2be7 100644 --- a/poincare/include/poincare/great_common_divisor.h +++ b/poincare/include/poincare/great_common_divisor.h @@ -7,8 +7,6 @@ namespace Poincare { class GreatCommonDivisorNode : public ExpressionNode { public: - static GreatCommonDivisorNode * FailedAllocationStaticNode(); - GreatCommonDivisorNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(GreatCommonDivisorNode); } diff --git a/poincare/include/poincare/grid_layout_node.h b/poincare/include/poincare/grid_layout_node.h index dfb03d34c..ba9b6f71e 100644 --- a/poincare/include/poincare/grid_layout_node.h +++ b/poincare/include/poincare/grid_layout_node.h @@ -40,8 +40,6 @@ public: } // TreeNode - static GridLayoutNode * FailedAllocationStaticNode(); - GridLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } size_t size() const override { return sizeof(GridLayoutNode); } void didAddChildAtIndex(int newNumberOfChildren) override; int numberOfChildren() const override { return m_numberOfRows * m_numberOfColumns; } diff --git a/poincare/include/poincare/horizontal_layout_node.h b/poincare/include/poincare/horizontal_layout_node.h index b11907a54..d1164b70f 100644 --- a/poincare/include/poincare/horizontal_layout_node.h +++ b/poincare/include/poincare/horizontal_layout_node.h @@ -14,10 +14,6 @@ class HorizontalLayoutNode : public LayoutNode { friend class LayoutReference; public: - // AllocationFailure - static HorizontalLayoutNode * FailedAllocationStaticNode(); - HorizontalLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } - HorizontalLayoutNode() : LayoutNode(), m_numberOfChildren(0) diff --git a/poincare/include/poincare/hyperbolic_arc_cosine.h b/poincare/include/poincare/hyperbolic_arc_cosine.h index 4f41dd098..ea28e5f4e 100644 --- a/poincare/include/poincare/hyperbolic_arc_cosine.h +++ b/poincare/include/poincare/hyperbolic_arc_cosine.h @@ -8,9 +8,6 @@ namespace Poincare { class HyperbolicArcCosineNode : public HyperbolicTrigonometricFunctionNode { public: - // Allocation Failure - static HyperbolicArcCosineNode * FailedAllocationStaticNode(); - HyperbolicArcCosineNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(HyperbolicArcCosineNode); } diff --git a/poincare/include/poincare/hyperbolic_arc_sine.h b/poincare/include/poincare/hyperbolic_arc_sine.h index a4c5ea87d..942125bbc 100644 --- a/poincare/include/poincare/hyperbolic_arc_sine.h +++ b/poincare/include/poincare/hyperbolic_arc_sine.h @@ -8,9 +8,6 @@ namespace Poincare { class HyperbolicArcSineNode : public HyperbolicTrigonometricFunctionNode { public: - // Allocation Failure - static HyperbolicArcSineNode * FailedAllocationStaticNode(); - HyperbolicArcSineNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(HyperbolicArcSineNode); } diff --git a/poincare/include/poincare/hyperbolic_arc_tangent.h b/poincare/include/poincare/hyperbolic_arc_tangent.h index c9a003a4b..dbb5380e5 100644 --- a/poincare/include/poincare/hyperbolic_arc_tangent.h +++ b/poincare/include/poincare/hyperbolic_arc_tangent.h @@ -8,9 +8,6 @@ namespace Poincare { class HyperbolicArcTangentNode : public HyperbolicTrigonometricFunctionNode { public: - // Allocation Failure - static HyperbolicArcTangentNode * FailedAllocationStaticNode(); - HyperbolicArcTangentNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(HyperbolicArcTangentNode); } diff --git a/poincare/include/poincare/hyperbolic_cosine.h b/poincare/include/poincare/hyperbolic_cosine.h index 125e6aa2f..3e71381f7 100644 --- a/poincare/include/poincare/hyperbolic_cosine.h +++ b/poincare/include/poincare/hyperbolic_cosine.h @@ -8,9 +8,6 @@ namespace Poincare { class HyperbolicCosineNode : public HyperbolicTrigonometricFunctionNode { public: - // Allocation Failure - static HyperbolicCosineNode * FailedAllocationStaticNode(); - HyperbolicCosineNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(HyperbolicCosineNode); } diff --git a/poincare/include/poincare/hyperbolic_sine.h b/poincare/include/poincare/hyperbolic_sine.h index 225a305e6..b94265c1b 100644 --- a/poincare/include/poincare/hyperbolic_sine.h +++ b/poincare/include/poincare/hyperbolic_sine.h @@ -8,9 +8,6 @@ namespace Poincare { class HyperbolicSineNode : public HyperbolicTrigonometricFunctionNode { public: - // Allocation Failure - static HyperbolicSineNode * FailedAllocationStaticNode(); - HyperbolicSineNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(HyperbolicSineNode); } diff --git a/poincare/include/poincare/hyperbolic_tangent.h b/poincare/include/poincare/hyperbolic_tangent.h index 945413848..2a9b59ff1 100644 --- a/poincare/include/poincare/hyperbolic_tangent.h +++ b/poincare/include/poincare/hyperbolic_tangent.h @@ -8,9 +8,6 @@ namespace Poincare { class HyperbolicTangentNode : public HyperbolicTrigonometricFunctionNode { public: - // Allocation Failure - static HyperbolicTangentNode * FailedAllocationStaticNode(); - HyperbolicTangentNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(HyperbolicTangentNode); } diff --git a/poincare/include/poincare/imaginary_part.h b/poincare/include/poincare/imaginary_part.h index 1219f0034..164a01452 100644 --- a/poincare/include/poincare/imaginary_part.h +++ b/poincare/include/poincare/imaginary_part.h @@ -8,9 +8,6 @@ namespace Poincare { class ImaginaryPartNode : public ExpressionNode { public: - // Allocation Failure - static ImaginaryPartNode * FailedAllocationStaticNode(); - ImaginaryPartNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(ImaginaryPartNode); } diff --git a/poincare/include/poincare/infinity.h b/poincare/include/poincare/infinity.h index 26eae3e29..f55100325 100644 --- a/poincare/include/poincare/infinity.h +++ b/poincare/include/poincare/infinity.h @@ -5,12 +5,8 @@ namespace Poincare { -class AllocationFailureInfinityNode; - class InfinityNode : public NumberNode { public: - static InfinityNode * FailedAllocationStaticNode(); - InfinityNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } void setNegative(bool negative) { m_negative = negative; } Expression setSign(Sign s, Context & context, Preferences::AngleUnit angleUnit) override; diff --git a/poincare/include/poincare/integral.h b/poincare/include/poincare/integral.h index f25d3045d..363e2fea4 100644 --- a/poincare/include/poincare/integral.h +++ b/poincare/include/poincare/integral.h @@ -7,8 +7,6 @@ namespace Poincare { class IntegralNode : public ExpressionNode { public: - static IntegralNode * FailedAllocationStaticNode(); - IntegralNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(IntegralNode); } diff --git a/poincare/include/poincare/integral_layout_node.h b/poincare/include/poincare/integral_layout_node.h index 5a164300f..e76bd15e4 100644 --- a/poincare/include/poincare/integral_layout_node.h +++ b/poincare/include/poincare/integral_layout_node.h @@ -29,8 +29,6 @@ public: char XNTChar() const override { return 'x'; } // TreeNode - static IntegralLayoutNode * FailedAllocationStaticNode(); - IntegralLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } size_t size() const override { return sizeof(IntegralLayoutNode); } int numberOfChildren() const override { return 3; } #if POINCARE_TREE_LOG diff --git a/poincare/include/poincare/layout_node.h b/poincare/include/poincare/layout_node.h index 03e1c5a0c..14e27c614 100644 --- a/poincare/include/poincare/layout_node.h +++ b/poincare/include/poincare/layout_node.h @@ -11,18 +11,6 @@ namespace Poincare { class LayoutCursor; class LayoutReference; -/* Some methods, such as FractionLayoutNode::didCollapseSiblings, move the - * cursor without making sure that the layout is in the main layout, so they - * might make the cursor "jump" to an independent layout. - * - * Example : the main layout is AllocationFailure, we add a FractionLayout, - * which cannot be inserted in the main layout. Then FractionLayout collapses - * its siblings and moves the cursor to its denominator: the cursor is no longer - * on the main layout. - * - * We tackle this by not handling any event when the cursor points to an - * AllocationFailure layout. */ - class LayoutNode : public TreeNode, public SerializationHelperInterface { friend class LayoutReference; public: @@ -85,8 +73,8 @@ public: } bool removeGreySquaresFromAllMatrixAncestors() { return changeGreySquaresOfAllMatrixAncestors(false); } bool addGreySquaresToAllMatrixAncestors() { return changeGreySquaresOfAllMatrixAncestors(true); } - /* A layout has text if it is not empty or an allocation failure and it is - * not an horizontal layout with no child or with one child with no text. */ + /* A layout has text if it is not empty and it is not an horizontal layout + * with no child or with one child with no text. */ virtual bool hasText() const { return true; } virtual bool isCollapsable(int * numberOfOpenParenthesis, bool goingLeft) const { return true; } /* isCollapsable is used when adding a sibling fraction: should the layout be diff --git a/poincare/include/poincare/least_common_multiple.h b/poincare/include/poincare/least_common_multiple.h index ff488e176..f45a7ac03 100644 --- a/poincare/include/poincare/least_common_multiple.h +++ b/poincare/include/poincare/least_common_multiple.h @@ -8,8 +8,6 @@ namespace Poincare { class LeastCommonMultipleNode : public ExpressionNode { public: - static LeastCommonMultipleNode * FailedAllocationStaticNode(); - LeastCommonMultipleNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(LeastCommonMultipleNode); } diff --git a/poincare/include/poincare/left_parenthesis_layout_node.h b/poincare/include/poincare/left_parenthesis_layout_node.h index 329990897..bec5698ec 100644 --- a/poincare/include/poincare/left_parenthesis_layout_node.h +++ b/poincare/include/poincare/left_parenthesis_layout_node.h @@ -23,8 +23,6 @@ public: } // TreeNode - static LeftParenthesisLayoutNode * FailedAllocationStaticNode(); - LeftParenthesisLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } #if POINCARE_TREE_LOG virtual void logNodeName(std::ostream & stream) const override { stream << "LeftParenthesisLayout"; diff --git a/poincare/include/poincare/left_square_bracket_layout_node.h b/poincare/include/poincare/left_square_bracket_layout_node.h index c714a34b5..f3b402f63 100644 --- a/poincare/include/poincare/left_square_bracket_layout_node.h +++ b/poincare/include/poincare/left_square_bracket_layout_node.h @@ -16,8 +16,6 @@ public: bool isLeftBracket() const override { return true; } // TreeNode - static LeftSquareBracketLayoutNode * FailedAllocationStaticNode(); - LeftSquareBracketLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } size_t size() const override { return sizeof(LeftSquareBracketLayoutNode); } #if POINCARE_TREE_LOG virtual void logNodeName(std::ostream & stream) const override { diff --git a/poincare/include/poincare/logarithm.h b/poincare/include/poincare/logarithm.h index db4ae33a4..d955a5961 100644 --- a/poincare/include/poincare/logarithm.h +++ b/poincare/include/poincare/logarithm.h @@ -12,10 +12,6 @@ namespace Poincare { template class LogarithmNode : public ExpressionNode { public: - // Allocation Failure - static LogarithmNode * FailedAllocationStaticNode(); - LogarithmNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } - // TreeNode size_t size() const override { return sizeof(LogarithmNode); } int numberOfChildren() const override { assert(I == 1 || I == 2); return I; } diff --git a/poincare/include/poincare/matrix.h b/poincare/include/poincare/matrix.h index 7cb5d89ff..864e21f98 100644 --- a/poincare/include/poincare/matrix.h +++ b/poincare/include/poincare/matrix.h @@ -3,7 +3,6 @@ #include #include -#include namespace Poincare { @@ -15,8 +14,6 @@ public: m_numberOfRows(0), m_numberOfColumns(0) {} - static MatrixNode * FailedAllocationStaticNode(); - MatrixNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } int numberOfRows() const { return m_numberOfRows; } int numberOfColumns() const { return m_numberOfColumns; } @@ -58,11 +55,6 @@ private: int m_numberOfColumns; }; -class AllocationFailureMatrixNode : public AllocationFailureExpressionNode { - void setNumberOfRows(int rows) override {} - void setNumberOfColumns(int columns) override {} -}; - class Matrix : public Expression { template friend class MatrixComplexNode; friend class GlobalContext; diff --git a/poincare/include/poincare/matrix_complex.h b/poincare/include/poincare/matrix_complex.h index e2dbf116e..f3da6a383 100644 --- a/poincare/include/poincare/matrix_complex.h +++ b/poincare/include/poincare/matrix_complex.h @@ -2,7 +2,6 @@ #define POINCARE_MATRIX_COMPLEX_H #include -#include #include namespace Poincare { @@ -13,9 +12,6 @@ class MatrixComplex; template class MatrixComplexNode : public EvaluationNode { public: - static MatrixComplexNode * FailedAllocationStaticNode(); - MatrixComplexNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } - MatrixComplexNode() : EvaluationNode(), m_numberOfRows(0), @@ -55,12 +51,6 @@ private: int m_numberOfColumns; }; -template -class AllocationFailureMatrixComplexNode : public AllocationFailureEvaluationNode { - void setNumberOfRows(int rows) override {} - void setNumberOfColumns(int columns) override {} -}; - template class MatrixComplex : public Evaluation { friend class MatrixComplexNode; diff --git a/poincare/include/poincare/matrix_dimension.h b/poincare/include/poincare/matrix_dimension.h index 7b2c7d377..164c1d728 100644 --- a/poincare/include/poincare/matrix_dimension.h +++ b/poincare/include/poincare/matrix_dimension.h @@ -7,9 +7,6 @@ namespace Poincare { class MatrixDimensionNode : public ExpressionNode { public: - // Allocation Failure - static MatrixDimensionNode * FailedAllocationStaticNode(); - MatrixDimensionNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(MatrixDimensionNode); } diff --git a/poincare/include/poincare/matrix_inverse.h b/poincare/include/poincare/matrix_inverse.h index 4db4a8b64..2e702d4eb 100644 --- a/poincare/include/poincare/matrix_inverse.h +++ b/poincare/include/poincare/matrix_inverse.h @@ -7,9 +7,6 @@ namespace Poincare { class MatrixInverseNode : public ExpressionNode { public: - // Allocation Failure - static MatrixInverseNode * FailedAllocationStaticNode(); - MatrixInverseNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(MatrixInverseNode); } diff --git a/poincare/include/poincare/matrix_layout_node.h b/poincare/include/poincare/matrix_layout_node.h index 9fa5b556c..6d2b2f071 100644 --- a/poincare/include/poincare/matrix_layout_node.h +++ b/poincare/include/poincare/matrix_layout_node.h @@ -1,7 +1,6 @@ #ifndef POINCARE_MATRIX_LAYOUT_NODE_H #define POINCARE_MATRIX_LAYOUT_NODE_H -#include #include #include #include @@ -30,8 +29,6 @@ public: int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override; // TreeNode - static MatrixLayoutNode * FailedAllocationStaticNode(); - MatrixLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } size_t size() const override { return sizeof(MatrixLayoutNode); } #if POINCARE_TREE_LOG virtual void logNodeName(std::ostream & stream) const override { @@ -57,16 +54,6 @@ private: void didReplaceChildAtIndex(int index, LayoutCursor * cursor, bool force) override; }; -class AllocationFailureMatrixLayoutNode : public AllocationFailureLayoutNode { - void setNumberOfRows(int numberOfRows) override {} - void setNumberOfColumns(int numberOfColumns) override {} -protected: - void addEmptyRow(EmptyLayoutNode::Color color) override {} - void addEmptyColumn(EmptyLayoutNode::Color color) override {} - void deleteRowAtIndex(int index) override {} - void deleteColumnAtIndex(int index) override {} -}; - class MatrixLayoutRef : public GridLayoutRef { friend class MatrixLayoutNode; public: diff --git a/poincare/include/poincare/matrix_trace.h b/poincare/include/poincare/matrix_trace.h index 4b144b41a..e833d0075 100644 --- a/poincare/include/poincare/matrix_trace.h +++ b/poincare/include/poincare/matrix_trace.h @@ -7,9 +7,6 @@ namespace Poincare { class MatrixTraceNode : public ExpressionNode { public: - // Allocation Failure - static MatrixTraceNode * FailedAllocationStaticNode(); - MatrixTraceNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(MatrixTraceNode); } diff --git a/poincare/include/poincare/matrix_transpose.h b/poincare/include/poincare/matrix_transpose.h index a95b96552..81c80c334 100644 --- a/poincare/include/poincare/matrix_transpose.h +++ b/poincare/include/poincare/matrix_transpose.h @@ -7,9 +7,6 @@ namespace Poincare { class MatrixTransposeNode : public ExpressionNode { public: - // Allocation Failure - static MatrixTransposeNode * FailedAllocationStaticNode(); - MatrixTransposeNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(MatrixTransposeNode); } diff --git a/poincare/include/poincare/multiplication.h b/poincare/include/poincare/multiplication.h index c2e1af1de..88ac71227 100644 --- a/poincare/include/poincare/multiplication.h +++ b/poincare/include/poincare/multiplication.h @@ -12,8 +12,6 @@ public: using NAryExpressionNode::NAryExpressionNode; // Tree - static MultiplicationNode * FailedAllocationStaticNode(); - MultiplicationNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } size_t size() const override { return sizeof(MultiplicationNode); } #if POINCARE_TREE_LOG virtual void logNodeName(std::ostream & stream) const override { diff --git a/poincare/include/poincare/naperian_logarithm.h b/poincare/include/poincare/naperian_logarithm.h index 36423a2ed..e503bb3ab 100644 --- a/poincare/include/poincare/naperian_logarithm.h +++ b/poincare/include/poincare/naperian_logarithm.h @@ -10,10 +10,6 @@ namespace Poincare { class NaperianLogarithmNode : public ExpressionNode { public: - // Allocation Failure - static NaperianLogarithmNode * FailedAllocationStaticNode(); - NaperianLogarithmNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } - // TreeNode size_t size() const override { return sizeof(NaperianLogarithmNode); } int numberOfChildren() const override { return 1; } diff --git a/poincare/include/poincare/nth_root.h b/poincare/include/poincare/nth_root.h index 79171a03e..09ea182cd 100644 --- a/poincare/include/poincare/nth_root.h +++ b/poincare/include/poincare/nth_root.h @@ -13,8 +13,6 @@ public: Type type() const override { return Type::NthRoot; } // TreeNode - static NthRootNode * FailedAllocationStaticNode(); - NthRootNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } size_t size() const override { return sizeof(NthRootNode); } int numberOfChildren() const override { return 2; } #if POINCARE_TREE_LOG diff --git a/poincare/include/poincare/nth_root_layout_node.h b/poincare/include/poincare/nth_root_layout_node.h index a8baa89f0..8ee8e2457 100644 --- a/poincare/include/poincare/nth_root_layout_node.h +++ b/poincare/include/poincare/nth_root_layout_node.h @@ -31,8 +31,6 @@ public: bool hasUpperLeftIndex() const override { return m_hasIndex; } // TreeNode - static NthRootLayoutNode * FailedAllocationStaticNode(); - NthRootLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } size_t size() const override { return sizeof(NthRootLayoutNode); } int numberOfChildren() const override { return m_hasIndex ? 2 : 1; } #if POINCARE_TREE_LOG diff --git a/poincare/include/poincare/opposite.h b/poincare/include/poincare/opposite.h index fadb58a33..143073972 100644 --- a/poincare/include/poincare/opposite.h +++ b/poincare/include/poincare/opposite.h @@ -12,9 +12,6 @@ class OppositeNode : public ExpressionNode { public: template static Complex compute(const std::complex c, Preferences::AngleUnit angleUnit = Preferences::AngleUnit::Degree) { return Complex(-c); } - // Allocation Failure - static OppositeNode * FailedAllocationStaticNode(); - OppositeNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(OppositeNode); } diff --git a/poincare/include/poincare/parenthesis.h b/poincare/include/poincare/parenthesis.h index c5fe80934..04adb784f 100644 --- a/poincare/include/poincare/parenthesis.h +++ b/poincare/include/poincare/parenthesis.h @@ -8,8 +8,6 @@ namespace Poincare { class ParenthesisNode : public ExpressionNode { public: - static ParenthesisNode * FailedAllocationStaticNode(); - ParenthesisNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(ParenthesisNode); } diff --git a/poincare/include/poincare/permute_coefficient.h b/poincare/include/poincare/permute_coefficient.h index aa7066527..0014c63a7 100644 --- a/poincare/include/poincare/permute_coefficient.h +++ b/poincare/include/poincare/permute_coefficient.h @@ -10,8 +10,6 @@ namespace Poincare { class PermuteCoefficientNode : public ExpressionNode { public: - static PermuteCoefficientNode * FailedAllocationStaticNode(); - PermuteCoefficientNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(PermuteCoefficientNode); } diff --git a/poincare/include/poincare/power.h b/poincare/include/poincare/power.h index 29cbb4df2..e2f0a2de5 100644 --- a/poincare/include/poincare/power.h +++ b/poincare/include/poincare/power.h @@ -12,9 +12,6 @@ class Power; class PowerNode : public ExpressionNode { public: - // Allocation Failure - static PowerNode * FailedAllocationStaticNode(); - PowerNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(PowerNode); } diff --git a/poincare/include/poincare/prediction_interval.h b/poincare/include/poincare/prediction_interval.h index e71b0448b..b35f96191 100644 --- a/poincare/include/poincare/prediction_interval.h +++ b/poincare/include/poincare/prediction_interval.h @@ -9,8 +9,6 @@ namespace Poincare { class PredictionIntervalNode : public ExpressionNode { public: - static PredictionIntervalNode * FailedAllocationStaticNode(); - PredictionIntervalNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(PredictionIntervalNode); } diff --git a/poincare/include/poincare/product.h b/poincare/include/poincare/product.h index 288752f8b..e8eacdb55 100644 --- a/poincare/include/poincare/product.h +++ b/poincare/include/poincare/product.h @@ -7,9 +7,6 @@ namespace Poincare { class ProductNode : public SequenceNode { public: - // Allocation Failure - static ProductNode * FailedAllocationStaticNode(); - ProductNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(ProductNode); } #if POINCARE_TREE_LOG diff --git a/poincare/include/poincare/product_layout_node.h b/poincare/include/poincare/product_layout_node.h index a016a7bbb..ef78a5d6e 100644 --- a/poincare/include/poincare/product_layout_node.h +++ b/poincare/include/poincare/product_layout_node.h @@ -10,8 +10,6 @@ class ProductLayoutNode : public SequenceLayoutNode { public: using SequenceLayoutNode::SequenceLayoutNode; int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override; - static ProductLayoutNode * FailedAllocationStaticNode(); - ProductLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } size_t size() const override { return sizeof(ProductLayoutNode); } #if POINCARE_TREE_LOG virtual void logNodeName(std::ostream & stream) const override { diff --git a/poincare/include/poincare/randint.h b/poincare/include/poincare/randint.h index bfe2edf3d..289082086 100644 --- a/poincare/include/poincare/randint.h +++ b/poincare/include/poincare/randint.h @@ -9,9 +9,6 @@ namespace Poincare { class RandintNode : public ExpressionNode { public: - // Allocation Failure - static RandintNode * FailedAllocationStaticNode(); - RandintNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(RandintNode); } diff --git a/poincare/include/poincare/random.h b/poincare/include/poincare/random.h index 6704c2098..90a319ed0 100644 --- a/poincare/include/poincare/random.h +++ b/poincare/include/poincare/random.h @@ -10,9 +10,6 @@ namespace Poincare { class RandomNode : public ExpressionNode { public: - // Allocation Failure - static RandomNode * FailedAllocationStaticNode(); - RandomNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(RandomNode); } diff --git a/poincare/include/poincare/rational.h b/poincare/include/poincare/rational.h index 6dabfdd53..417ce778a 100644 --- a/poincare/include/poincare/rational.h +++ b/poincare/include/poincare/rational.h @@ -4,7 +4,6 @@ #include #include #include -#include namespace Poincare { @@ -16,10 +15,6 @@ public: m_numberOfDigitsDenominator(0) {} virtual void setDigits(const native_uint_t * i, size_t numeratorSize, const native_uint_t * j, size_t denominatorSize, bool negative); - // Allocation Failure - static RationalNode * FailedAllocationStaticNode(); - RationalNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } - Integer signedNumerator() const; Integer unsignedNumerator() const; Integer denominator() const; @@ -72,11 +67,6 @@ private: native_uint_t m_digits[0]; }; -class AllocationFailureRationalNode : public AllocationFailureExpressionNode { -public: - void setDigits(const native_uint_t * i, size_t numeratorSize, const native_uint_t * j, size_t denominatorSize, bool negative) override {}; -}; - class Rational : public Number { friend class RationalNode; friend class PowerNode; diff --git a/poincare/include/poincare/real_part.h b/poincare/include/poincare/real_part.h index eea68e866..9cf984ff9 100644 --- a/poincare/include/poincare/real_part.h +++ b/poincare/include/poincare/real_part.h @@ -10,9 +10,6 @@ namespace Poincare { class RealPartNode : public ExpressionNode { public: - // Allocation Failure - static RealPartNode * FailedAllocationStaticNode(); - RealPartNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(RealPartNode); } diff --git a/poincare/include/poincare/right_parenthesis_layout_node.h b/poincare/include/poincare/right_parenthesis_layout_node.h index 7b4d1d151..65d8d57fa 100644 --- a/poincare/include/poincare/right_parenthesis_layout_node.h +++ b/poincare/include/poincare/right_parenthesis_layout_node.h @@ -23,8 +23,6 @@ public: } // TreeNode - static RightParenthesisLayoutNode * FailedAllocationStaticNode(); - RightParenthesisLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } size_t size() const override { return sizeof(RightParenthesisLayoutNode); } #if POINCARE_TREE_LOG virtual void logNodeName(std::ostream & stream) const override { diff --git a/poincare/include/poincare/right_square_bracket_layout_node.h b/poincare/include/poincare/right_square_bracket_layout_node.h index e66a048e9..1141da0b4 100644 --- a/poincare/include/poincare/right_square_bracket_layout_node.h +++ b/poincare/include/poincare/right_square_bracket_layout_node.h @@ -16,8 +16,6 @@ public: bool isRightBracket() const override { return true; } // TreeNode - static RightSquareBracketLayoutNode * FailedAllocationStaticNode(); - RightSquareBracketLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } size_t size() const override { return sizeof(RightSquareBracketLayoutNode); } #if POINCARE_TREE_LOG virtual void logNodeName(std::ostream & stream) const override { diff --git a/poincare/include/poincare/round.h b/poincare/include/poincare/round.h index ac62622bd..c030e8c6e 100644 --- a/poincare/include/poincare/round.h +++ b/poincare/include/poincare/round.h @@ -10,9 +10,6 @@ namespace Poincare { class RoundNode : public ExpressionNode { public: - // Allocation Failure - static RoundNode * FailedAllocationStaticNode(); - RoundNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(RoundNode); } diff --git a/poincare/include/poincare/sine.h b/poincare/include/poincare/sine.h index 89a9f1a5a..9bfd0b4e6 100644 --- a/poincare/include/poincare/sine.h +++ b/poincare/include/poincare/sine.h @@ -10,9 +10,6 @@ namespace Poincare { class SineNode : public ExpressionNode { public: - // Allocation Failure - static SineNode * FailedAllocationStaticNode(); - SineNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(SineNode); } diff --git a/poincare/include/poincare/square_root.h b/poincare/include/poincare/square_root.h index 968573fd9..6c43c055f 100644 --- a/poincare/include/poincare/square_root.h +++ b/poincare/include/poincare/square_root.h @@ -13,8 +13,6 @@ public: Type type() const override { return Type::SquareRoot; } // TreeNode - static SquareRootNode * FailedAllocationStaticNode(); - SquareRootNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } size_t size() const override { return sizeof(SquareRootNode); } int numberOfChildren() const override { return 1; } #if POINCARE_TREE_LOG diff --git a/poincare/include/poincare/store.h b/poincare/include/poincare/store.h index b81a0481b..6b0662030 100644 --- a/poincare/include/poincare/store.h +++ b/poincare/include/poincare/store.h @@ -10,8 +10,6 @@ namespace Poincare { class StoreNode : public ExpressionNode { public: - static StoreNode * FailedAllocationStaticNode(); - StoreNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(StoreNode); } diff --git a/poincare/include/poincare/subtraction.h b/poincare/include/poincare/subtraction.h index 217c6ec5a..8f94254d8 100644 --- a/poincare/include/poincare/subtraction.h +++ b/poincare/include/poincare/subtraction.h @@ -9,8 +9,6 @@ namespace Poincare { class SubtractionNode : public ExpressionNode { public: - static SubtractionNode * FailedAllocationStaticNode(); - SubtractionNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(SubtractionNode); } diff --git a/poincare/include/poincare/sum.h b/poincare/include/poincare/sum.h index 0fa3b84fa..08756a031 100644 --- a/poincare/include/poincare/sum.h +++ b/poincare/include/poincare/sum.h @@ -7,9 +7,6 @@ namespace Poincare { class SumNode : public SequenceNode { public: - // Allocation Failure - static SumNode * FailedAllocationStaticNode(); - SumNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(SumNode); } #if POINCARE_TREE_LOG diff --git a/poincare/include/poincare/sum_layout_node.h b/poincare/include/poincare/sum_layout_node.h index 945366422..fa00fa3a4 100644 --- a/poincare/include/poincare/sum_layout_node.h +++ b/poincare/include/poincare/sum_layout_node.h @@ -10,8 +10,6 @@ class SumLayoutNode : public SequenceLayoutNode { public: using SequenceLayoutNode::SequenceLayoutNode; int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override; - static SumLayoutNode * FailedAllocationStaticNode(); - SumLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } size_t size() const override { return sizeof(SumLayoutNode); } #if POINCARE_TREE_LOG virtual void logNodeName(std::ostream & stream) const override { diff --git a/poincare/include/poincare/symbol.h b/poincare/include/poincare/symbol.h index 2cc872a51..89e774b9b 100644 --- a/poincare/include/poincare/symbol.h +++ b/poincare/include/poincare/symbol.h @@ -10,8 +10,6 @@ class SymbolNode : public ExpressionNode { public: SymbolNode() : m_name(0) {} - static SymbolNode * FailedAllocationStaticNode(); - SymbolNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } void setName(const char name) { m_name = name; } char name() const { return m_name; } diff --git a/poincare/include/poincare/tangent.h b/poincare/include/poincare/tangent.h index 5eb0060c6..50baf09d5 100644 --- a/poincare/include/poincare/tangent.h +++ b/poincare/include/poincare/tangent.h @@ -9,9 +9,6 @@ namespace Poincare { class TangentNode : public ExpressionNode { public: - // Allocation Failure - static TangentNode * FailedAllocationStaticNode(); - TangentNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(TangentNode); } diff --git a/poincare/include/poincare/tree_by_reference.h b/poincare/include/poincare/tree_by_reference.h index ce51d272f..beabcd2b7 100644 --- a/poincare/include/poincare/tree_by_reference.h +++ b/poincare/include/poincare/tree_by_reference.h @@ -46,7 +46,6 @@ public: bool isGhost() const { return node()->isGhost(); } bool isUninitialized() const { return node()->isUninitialized(); } - bool isAllocationFailure() const { return node()->isAllocationFailure(); } bool isStatic() const { return node()->isStatic(); } @@ -70,7 +69,6 @@ public: void replaceWithInPlace(TreeByReference t); void replaceChildInPlace(TreeByReference oldChild, TreeByReference newChild); void replaceChildAtIndexInPlace(int oldChildIndex, TreeByReference newChild); - void replaceWithAllocationFailureInPlace(int currentNumberOfChildren); void replaceChildAtIndexWithGhostInPlace(int index) { assert(index >= 0 && index < numberOfChildren()); replaceChildWithGhostInPlace(childAtIndex(index)); diff --git a/poincare/include/poincare/tree_node.h b/poincare/include/poincare/tree_node.h index 3e283fd7c..ee692cea1 100644 --- a/poincare/include/poincare/tree_node.h +++ b/poincare/include/poincare/tree_node.h @@ -39,11 +39,6 @@ public: // Ghost virtual bool isGhost() const { return false; } - // Allocation failure - virtual bool isAllocationFailure() const { return false; } - virtual TreeNode * failedAllocationStaticNode() = 0; - int allocationFailureNodeIdentifier() { return failedAllocationStaticNode()->identifier(); } - // Node operations void setReferenceCounter(int refCount) { m_referenceCounter = refCount; } void retain() { m_referenceCounter++; } // It doesn't matter if the node is static diff --git a/poincare/include/poincare/tree_pool.h b/poincare/include/poincare/tree_pool.h index bc6d42aa5..142c3a37f 100644 --- a/poincare/include/poincare/tree_pool.h +++ b/poincare/include/poincare/tree_pool.h @@ -48,36 +48,13 @@ public: template T * createTreeNode(size_t size = sizeof(T)) { int nodeIdentifier = generateIdentifier(); - if (nodeIdentifier == -1) { - T::FailedAllocationStaticNode()->retain(); - return T::FailedAllocationStaticNode(); - } void * ptr = alloc(size); - if (ptr == nullptr) { - T::FailedAllocationStaticNode()->retain(); - return T::FailedAllocationStaticNode(); - } T * node = new(ptr) T(); // Ensure the pool is syntactially correct by creating ghost children if needed. // It's needed for children that have a fixed, non-zero number of children. for (int i = 0; i < node->numberOfChildren(); i++) { TreeNode * ghost = createTreeNode(); - if (ghost->isAllocationFailure()) { - /* There is no room to create the node and all of its children, so - * delete the node, the children already built and return an allocation - * failure node. */ - // Discard the node and its first children - discardTreeNode(node); - for (int j = 0; j < i; j++) { - /* The pool has been compacted, so the next child to discard is at the - * address "node" */ - discardTreeNode(node); - } - // Return an allocation failure node - T::FailedAllocationStaticNode()->retain(); - return T::FailedAllocationStaticNode(); - } ghost->retain(); move(node->next(), ghost, 0); } @@ -93,10 +70,6 @@ public: TreeNode * deepCopy(TreeNode * node) { size_t size = node->deepSize(-1); void * ptr = alloc(size); - if (ptr == nullptr) { - node->failedAllocationStaticNode()->retain(); - return node->failedAllocationStaticNode(); - } memcpy(ptr, static_cast(node), size); TreeNode * copy = reinterpret_cast(ptr); renameNode(copy, false); @@ -238,6 +211,7 @@ private: } int pop() { if (m_currentIndex == 0) { + assert(false); return -1; } assert(m_currentIndex > 0 && m_currentIndex <= MaxNumberOfNodes); diff --git a/poincare/include/poincare/undefined.h b/poincare/include/poincare/undefined.h index debf24bff..876c44074 100644 --- a/poincare/include/poincare/undefined.h +++ b/poincare/include/poincare/undefined.h @@ -2,14 +2,11 @@ #define POINCARE_UNDEFINED_H #include -#include namespace Poincare { class UndefinedNode : public NumberNode { public: - static UndefinedNode * FailedAllocationStaticNode(); - UndefinedNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } // TreeNode size_t size() const override { return sizeof(UndefinedNode); } diff --git a/poincare/include/poincare/uninitialized_evaluation_node.h b/poincare/include/poincare/uninitialized_evaluation_node.h index c2924faee..344665601 100644 --- a/poincare/include/poincare/uninitialized_evaluation_node.h +++ b/poincare/include/poincare/uninitialized_evaluation_node.h @@ -16,9 +16,6 @@ public: static UninitializedEvaluationNode * UninitializedEvaluationStaticNode(); // TreeNode bool isUninitialized() const override { return true; } - /* There is only one static node, that should never be inserted in the pool, - * so no need for an allocation failure. */ - TreeNode * failedAllocationStaticNode() override { assert(false); return nullptr; } size_t size() const override { return sizeof(UninitializedEvaluationNode); } #if POINCARE_TREE_LOG virtual void logNodeName(std::ostream & stream) const override { diff --git a/poincare/include/poincare/uninitialized_expression_node.h b/poincare/include/poincare/uninitialized_expression_node.h index 1d5b16f5d..8e7684851 100644 --- a/poincare/include/poincare/uninitialized_expression_node.h +++ b/poincare/include/poincare/uninitialized_expression_node.h @@ -28,9 +28,6 @@ public: // TreeNode bool isUninitialized() const override { return true; } - /* There is only one static node, that should never be inserted in the pool, - * so no need for an allocation failure. */ - TreeNode * failedAllocationStaticNode() override { assert(false); return nullptr; } size_t size() const override { return sizeof(UninitializedExpressionNode); } Expression denominator(Context & context, Preferences::AngleUnit angleUnit) const override { assert(false); return ExceptionExpressionNode::denominator(context, angleUnit); } #if POINCARE_TREE_LOG diff --git a/poincare/include/poincare/uninitialized_ghost_node.h b/poincare/include/poincare/uninitialized_ghost_node.h index 942951df9..7b03e1902 100644 --- a/poincare/include/poincare/uninitialized_ghost_node.h +++ b/poincare/include/poincare/uninitialized_ghost_node.h @@ -13,9 +13,6 @@ public: // TreeNode bool isUninitialized() const override { return true; } - /* There is only one static node, that should never be inserted in the pool, - * so no need for an allocation failure. */ - TreeNode * failedAllocationStaticNode() override { assert(false); return nullptr; } size_t size() const override { return sizeof(UninitializedGhostNode); } #if POINCARE_TREE_LOG virtual void logNodeName(std::ostream & stream) const override { diff --git a/poincare/include/poincare/uninitialized_layout_node.h b/poincare/include/poincare/uninitialized_layout_node.h index 3e913db9d..9de7308f4 100644 --- a/poincare/include/poincare/uninitialized_layout_node.h +++ b/poincare/include/poincare/uninitialized_layout_node.h @@ -61,9 +61,6 @@ public: // TreeNode bool isUninitialized() const override { return true; } - /* There is only one static node, that should never be inserted in the pool, - * so no need for an allocation failure. */ - TreeNode * failedAllocationStaticNode() override { assert(false); return nullptr; } size_t size() const override { return sizeof(UninitializedLayoutNode); } #if POINCARE_TREE_LOG virtual void logNodeName(std::ostream & stream) const override { diff --git a/poincare/include/poincare/vertical_offset_layout_node.h b/poincare/include/poincare/vertical_offset_layout_node.h index a2d1c9c1a..d8a79e23b 100644 --- a/poincare/include/poincare/vertical_offset_layout_node.h +++ b/poincare/include/poincare/vertical_offset_layout_node.h @@ -19,10 +19,6 @@ public: m_type(type) {} - // AllocationFailure - static VerticalOffsetLayoutNode * FailedAllocationStaticNode(); - VerticalOffsetLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } - // VerticalOffsetLayoutNode Type type() const { return m_type; } void setType(Type type) { m_type = type; } diff --git a/poincare/src/absolute_value.cpp b/poincare/src/absolute_value.cpp index 21fb0166c..6d7d46488 100644 --- a/poincare/src/absolute_value.cpp +++ b/poincare/src/absolute_value.cpp @@ -1,21 +1,11 @@ #include #include #include -#include - -extern "C" { #include -} #include namespace Poincare { -AbsoluteValueNode * AbsoluteValueNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - Expression AbsoluteValueNode::setSign(Sign s, Context & context, Preferences::AngleUnit angleUnit) { return AbsoluteValue(this).setSign(s, context, angleUnit); } @@ -40,7 +30,7 @@ Expression AbsoluteValue::setSign(ExpressionNode::Sign s, Context & context, Pre Expression AbsoluteValue::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } Expression c = childAtIndex(0); diff --git a/poincare/src/absolute_value_layout_node.cpp b/poincare/src/absolute_value_layout_node.cpp deleted file mode 100644 index cb75d43ce..000000000 --- a/poincare/src/absolute_value_layout_node.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include - -namespace Poincare { - -AbsoluteValueLayoutNode * AbsoluteValueLayoutNode::FailedAllocationStaticNode() { - static AllocationFailureLayoutNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - -} diff --git a/poincare/src/addition.cpp b/poincare/src/addition.cpp index 149537bf2..baa19e2eb 100644 --- a/poincare/src/addition.cpp +++ b/poincare/src/addition.cpp @@ -9,12 +9,6 @@ namespace Poincare { -AdditionNode * AdditionNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - int AdditionNode::polynomialDegree(char symbolName) const { int degree = 0; for (int i = 0; i < numberOfChildren(); i++) { @@ -135,7 +129,7 @@ Expression Addition::shallowBeautify(Context & context, Preferences::AngleUnit a Expression Addition::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/approximation_helper.cpp b/poincare/src/approximation_helper.cpp index bb8f165dd..295c45590 100644 --- a/poincare/src/approximation_helper.cpp +++ b/poincare/src/approximation_helper.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -28,9 +29,7 @@ template std::complex ApproximationHelper::TruncateRealOrImagina template Evaluation ApproximationHelper::Map(const ExpressionNode * expression, Context& context, Preferences::AngleUnit angleUnit, ComplexCompute compute) { assert(expression->numberOfChildren() == 1); Evaluation input = expression->childAtIndex(0)->approximate(T(), context, angleUnit); - if (input.node()->type() == EvaluationNode::Type::AllocationFailure) { - return Complex::Undefined(); - } else if (input.node()->type() == EvaluationNode::Type::Complex) { + if (input.node()->type() == EvaluationNode::Type::Complex) { const ComplexNode * c = static_cast *>(input.node()); return compute(*c, angleUnit); } else { @@ -51,9 +50,6 @@ template Evaluation ApproximationHelper::MapReduce(const Expressi for (int i = 1; i < expression->numberOfChildren(); i++) { Evaluation intermediateResult; Evaluation nextOperandEvaluation = expression->childAtIndex(i)->approximate(T(), context, angleUnit); - if (result.node()->type() == EvaluationNode::Type::AllocationFailure || nextOperandEvaluation.node()->type() == EvaluationNode::Type::AllocationFailure) { - return Complex::Undefined(); - } if (result.node()->type() == EvaluationNode::Type::Complex && nextOperandEvaluation.node()->type() == EvaluationNode::Type::Complex) { const ComplexNode * c = static_cast *>(result.node()); const ComplexNode * d = static_cast *>(nextOperandEvaluation.node()); diff --git a/poincare/src/arc_cosine.cpp b/poincare/src/arc_cosine.cpp index 8ed9234d8..c6eb51a53 100644 --- a/poincare/src/arc_cosine.cpp +++ b/poincare/src/arc_cosine.cpp @@ -6,12 +6,6 @@ namespace Poincare { -ArcCosineNode * ArcCosineNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - LayoutReference ArcCosineNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return LayoutHelper::Prefix(ArcCosine(this), floatDisplayMode, numberOfSignificantDigits, name()); } @@ -38,7 +32,7 @@ Complex ArcCosineNode::computeOnComplex(const std::complex c, Preferences: Expression ArcCosine::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/arc_sine.cpp b/poincare/src/arc_sine.cpp index fee872a3d..d5f1fdfdf 100644 --- a/poincare/src/arc_sine.cpp +++ b/poincare/src/arc_sine.cpp @@ -6,12 +6,6 @@ namespace Poincare { -ArcSineNode * ArcSineNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - LayoutReference ArcSineNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return LayoutHelper::Prefix(ArcSine(this), floatDisplayMode, numberOfSignificantDigits, name()); } @@ -38,7 +32,7 @@ Complex ArcSineNode::computeOnComplex(const std::complex c, Preferences::A Expression ArcSine::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/arc_tangent.cpp b/poincare/src/arc_tangent.cpp index 6fc0c885b..77c39fc0c 100644 --- a/poincare/src/arc_tangent.cpp +++ b/poincare/src/arc_tangent.cpp @@ -6,12 +6,6 @@ namespace Poincare { -ArcTangentNode * ArcTangentNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - LayoutReference ArcTangentNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return LayoutHelper::Prefix(ArcTangent(this), floatDisplayMode, numberOfSignificantDigits, name()); } @@ -38,7 +32,7 @@ Expression ArcTangentNode::shallowReduce(Context & context, Preferences::AngleUn Expression ArcTangent::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/binomial_coefficient.cpp b/poincare/src/binomial_coefficient.cpp index 2ba863fa7..687ea7d8d 100644 --- a/poincare/src/binomial_coefficient.cpp +++ b/poincare/src/binomial_coefficient.cpp @@ -9,12 +9,6 @@ namespace Poincare { -BinomialCoefficientNode * BinomialCoefficientNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - Expression BinomialCoefficientNode::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { return BinomialCoefficient(this).shallowReduce(context, angleUnit); } @@ -57,7 +51,7 @@ T BinomialCoefficientNode::compute(T k, T n) { Expression BinomialCoefficient::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/binomial_coefficient_layout_node.cpp b/poincare/src/binomial_coefficient_layout_node.cpp index e78170cce..8723635cf 100644 --- a/poincare/src/binomial_coefficient_layout_node.cpp +++ b/poincare/src/binomial_coefficient_layout_node.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -9,12 +8,6 @@ namespace Poincare { static inline KDCoordinate max(KDCoordinate x, KDCoordinate y) { return x > y ? x : y; } -BinomialCoefficientLayoutNode * BinomialCoefficientLayoutNode::FailedAllocationStaticNode() { - static AllocationFailureLayoutNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - void BinomialCoefficientLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) { if (cursor->position() == LayoutCursor::Position::Left && (cursor->layoutNode() == nLayout() diff --git a/poincare/src/bracket_pair_layout_node.cpp b/poincare/src/bracket_pair_layout_node.cpp index d30065c6a..3b8755b69 100644 --- a/poincare/src/bracket_pair_layout_node.cpp +++ b/poincare/src/bracket_pair_layout_node.cpp @@ -73,15 +73,10 @@ void BracketPairLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * should void BracketPairLayoutNode::deleteBeforeCursor(LayoutCursor * cursor) { if (cursor->isEquivalentTo(LayoutCursor(childLayout(), LayoutCursor::Position::Left))) { // Case: Left of the operand. Delete the layout, keep the operand. - LayoutRef rootRef = LayoutRef(root()); LayoutRef thisRef = LayoutRef(this); LayoutRef child = LayoutRef(childLayout()); thisRef.replaceChildWithGhostInPlace(child); // WARNING: do not call "this" afterwards - if (rootRef.isAllocationFailure()) { - cursor->setLayoutReference(rootRef); - return; - } cursor->setLayoutReference(thisRef.childAtIndex(0)); cursor->setPosition(LayoutCursor::Position::Left); thisRef.replaceWith(child, cursor); diff --git a/poincare/src/ceiling.cpp b/poincare/src/ceiling.cpp index 8307e7bf2..85edbc8b6 100644 --- a/poincare/src/ceiling.cpp +++ b/poincare/src/ceiling.cpp @@ -10,12 +10,6 @@ namespace Poincare { -CeilingNode * CeilingNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - LayoutReference CeilingNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return CeilingLayoutRef(childAtIndex(0)->createLayout(floatDisplayMode, numberOfSignificantDigits)); } @@ -39,7 +33,7 @@ Expression CeilingNode::shallowReduce(Context & context, Preferences::AngleUnit Expression Ceiling::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/ceiling_layout_node.cpp b/poincare/src/ceiling_layout_node.cpp index b98bb5c72..f7631b360 100644 --- a/poincare/src/ceiling_layout_node.cpp +++ b/poincare/src/ceiling_layout_node.cpp @@ -1,12 +1,5 @@ #include -#include namespace Poincare { -CeilingLayoutNode * CeilingLayoutNode::FailedAllocationStaticNode() { - static AllocationFailureLayoutNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - } diff --git a/poincare/src/char_layout_node.cpp b/poincare/src/char_layout_node.cpp index 43227d653..521a90822 100644 --- a/poincare/src/char_layout_node.cpp +++ b/poincare/src/char_layout_node.cpp @@ -4,12 +4,6 @@ namespace Poincare { -CharLayoutNode * CharLayoutNode::FailedAllocationStaticNode() { - static AllocationFailureCharLayoutNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - // LayoutNode void CharLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) { if (cursor->position() == LayoutCursor::Position::Right) { diff --git a/poincare/src/complex.cpp b/poincare/src/complex.cpp index 91413fd16..19de8bfc7 100644 --- a/poincare/src/complex.cpp +++ b/poincare/src/complex.cpp @@ -6,7 +6,6 @@ extern "C" { #include #include #include -#include #include #include #include @@ -21,18 +20,6 @@ extern "C" { namespace Poincare { -template -class AllocationFailureComplexNode : public AllocationFailureEvaluationNode { - void setComplex(std::complex c) override {} -}; - -template -ComplexNode * ComplexNode::FailedAllocationStaticNode() { - static AllocationFailureComplexNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - template void ComplexNode::setComplex(std::complex c) { this->real(c.real()); diff --git a/poincare/src/complex_argument.cpp b/poincare/src/complex_argument.cpp index 61092442e..575699bb0 100644 --- a/poincare/src/complex_argument.cpp +++ b/poincare/src/complex_argument.cpp @@ -9,12 +9,6 @@ extern "C" { namespace Poincare { -ComplexArgumentNode * ComplexArgumentNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - LayoutReference ComplexArgumentNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return LayoutHelper::Prefix(ComplexArgument(this), floatDisplayMode, numberOfSignificantDigits, name()); } @@ -35,7 +29,7 @@ Complex ComplexArgumentNode::computeOnComplex(const std::complex c, Prefer Expression ComplexArgument::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/condensed_sum_layout_node.cpp b/poincare/src/condensed_sum_layout_node.cpp index 2b10b8d8e..e8a86b8eb 100644 --- a/poincare/src/condensed_sum_layout_node.cpp +++ b/poincare/src/condensed_sum_layout_node.cpp @@ -1,5 +1,4 @@ #include -#include #include #include @@ -7,12 +6,6 @@ namespace Poincare { static inline KDCoordinate max(KDCoordinate x, KDCoordinate y) { return x > y ? x : y; } -CondensedSumLayoutNode * CondensedSumLayoutNode::FailedAllocationStaticNode() { - static AllocationFailureLayoutNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - KDCoordinate CondensedSumLayoutNode::computeBaseline() { KDSize superscriptSize = superscriptLayout()->isUninitialized() ? KDSizeZero : superscriptLayout()->layoutSize(); return baseLayout()->baseline() + max(0, superscriptSize.height() - baseLayout()->layoutSize().height()/2); diff --git a/poincare/src/confidence_interval.cpp b/poincare/src/confidence_interval.cpp index 35b299c2c..3e638a937 100644 --- a/poincare/src/confidence_interval.cpp +++ b/poincare/src/confidence_interval.cpp @@ -11,12 +11,6 @@ namespace Poincare { -ConfidenceIntervalNode * ConfidenceIntervalNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - LayoutReference ConfidenceIntervalNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return LayoutHelper::Prefix(ConfidenceInterval(this), floatDisplayMode, numberOfSignificantDigits, name()); } @@ -44,16 +38,10 @@ Evaluation ConfidenceIntervalNode::templatedApproximate(Context& context, Pre return MatrixComplex(operands, 1, 2); } -SimplePredictionIntervalNode * SimplePredictionIntervalNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - Expression ConfidenceInterval::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/conjugate.cpp b/poincare/src/conjugate.cpp index d238666d8..bff564490 100644 --- a/poincare/src/conjugate.cpp +++ b/poincare/src/conjugate.cpp @@ -7,12 +7,6 @@ namespace Poincare { -ConjugateNode * ConjugateNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - LayoutRef ConjugateNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return ConjugateLayoutRef(childAtIndex(0)->createLayout(floatDisplayMode, numberOfSignificantDigits)); } @@ -33,7 +27,7 @@ Complex ConjugateNode::computeOnComplex(const std::complex c, Preferences: Expression Conjugate::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/conjugate_layout_node.cpp b/poincare/src/conjugate_layout_node.cpp index 5a80b4f4d..c81d8600c 100644 --- a/poincare/src/conjugate_layout_node.cpp +++ b/poincare/src/conjugate_layout_node.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -7,12 +6,6 @@ namespace Poincare { -ConjugateLayoutNode * ConjugateLayoutNode::FailedAllocationStaticNode() { - static AllocationFailureLayoutNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - void ConjugateLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) { if (!childLayout()->isUninitialized() && cursor->layoutNode() == childLayout() diff --git a/poincare/src/cosine.cpp b/poincare/src/cosine.cpp index bbc00a86e..a4902d291 100644 --- a/poincare/src/cosine.cpp +++ b/poincare/src/cosine.cpp @@ -6,12 +6,6 @@ namespace Poincare { -CosineNode * CosineNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - float CosineNode::characteristicXRange(Context & context, Preferences::AngleUnit angleUnit) const { return Trigonometry::characteristicXRange(Cosine(this), context, angleUnit); } @@ -34,7 +28,7 @@ Expression CosineNode::shallowReduce(Context & context, Preferences::AngleUnit a Expression Cosine::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/decimal.cpp b/poincare/src/decimal.cpp index 655603170..092943ae9 100644 --- a/poincare/src/decimal.cpp +++ b/poincare/src/decimal.cpp @@ -31,12 +31,6 @@ void DecimalNode::setValue(const native_uint_t * mantissaDigits, size_t mantissa memcpy(m_mantissa, mantissaDigits, mantissaSize*sizeof(native_uint_t)); } -DecimalNode * DecimalNode::FailedAllocationStaticNode() { - static AllocationFailureDecimalNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - Integer DecimalNode::signedMantissa() const { return Integer((native_uint_t *)m_mantissa, m_numberOfDigitsInMantissa, m_negative); } @@ -318,7 +312,7 @@ Expression Decimal::setSign(ExpressionNode::Sign s, Context & context, Preferenc Expression Decimal::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } // this = e diff --git a/poincare/src/derivative.cpp b/poincare/src/derivative.cpp index 4094d9581..9f7c4ddad 100644 --- a/poincare/src/derivative.cpp +++ b/poincare/src/derivative.cpp @@ -8,12 +8,6 @@ namespace Poincare { -DerivativeNode * DerivativeNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - int DerivativeNode::polynomialDegree(char symbolName) const { if (symbolName == 'x') { if (childAtIndex(1)->polynomialDegree(symbolName) != 0) { @@ -119,7 +113,7 @@ T DerivativeNode::riddersApproximation(Context & context, Preferences::AngleUnit Expression Derivative::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/determinant.cpp b/poincare/src/determinant.cpp index cae18cfa5..ab07fbcde 100644 --- a/poincare/src/determinant.cpp +++ b/poincare/src/determinant.cpp @@ -8,12 +8,6 @@ extern "C" { namespace Poincare { -DeterminantNode * DeterminantNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - LayoutRef DeterminantNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return LayoutHelper::Prefix(Determinant(this), floatDisplayMode, numberOfSignificantDigits, name()); } @@ -32,7 +26,7 @@ Expression DeterminantNode::shallowReduce(Context & context, Preferences::AngleU Expression Determinant::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/division.cpp b/poincare/src/division.cpp index 13f8dfc47..5f27ef0da 100644 --- a/poincare/src/division.cpp +++ b/poincare/src/division.cpp @@ -11,12 +11,6 @@ namespace Poincare { -DivisionNode * DivisionNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - int DivisionNode::polynomialDegree(char symbolName) const { if (childAtIndex(1)->polynomialDegree(symbolName) != 0) { return -1; @@ -63,7 +57,7 @@ template MatrixComplex DivisionNode::computeOnMatrices(const Matr Expression Division::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/division_quotient.cpp b/poincare/src/division_quotient.cpp index 0fe2f6757..d305a5857 100644 --- a/poincare/src/division_quotient.cpp +++ b/poincare/src/division_quotient.cpp @@ -8,12 +8,6 @@ namespace Poincare { -DivisionQuotientNode * DivisionQuotientNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - Expression DivisionQuotientNode::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { return DivisionQuotient(this).shallowReduce(context, angleUnit); } @@ -40,7 +34,7 @@ Evaluation DivisionQuotientNode::templatedApproximate(Context& context, Prefe Expression DivisionQuotient::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/division_remainder.cpp b/poincare/src/division_remainder.cpp index 30761f2f3..3dec8cbc4 100644 --- a/poincare/src/division_remainder.cpp +++ b/poincare/src/division_remainder.cpp @@ -8,12 +8,6 @@ namespace Poincare { -DivisionRemainderNode * DivisionRemainderNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - LayoutReference DivisionRemainderNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return LayoutHelper::Prefix(DivisionRemainder(this), floatDisplayMode, numberOfSignificantDigits, name()); } @@ -40,7 +34,7 @@ Evaluation DivisionRemainderNode::templatedApproximate(Context& context, Pref Expression DivisionRemainder::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/empty_expression.cpp b/poincare/src/empty_expression.cpp index fb324553e..f87ba3bf2 100644 --- a/poincare/src/empty_expression.cpp +++ b/poincare/src/empty_expression.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -7,12 +6,6 @@ namespace Poincare { -EmptyExpressionNode * EmptyExpressionNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - int EmptyExpressionNode::serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return SerializationHelper::Char(buffer, bufferSize, Ion::Charset::Empty); } diff --git a/poincare/src/empty_layout_node.cpp b/poincare/src/empty_layout_node.cpp index 36cad23f5..d95b4e4db 100644 --- a/poincare/src/empty_layout_node.cpp +++ b/poincare/src/empty_layout_node.cpp @@ -5,12 +5,6 @@ namespace Poincare { -EmptyLayoutNode * EmptyLayoutNode::FailedAllocationStaticNode() { - static AllocationFailureLayoutNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - void EmptyLayoutNode::deleteBeforeCursor(LayoutCursor * cursor) { cursor->setPosition(LayoutCursor::Position::Left); LayoutNode * p = parent(); @@ -77,17 +71,10 @@ bool EmptyLayoutNode::willAddSibling(LayoutCursor * cursor, LayoutNode * sibling if (m_color == Color::Grey) { /* The parent is a MatrixLayout, and the current empty row or column is * being filled in, so add a new empty row or column. */ - LayoutRef rootRef = LayoutRef(root()); LayoutNode * parentNode = parent(); assert(!parentNode->isUninitialized()); parentNode->willAddSiblingToEmptyChildAtIndex(parentNode->indexOfChild(this)); // WARNING: Do not use previous node pointers afterwards. - if (rootRef.isAllocationFailure()) { - if (moveCursor) { - cursor->setLayoutReference(rootRef); - } - return false; - } } if (siblingRef.mustHaveLeftSibling()) { thisRef.setColor(Color::Yellow); diff --git a/poincare/src/equal.cpp b/poincare/src/equal.cpp index a5667a6e8..a13a2bd62 100644 --- a/poincare/src/equal.cpp +++ b/poincare/src/equal.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -20,12 +19,6 @@ extern "C" { } namespace Poincare { -EqualNode * EqualNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - Expression EqualNode::standardEquation(Context & context, Preferences::AngleUnit angleUnit) const { Expression sub = Subtraction(Expression(childAtIndex(0)).clone(), Expression(childAtIndex(1)).clone()); return sub.deepReduce(context, angleUnit); @@ -55,7 +48,7 @@ Evaluation EqualNode::templatedApproximate(Context& context, Preferences::Ang Expression Equal::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/expression.cpp b/poincare/src/expression.cpp index 12addb4f3..7a8f6d5a6 100644 --- a/poincare/src/expression.cpp +++ b/poincare/src/expression.cpp @@ -166,13 +166,7 @@ bool Expression::getLinearCoefficients(char * variables, Expression coefficients Expression Expression::defaultShallowReduce(Context & context, Preferences::AngleUnit angleUnit) { for (int i = 0; i < numberOfChildren(); i++) { - Expression childI = childAtIndex(i); - if (childI.isAllocationFailure()) { - Expression result = Expression(UndefinedNode::FailedAllocationStaticNode()); - replaceWithInPlace(result); - return result; - } - if (childI.type() == ExpressionNode::Type::Undefined) { + if (childAtIndex(i).type() == ExpressionNode::Type::Undefined) { Expression result = Undefined(); replaceWithInPlace(result); return result; diff --git a/poincare/src/factor.cpp b/poincare/src/factor.cpp index 6d0b49fc8..392f80a29 100644 --- a/poincare/src/factor.cpp +++ b/poincare/src/factor.cpp @@ -13,12 +13,6 @@ extern "C" { namespace Poincare { -FactorNode * FactorNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - LayoutRef FactorNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return LayoutHelper::Prefix(Factor(this), floatDisplayMode, numberOfSignificantDigits, name()); } diff --git a/poincare/src/factorial.cpp b/poincare/src/factorial.cpp index 9826af585..f611416bf 100644 --- a/poincare/src/factorial.cpp +++ b/poincare/src/factorial.cpp @@ -11,12 +11,6 @@ namespace Poincare { -FactorialNode * FactorialNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - // Layout bool FactorialNode::needsParenthesesWithParent(const SerializationHelperInterface * e) const { @@ -83,7 +77,7 @@ int FactorialNode::serialize(char * buffer, int bufferSize, Preferences::PrintFl Expression Factorial::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/float.cpp b/poincare/src/float.cpp index f4b7fda48..76c3d554f 100644 --- a/poincare/src/float.cpp +++ b/poincare/src/float.cpp @@ -1,15 +1,7 @@ #include -#include namespace Poincare { -template -FloatNode * FloatNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode> failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - template Expression FloatNode::setSign(Sign s, Context & context, Preferences::AngleUnit angleUnit) { Expression thisExpr = Number(this); diff --git a/poincare/src/floor.cpp b/poincare/src/floor.cpp index 9c73d0e81..48a2aa9ef 100644 --- a/poincare/src/floor.cpp +++ b/poincare/src/floor.cpp @@ -10,12 +10,6 @@ namespace Poincare { -FloorNode * FloorNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - LayoutRef FloorNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return FloorLayoutRef(childAtIndex(0)->createLayout(floatDisplayMode, numberOfSignificantDigits)); } @@ -39,7 +33,7 @@ Expression FloorNode::shallowReduce(Context & context, Preferences::AngleUnit an Expression Floor::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/floor_layout_node.cpp b/poincare/src/floor_layout_node.cpp index 339e745fc..adeb495f9 100644 --- a/poincare/src/floor_layout_node.cpp +++ b/poincare/src/floor_layout_node.cpp @@ -1,12 +1,5 @@ #include -#include namespace Poincare { -FloorLayoutNode * FloorLayoutNode::FailedAllocationStaticNode() { - static AllocationFailureLayoutNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - } diff --git a/poincare/src/frac_part.cpp b/poincare/src/frac_part.cpp index 3bd2bd8ae..611f85fd3 100644 --- a/poincare/src/frac_part.cpp +++ b/poincare/src/frac_part.cpp @@ -7,12 +7,6 @@ namespace Poincare { -FracPartNode * FracPartNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - LayoutRef FracPartNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return LayoutHelper::Prefix(FracPart(this), floatDisplayMode, numberOfSignificantDigits, name()); } @@ -36,7 +30,7 @@ Complex FracPartNode::computeOnComplex(const std::complex c, Preferences:: Expression FracPart::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/fraction_layout_node.cpp b/poincare/src/fraction_layout_node.cpp index 4524eec6d..509ea6435 100644 --- a/poincare/src/fraction_layout_node.cpp +++ b/poincare/src/fraction_layout_node.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -12,12 +11,6 @@ namespace Poincare { static inline KDCoordinate max(KDCoordinate x, KDCoordinate y) { return x > y ? x : y; } -FractionLayoutNode * FractionLayoutNode::FailedAllocationStaticNode() { - static AllocationFailureLayoutNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - void FractionLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) { if (cursor->position() == LayoutCursor::Position::Left && ((!numeratorLayout()->isUninitialized() && cursor->layoutNode() == numeratorLayout()) diff --git a/poincare/src/ghost_node.cpp b/poincare/src/ghost_node.cpp index 20324ed2b..8c1c5f123 100644 --- a/poincare/src/ghost_node.cpp +++ b/poincare/src/ghost_node.cpp @@ -4,12 +4,6 @@ namespace Poincare { -GhostNode * GhostNode::FailedAllocationStaticNode() { - static AllocationFailedGhostNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - TreeNode * GhostNode::uninitializedStaticNode() const { return UninitializedGhostNode::UninitializedGhostStaticNode(); } diff --git a/poincare/src/great_common_divisor.cpp b/poincare/src/great_common_divisor.cpp index 9e4d3a391..5dcea685e 100644 --- a/poincare/src/great_common_divisor.cpp +++ b/poincare/src/great_common_divisor.cpp @@ -8,12 +8,6 @@ namespace Poincare { -GreatCommonDivisorNode * GreatCommonDivisorNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - LayoutReference GreatCommonDivisorNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return LayoutHelper::Prefix(GreatCommonDivisor(this), floatDisplayMode, numberOfSignificantDigits, name()); } @@ -53,7 +47,7 @@ Evaluation GreatCommonDivisorNode::templatedApproximate(Context& context, Pre Expression GreatCommonDivisor::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/grid_layout_node.cpp b/poincare/src/grid_layout_node.cpp index 9c012baff..24f6345f1 100644 --- a/poincare/src/grid_layout_node.cpp +++ b/poincare/src/grid_layout_node.cpp @@ -1,5 +1,4 @@ #include -#include #include #include @@ -7,12 +6,6 @@ namespace Poincare { static inline KDCoordinate max(KDCoordinate x, KDCoordinate y) { return x > y ? x : y; } -GridLayoutNode * GridLayoutNode::FailedAllocationStaticNode() { - static AllocationFailureLayoutNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - // LayoutNode void GridLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) { @@ -269,11 +262,7 @@ KDCoordinate GridLayoutNode::width() const { // Grid Layout Reference void GridLayoutRef::setDimensions(int rows, int columns) { - if (!isAllocationFailure()) { - /* If the node is an allocation failure, setNumberOfRows and - * setNumberOfColumns will do nothing. */ - assert(rows * columns == numberOfChildren()); - } + assert(rows * columns == numberOfChildren()); setNumberOfRows(rows); setNumberOfColumns(columns); } diff --git a/poincare/src/horizontal_layout_node.cpp b/poincare/src/horizontal_layout_node.cpp index 56c91220d..0194076f5 100644 --- a/poincare/src/horizontal_layout_node.cpp +++ b/poincare/src/horizontal_layout_node.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -8,12 +7,6 @@ namespace Poincare { static inline KDCoordinate maxCoordinate(KDCoordinate c1, KDCoordinate c2) { return c1 > c2 ? c1 : c2; } -HorizontalLayoutNode * HorizontalLayoutNode::FailedAllocationStaticNode() { - static AllocationFailureLayoutNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - // LayoutNode void HorizontalLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) { @@ -359,9 +352,6 @@ bool HorizontalLayoutNode::willReplaceChild(LayoutNode * oldChild, LayoutNode * // HorizontalLayoutRef void HorizontalLayoutRef::addOrMergeChildAtIndex(LayoutRef l, int index, bool removeEmptyChildren, LayoutCursor * cursor) { - if (isAllocationFailure()) { - return; - } if (l.isHorizontal()) { mergeChildrenAtIndex(HorizontalLayoutRef(static_cast(l.node())), index, removeEmptyChildren, cursor); } else { @@ -370,9 +360,6 @@ void HorizontalLayoutRef::addOrMergeChildAtIndex(LayoutRef l, int index, bool re } void HorizontalLayoutRef::mergeChildrenAtIndex(HorizontalLayoutRef h, int index, bool removeEmptyChildren, LayoutCursor * cursor) { - if (isAllocationFailure()) { - return; - } /* Remove any empty child that would be next to the inserted layout. * If the layout to insert starts with a vertical offset layout, any empty * layout child directly on the left of the inserted layout (if there is one) @@ -395,19 +382,12 @@ void HorizontalLayoutRef::mergeChildrenAtIndex(HorizontalLayoutRef h, int index, mergeChildrenAtIndexInPlace(h, newIndex); if (cursor != nullptr) { - if (!isAllocationFailure()) { - cursor->setLayoutReference(nextPointedLayout); - cursor->setPosition(nextPosition); - } else { - cursor->setLayoutReference(*this); - } + cursor->setLayoutReference(nextPointedLayout); + cursor->setPosition(nextPosition); } } void HorizontalLayoutRef::removeEmptyChildBeforeInsertionAtIndex(int * index, int * currentNumberOfChildren, bool shouldRemoveOnLeft, LayoutCursor * cursor) { - if (isAllocationFailure()) { - return; - } int childrenCount = currentNumberOfChildren == nullptr ? numberOfChildren() : *currentNumberOfChildren; assert(*index >= 0 && *index <= childrenCount); /* If empty, remove the child that would be on the right of the inserted diff --git a/poincare/src/hyperbolic_arc_cosine.cpp b/poincare/src/hyperbolic_arc_cosine.cpp index 182762002..bf04aeaed 100644 --- a/poincare/src/hyperbolic_arc_cosine.cpp +++ b/poincare/src/hyperbolic_arc_cosine.cpp @@ -4,12 +4,6 @@ namespace Poincare { -HyperbolicArcCosineNode * HyperbolicArcCosineNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - template Complex HyperbolicArcCosineNode::computeOnComplex(const std::complex c, Preferences::AngleUnit angleUnit) { std::complex result = std::acosh(c); diff --git a/poincare/src/hyperbolic_arc_sine.cpp b/poincare/src/hyperbolic_arc_sine.cpp index 78b6a8754..407cfccbd 100644 --- a/poincare/src/hyperbolic_arc_sine.cpp +++ b/poincare/src/hyperbolic_arc_sine.cpp @@ -4,12 +4,6 @@ namespace Poincare { -HyperbolicArcSineNode * HyperbolicArcSineNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - template Complex HyperbolicArcSineNode::computeOnComplex(const std::complex c, Preferences::AngleUnit angleUnit) { std::complex result = std::asinh(c); diff --git a/poincare/src/hyperbolic_arc_tangent.cpp b/poincare/src/hyperbolic_arc_tangent.cpp index d41f41301..c0f5f6e94 100644 --- a/poincare/src/hyperbolic_arc_tangent.cpp +++ b/poincare/src/hyperbolic_arc_tangent.cpp @@ -4,12 +4,6 @@ namespace Poincare { -HyperbolicArcTangentNode * HyperbolicArcTangentNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - template Complex HyperbolicArcTangentNode::computeOnComplex(const std::complex c, Preferences::AngleUnit angleUnit) { std::complex result = std::atanh(c); diff --git a/poincare/src/hyperbolic_cosine.cpp b/poincare/src/hyperbolic_cosine.cpp index 64b155341..e451f39ce 100644 --- a/poincare/src/hyperbolic_cosine.cpp +++ b/poincare/src/hyperbolic_cosine.cpp @@ -2,12 +2,6 @@ namespace Poincare { -HyperbolicCosineNode * HyperbolicCosineNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - template Complex HyperbolicCosineNode::computeOnComplex(const std::complex c, Preferences::AngleUnit angleUnit) { return Complex(Trigonometry::RoundToMeaningfulDigits(std::cosh(c))); diff --git a/poincare/src/hyperbolic_sine.cpp b/poincare/src/hyperbolic_sine.cpp index aa8dbda76..b05a14752 100644 --- a/poincare/src/hyperbolic_sine.cpp +++ b/poincare/src/hyperbolic_sine.cpp @@ -2,12 +2,6 @@ namespace Poincare { -HyperbolicSineNode * HyperbolicSineNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - template Complex HyperbolicSineNode::computeOnComplex(const std::complex c, Preferences::AngleUnit angleUnit) { return Complex(Trigonometry::RoundToMeaningfulDigits(std::sinh(c))); diff --git a/poincare/src/hyperbolic_tangent.cpp b/poincare/src/hyperbolic_tangent.cpp index dcb97f1a1..cbd86a182 100644 --- a/poincare/src/hyperbolic_tangent.cpp +++ b/poincare/src/hyperbolic_tangent.cpp @@ -2,12 +2,6 @@ namespace Poincare { -HyperbolicTangentNode * HyperbolicTangentNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - template Complex HyperbolicTangentNode::computeOnComplex(const std::complex c, Preferences::AngleUnit angleUnit) { return Complex(Trigonometry::RoundToMeaningfulDigits(std::tanh(c))); diff --git a/poincare/src/hyperbolic_trigonometric_function.cpp b/poincare/src/hyperbolic_trigonometric_function.cpp index 1117c47dc..1ae98438c 100644 --- a/poincare/src/hyperbolic_trigonometric_function.cpp +++ b/poincare/src/hyperbolic_trigonometric_function.cpp @@ -14,7 +14,7 @@ Expression HyperbolicTrigonometricFunctionNode::shallowReduce(Context & context, Expression HyperbolicTrigonometricFunction::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/imaginary_part.cpp b/poincare/src/imaginary_part.cpp index 4a5036798..7a372ab18 100644 --- a/poincare/src/imaginary_part.cpp +++ b/poincare/src/imaginary_part.cpp @@ -7,12 +7,6 @@ namespace Poincare { -ImaginaryPartNode * ImaginaryPartNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - LayoutReference ImaginaryPartNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return LayoutHelper::Prefix(ImaginaryPart(this), floatDisplayMode, numberOfSignificantDigits, name()); } @@ -33,7 +27,7 @@ Expression ImaginaryPartNode::shallowReduce(Context & context, Preferences::Angl Expression ImaginaryPart::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/infinity.cpp b/poincare/src/infinity.cpp index 6a39f4131..02169e527 100644 --- a/poincare/src/infinity.cpp +++ b/poincare/src/infinity.cpp @@ -1,5 +1,4 @@ #include -#include #include #include @@ -10,12 +9,6 @@ extern "C" { namespace Poincare { -InfinityNode * InfinityNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - Expression InfinityNode::setSign(Sign s, Context & context, Preferences::AngleUnit angleUnit) { return Infinity(this).setSign(s, context, angleUnit); } diff --git a/poincare/src/integral.cpp b/poincare/src/integral.cpp index 5368a8b25..7e71ba6c0 100644 --- a/poincare/src/integral.cpp +++ b/poincare/src/integral.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -8,12 +9,6 @@ namespace Poincare { -IntegralNode * IntegralNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - int IntegralNode::polynomialDegree(char symbolName) const { if (symbolName == 'x') { int da = childAtIndex(1)->polynomialDegree(symbolName); @@ -193,7 +188,7 @@ T IntegralNode::adaptiveQuadrature(T a, T b, T eps, int numberOfIterations, Cont Expression Integral::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/integral_layout_node.cpp b/poincare/src/integral_layout_node.cpp index 63cb3b308..d1ca72edd 100644 --- a/poincare/src/integral_layout_node.cpp +++ b/poincare/src/integral_layout_node.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -24,12 +23,6 @@ const uint8_t bottomSymbolPixel[IntegralLayoutNode::k_symbolHeight][IntegralLayo {0xFF, 0xFF, 0x00, 0x00}, }; -IntegralLayoutNode * IntegralLayoutNode::FailedAllocationStaticNode() { - static AllocationFailureLayoutNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - void IntegralLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) { if (cursor->position() == LayoutCursor::Position::Left && ((!upperBoundLayout()->isUninitialized() && cursor->layoutNode() == upperBoundLayout()) @@ -140,15 +133,10 @@ void IntegralLayoutNode::moveCursorDown(LayoutCursor * cursor, bool * shouldReco void IntegralLayoutNode::deleteBeforeCursor(LayoutCursor * cursor) { if (cursor->isEquivalentTo(LayoutCursor(integrandLayout(), LayoutCursor::Position::Left))) { // Case: Left of the integrand. Delete the layout, keep the integrand. - LayoutRef rootRef = LayoutRef(root()); LayoutRef thisRef = LayoutRef(this); LayoutRef integrand = LayoutRef(integrandLayout()); thisRef.replaceChildWithGhostInPlace(integrand); // WARNING: Do not use "this" afterwards - if (rootRef.isAllocationFailure()) { - cursor->setLayoutReference(rootRef); - return; - } cursor->setLayoutReference(thisRef.childAtIndex(0)); cursor->setPosition(LayoutCursor::Position::Left); thisRef.replaceWith(integrand, cursor); diff --git a/poincare/src/layout_cursor.cpp b/poincare/src/layout_cursor.cpp index 51977f631..e4cc5f26c 100644 --- a/poincare/src/layout_cursor.cpp +++ b/poincare/src/layout_cursor.cpp @@ -75,13 +75,8 @@ void LayoutCursor::addEmptyExponentialLayout() { HorizontalLayoutRef sibling = HorizontalLayoutRef( CharLayoutRef(Ion::Charset::Exponential), VerticalOffsetLayoutRef(emptyLayout, VerticalOffsetLayoutNode::Type::Superscript)); - LayoutRef rootRef = m_layoutRef.root(); m_layoutRef.addSibling(this, sibling, false); - if (!rootRef.isAllocationFailure()) { - m_layoutRef = emptyLayout; - } else { - m_layoutRef = rootRef; - } + m_layoutRef = emptyLayout; } void LayoutCursor::addEmptyMatrixLayout() { @@ -90,38 +85,23 @@ void LayoutCursor::addEmptyMatrixLayout() { EmptyLayoutRef(EmptyLayoutNode::Color::Grey), EmptyLayoutRef(EmptyLayoutNode::Color::Grey), EmptyLayoutRef(EmptyLayoutNode::Color::Grey)); - LayoutRef rootRef = m_layoutRef.root(); m_layoutRef.addSibling(this, matrixLayout, false); - if (!rootRef.isAllocationFailure()) { - m_layoutRef = matrixLayout.childAtIndex(0); - m_position = Position::Right; - } else { - m_layoutRef = rootRef; - } + m_layoutRef = matrixLayout.childAtIndex(0); + m_position = Position::Right; } void LayoutCursor::addEmptySquareRootLayout() { HorizontalLayoutRef child1 = HorizontalLayoutRef(EmptyLayoutRef()); NthRootLayoutRef newChild = NthRootLayoutRef(child1); - LayoutRef rootRef = m_layoutRef.root(); m_layoutRef.addSibling(this, newChild, false); - if (!rootRef.isAllocationFailure()) { - m_layoutRef = newChild.childAtIndex(0); - ((LayoutRef *)&newChild)->collapseSiblings(this); - } else { - m_layoutRef = rootRef; - } + m_layoutRef = newChild.childAtIndex(0); + ((LayoutRef *)&newChild)->collapseSiblings(this); } void LayoutCursor::addEmptyPowerLayout() { VerticalOffsetLayoutRef offsetLayout = VerticalOffsetLayoutRef(EmptyLayoutRef(), VerticalOffsetLayoutNode::Type::Superscript); - LayoutRef rootRef = m_layoutRef.root(); privateAddEmptyPowerLayout(offsetLayout); - if (!rootRef.isAllocationFailure()) { - m_layoutRef = offsetLayout.childAtIndex(0); - } else { - m_layoutRef = rootRef; - } + m_layoutRef = offsetLayout.childAtIndex(0); } void LayoutCursor::addEmptySquarePowerLayout() { @@ -138,13 +118,8 @@ void LayoutCursor::addEmptyTenPowerLayout() { VerticalOffsetLayoutRef( emptyLayout, VerticalOffsetLayoutNode::Type::Superscript)); - LayoutRef rootRef = m_layoutRef.root(); m_layoutRef.addSibling(this, sibling, false); - if (!rootRef.isAllocationFailure()) { - m_layoutRef = emptyLayout; - } else { - m_layoutRef = rootRef; - } + m_layoutRef = emptyLayout; } void LayoutCursor::addFractionLayoutAndCollapseSiblings() { @@ -213,10 +188,9 @@ void LayoutCursor::insertText(const char * text) { } void LayoutCursor::addLayoutAndMoveCursor(LayoutRef l) { - LayoutRef rootRef = m_layoutRef.root(); bool layoutWillBeMerged = l.isHorizontal(); m_layoutRef.addSibling(this, l, true); - if (!rootRef.isAllocationFailure() && !layoutWillBeMerged) { + if (!layoutWillBeMerged) { l.collapseSiblings(this); } } @@ -289,9 +263,6 @@ bool LayoutCursor::baseForNewPowerLayout() { } bool LayoutCursor::privateShowHideEmptyLayoutIfNeeded(bool show) { - if (m_layoutRef.isAllocationFailure()) { - return false; - } /* Find Empty layouts adjacent to the cursor: Check the pointed layout and the * equivalent cursor positions */ LayoutRef adjacentEmptyLayout; diff --git a/poincare/src/layout_node.cpp b/poincare/src/layout_node.cpp index 2778f2fb8..a4709c9c3 100644 --- a/poincare/src/layout_node.cpp +++ b/poincare/src/layout_node.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -83,8 +82,7 @@ void LayoutNode::moveCursorDownInDescendants(LayoutCursor * cursor, bool * shoul } LayoutCursor LayoutNode::equivalentCursor(LayoutCursor * cursor) { - /* Only HorizontalLayout or AllocationFailedLayout may have no parent, and - * they overload this method */ + // Only HorizontalLayout may have no parent, and it overloads this method assert(!parent()->isUninitialized()); return (cursor->layoutReference().node() == this) ? parent()->equivalentCursor(cursor) : LayoutCursor(); } @@ -190,17 +188,12 @@ void LayoutNode::moveCursorInDescendantsVertically(VerticalDirection direction, // If there is a valid result LayoutRef resultRef(childResult); - LayoutRef rootRef = LayoutRef(root()); if (!(*childResultPtr)->isUninitialized()) { *shouldRecomputeLayout = childResult->addGreySquaresToAllMatrixAncestors(); // WARNING: Do not use "this" afterwards } - if (rootRef.isAllocationFailure()) { - cursor->setLayoutReference(rootRef); - } else { - cursor->setLayoutReference(resultRef); - cursor->setPosition(resultPosition); - } + cursor->setLayoutReference(resultRef); + cursor->setPosition(resultPosition); } void LayoutNode::scoreCursorInDescendantsVertically ( diff --git a/poincare/src/layout_reference.cpp b/poincare/src/layout_reference.cpp index 39a0791e9..5a607e621 100644 --- a/poincare/src/layout_reference.cpp +++ b/poincare/src/layout_reference.cpp @@ -30,11 +30,7 @@ void LayoutReference::replaceChild(LayoutRef oldChild, LayoutRef newChild, Layou } replaceChildInPlace(oldChild, newChild); if (cursor != nullptr) { - if (isAllocationFailure()) { - cursor->setLayoutReference(*this); - } else { - cursor->setLayoutReference(newChild); - } + cursor->setLayoutReference(newChild); } node()->didReplaceChildAtIndex(childIndex, cursor, force); } @@ -44,11 +40,6 @@ void LayoutReference::replaceChildWithEmpty(LayoutRef oldChild, LayoutCursor * c } void LayoutReference::replaceWithJuxtapositionOf(LayoutRef leftChild, LayoutRef rightChild, LayoutCursor * cursor, bool putCursorInTheMiddle) { - LayoutReference rootRef = root(); - if (rootRef.isAllocationFailure()) { - cursor->setLayoutReference(rootRef); - return; - } LayoutReference p = parent(); assert(!p.isUninitialized()); if (!p.isHorizontal()) { @@ -57,10 +48,6 @@ void LayoutReference::replaceWithJuxtapositionOf(LayoutRef leftChild, LayoutRef HorizontalLayoutRef horizontalLayoutR; p.replaceChild(*this, horizontalLayoutR, cursor); horizontalLayoutR.addOrMergeChildAtIndex(leftChild, 0, false); - if (rootRef.isAllocationFailure()) { - cursor->setLayoutReference(rootRef); - return; - } if (putCursorInTheMiddle) { if (!horizontalLayoutR.isEmpty()) { cursor->setLayoutReference(horizontalLayoutR.childAtIndex(horizontalLayoutR.numberOfChildren()-1)); @@ -112,12 +99,8 @@ void LayoutReference::addChildAtIndex(LayoutRef l, int index, int currentNumberO addChildAtIndexInPlace(l, newIndex, newCurrentNumberOfChildren); if (cursor != nullptr) { - if (isAllocationFailure()) { - cursor->setLayoutReference(*this); - } else { - cursor->setLayoutReference(nextPointedLayout); - cursor->setPosition(nextPosition); - } + cursor->setLayoutReference(nextPointedLayout); + cursor->setPosition(nextPosition); } } @@ -151,9 +134,6 @@ void LayoutReference::addSibling(LayoutCursor * cursor, LayoutReference sibling, cursor->setPosition(cursor->position() == LayoutCursor::Position::Left ? LayoutCursor::Position::Right : LayoutCursor::Position::Left); } neighbour.addSibling(cursor, sibling, moveCursor); - if (rootLayout.isAllocationFailure() && moveCursor) { - cursor->setLayoutReference(rootLayout); - } return; } } @@ -253,9 +233,6 @@ void LayoutReference::collapseSiblings(LayoutCursor * cursor) { LayoutRef horRef = HorizontalLayoutRef(absorbingChild.clone()); replaceChild(absorbingChild, horRef, cursor, true); } - if (rootLayout.isAllocationFailure()) { - return; - } collapseOnDirection(HorizontalDirection::Right, rightCollapsingAbsorbingChildIndex()); } if (node()->shouldCollapseSiblingsOnLeft()) { @@ -263,9 +240,6 @@ void LayoutReference::collapseSiblings(LayoutCursor * cursor) { if (!absorbingChild.isHorizontal()) { replaceChild(absorbingChild, HorizontalLayoutRef(absorbingChild.clone()), cursor, true); } - if (rootLayout.isAllocationFailure()) { - return; - } collapseOnDirection(HorizontalDirection::Left, leftCollapsingAbsorbingChildIndex()); } node()->didCollapseSiblings(cursor); diff --git a/poincare/src/least_common_multiple.cpp b/poincare/src/least_common_multiple.cpp index adc7e5f4f..27d380807 100644 --- a/poincare/src/least_common_multiple.cpp +++ b/poincare/src/least_common_multiple.cpp @@ -8,12 +8,6 @@ namespace Poincare { -LeastCommonMultipleNode * LeastCommonMultipleNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - LayoutReference LeastCommonMultipleNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return LayoutHelper::Prefix(LeastCommonMultiple(this), floatDisplayMode, numberOfSignificantDigits, name()); } @@ -53,7 +47,7 @@ Evaluation LeastCommonMultipleNode::templatedApproximate(Context& context, Pr Expression LeastCommonMultiple::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/left_parenthesis_layout_node.cpp b/poincare/src/left_parenthesis_layout_node.cpp index e0ec40a6d..058f95d55 100644 --- a/poincare/src/left_parenthesis_layout_node.cpp +++ b/poincare/src/left_parenthesis_layout_node.cpp @@ -1,5 +1,4 @@ #include -#include #include #include @@ -48,12 +47,6 @@ void LeftParenthesisLayoutNode::RenderWithChildHeight(KDCoordinate childHeight, expressionColor); } -LeftParenthesisLayoutNode * LeftParenthesisLayoutNode::FailedAllocationStaticNode() { - static AllocationFailureLayoutNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - bool LeftParenthesisLayoutNode::isCollapsable(int * numberOfOpenParenthesis, bool goingLeft) const { if (*numberOfOpenParenthesis == 0 && goingLeft) { return false; diff --git a/poincare/src/left_square_bracket_layout_node.cpp b/poincare/src/left_square_bracket_layout_node.cpp index e3d1777c1..95839baa1 100644 --- a/poincare/src/left_square_bracket_layout_node.cpp +++ b/poincare/src/left_square_bracket_layout_node.cpp @@ -1,14 +1,7 @@ #include -#include namespace Poincare { -LeftSquareBracketLayoutNode * LeftSquareBracketLayoutNode::FailedAllocationStaticNode() { - static AllocationFailureLayoutNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - void LeftSquareBracketLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { ctx->fillRect(KDRect(p.x()+k_externWidthMargin, p.y(), k_lineThickness, childHeight()), expressionColor); ctx->fillRect(KDRect(p.x()+k_externWidthMargin, p.y(), k_bracketWidth, k_lineThickness), expressionColor); diff --git a/poincare/src/logarithm.cpp b/poincare/src/logarithm.cpp index 865be7952..10be0db97 100644 --- a/poincare/src/logarithm.cpp +++ b/poincare/src/logarithm.cpp @@ -17,13 +17,6 @@ namespace Poincare { -template -LogarithmNode * LogarithmNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode > failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - template<> LayoutReference LogarithmNode<1>::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, "log"); @@ -67,7 +60,7 @@ template Evaluation LogarithmNode<2>::templatedApproximate(Contex Expression Logarithm::shallowReduce(Context & context, Preferences::AngleUnit angleUnit){ { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } @@ -86,7 +79,7 @@ Expression Logarithm::shallowReduce(Context & context, Preferences::AngleUnit an return *this; } Expression f = simpleShallowReduce(context, angleUnit); - if (f.isUndefinedOrAllocationFailure()) { + if (f.isUndefined()) { return f; } @@ -257,8 +250,6 @@ Expression Logarithm::shallowBeautify(Context & context, Preferences::AngleUnit return *this; } -template LogarithmNode<1> * LogarithmNode<1>::FailedAllocationStaticNode(); -template LogarithmNode<2> * LogarithmNode<2>::FailedAllocationStaticNode(); template Evaluation LogarithmNode<1>::templatedApproximate(Poincare::Context&, Poincare::Preferences::AngleUnit) const; template Evaluation LogarithmNode<1>::templatedApproximate(Poincare::Context&, Poincare::Preferences::AngleUnit) const; template Evaluation LogarithmNode<2>::templatedApproximate(Poincare::Context&, Poincare::Preferences::AngleUnit) const; diff --git a/poincare/src/matrix.cpp b/poincare/src/matrix.cpp index 23b713995..5c4fca4ea 100644 --- a/poincare/src/matrix.cpp +++ b/poincare/src/matrix.cpp @@ -12,12 +12,6 @@ namespace Poincare { -MatrixNode * MatrixNode::FailedAllocationStaticNode() { - static AllocationFailureMatrixNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - void MatrixNode::didAddChildAtIndex(int newNumberOfChildren) { setNumberOfRows(1); setNumberOfColumns(newNumberOfChildren); @@ -100,10 +94,6 @@ void Matrix::setDimensions(int rows, int columns) { } void Matrix::addChildrenAsRowInPlace(TreeByReference t, int i) { - if (t.isAllocationFailure()) { - replaceWithAllocationFailureInPlace(numberOfChildren()); - return; - } int previousNumberOfColumns = numberOfColumns(); if (previousNumberOfColumns > 0) { assert(t.numberOfChildren() == numberOfColumns()); @@ -169,10 +159,7 @@ int Matrix::ArrayInverse(T * array, int numberOfRows, int numberOfColumns) { Matrix Matrix::rowCanonize(Context & context, Preferences::AngleUnit angleUnit, Multiplication determinant) { // The matrix has to be reduced to be able to spot 0 inside it Expression reduced = deepReduce(context, angleUnit); - /* The MatrixNode should change only in 2 cases: - * - Allocation failure - * - One of the child is Undefined - */ + // The MatrixNode should change only if one of the child is Undefined if (reduced.type() != ExpressionNode::Type::Matrix) { return Matrix(); } diff --git a/poincare/src/matrix_complex.cpp b/poincare/src/matrix_complex.cpp index 9f67cacdc..f31934ef0 100644 --- a/poincare/src/matrix_complex.cpp +++ b/poincare/src/matrix_complex.cpp @@ -9,13 +9,6 @@ namespace Poincare { -template -MatrixComplexNode * MatrixComplexNode::FailedAllocationStaticNode() { - static AllocationFailureMatrixComplexNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - template void MatrixComplexNode::didAddChildAtIndex(int newNumberOfChildren) { setNumberOfRows(1); diff --git a/poincare/src/matrix_dimension.cpp b/poincare/src/matrix_dimension.cpp index 17f697d19..464c900dd 100644 --- a/poincare/src/matrix_dimension.cpp +++ b/poincare/src/matrix_dimension.cpp @@ -7,12 +7,6 @@ namespace Poincare { -MatrixDimensionNode * MatrixDimensionNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - Expression MatrixDimensionNode::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { return MatrixDimension(this).shallowReduce(context, angleUnit); } @@ -42,7 +36,7 @@ Evaluation MatrixDimensionNode::templatedApproximate(Context& context, Prefer Expression MatrixDimension::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/matrix_inverse.cpp b/poincare/src/matrix_inverse.cpp index b9370fa0d..eae2fc4dc 100644 --- a/poincare/src/matrix_inverse.cpp +++ b/poincare/src/matrix_inverse.cpp @@ -10,12 +10,6 @@ namespace Poincare { -MatrixInverseNode * MatrixInverseNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - Expression MatrixInverseNode::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { return MatrixInverse(this).shallowReduce(context, angleUnit); } @@ -47,7 +41,7 @@ Evaluation MatrixInverseNode::templatedApproximate(Context& context, Preferen Expression MatrixInverse::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/matrix_layout_node.cpp b/poincare/src/matrix_layout_node.cpp index 896987be9..2239f612f 100644 --- a/poincare/src/matrix_layout_node.cpp +++ b/poincare/src/matrix_layout_node.cpp @@ -7,22 +7,13 @@ namespace Poincare { -MatrixLayoutNode * MatrixLayoutNode::FailedAllocationStaticNode() { - static AllocationFailureMatrixLayoutNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - // MatrixLayoutNode void MatrixLayoutNode::addGreySquares() { if (!hasGreySquares()) { LayoutRef thisRef(this); addEmptyRow(EmptyLayoutNode::Color::Grey); - // WARNING: the layout might have become an AllocationFailure - if (!thisRef.isAllocationFailure()) { - addEmptyColumn(EmptyLayoutNode::Color::Grey); - } + addEmptyColumn(EmptyLayoutNode::Color::Grey); } } @@ -55,14 +46,8 @@ void MatrixLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomp /* Case: Right. Add the grey squares to the matrix, then move to the bottom * right non empty nor grey child. */ assert(!hasGreySquares()); - LayoutRef rootRef(root()); addGreySquares(); - // WARNING: the layout might have become an AllocationFailure *shouldRecomputeLayout = true; - if (rootRef.isAllocationFailure()) { - cursor->setLayoutReference(rootRef); - return; - } LayoutNode * lastChild = childAtIndex((m_numberOfColumns-1)*(m_numberOfRows-1)); assert(!lastChild->isUninitialized()); cursor->setLayoutNode(lastChild); @@ -77,14 +62,8 @@ void MatrixLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecom { // Case: Left. Add grey squares to the matrix, then go to its first entry. assert(!hasGreySquares()); - LayoutRef rootRef(root()); addGreySquares(); - // WARNING: the layout might have become an AllocationFailure *shouldRecomputeLayout = true; - if (rootRef.isAllocationFailure()) { - cursor->setLayoutReference(rootRef); - return; - } assert(m_numberOfColumns*m_numberOfRows >= 1); assert(!childAtIndex(0)->isUninitialized()); cursor->setLayoutNode(childAtIndex(0)); @@ -172,7 +151,7 @@ void MatrixLayoutNode::moveCursorVertically(VerticalDirection direction, LayoutC } } GridLayoutNode::moveCursorVertically(direction, cursor, shouldRecomputeLayout, equivalentPositionVisited); - if (cursor->isDefined() && shouldRemoveGreySquares && !thisRef.isAllocationFailure()) { + if (cursor->isDefined() && shouldRemoveGreySquares) { assert(thisRef.hasGreySquares()); thisRef.removeGreySquares(); *shouldRecomputeLayout = true; @@ -183,7 +162,6 @@ void MatrixLayoutNode::moveCursorVertically(VerticalDirection direction, LayoutC void MatrixLayoutNode::newRowOrColumnAtIndex(int index) { assert(index >= 0 && index < m_numberOfColumns*m_numberOfRows); - LayoutRef rootRef = LayoutRef(root()); bool shouldAddNewRow = childIsBottomOfGrid(index); // We need to compute this boolean before modifying the layout int correspondingRow = rowAtChildIndex(index); if (childIsRightOfGrid(index)) { @@ -202,10 +180,6 @@ void MatrixLayoutNode::newRowOrColumnAtIndex(int index) { } // Add a column of grey EmptyLayouts on the right. addEmptyColumn(EmptyLayoutNode::Color::Grey); - // WARNING: the layout might have become an AllocationFailure - } - if (rootRef.isAllocationFailure()) { - return; } if (shouldAddNewRow) { // Color the grey EmptyLayouts of the row in yellow. @@ -222,7 +196,6 @@ void MatrixLayoutNode::newRowOrColumnAtIndex(int index) { } // Add a row of grey EmptyLayouts at the bottom. addEmptyRow(EmptyLayoutNode::Color::Grey); - // WARNING: the layout might have become an AllocationFailure } } diff --git a/poincare/src/matrix_trace.cpp b/poincare/src/matrix_trace.cpp index 02c285956..1a3135fd1 100644 --- a/poincare/src/matrix_trace.cpp +++ b/poincare/src/matrix_trace.cpp @@ -9,12 +9,6 @@ namespace Poincare { -MatrixTraceNode * MatrixTraceNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - Expression MatrixTraceNode::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { return MatrixTrace(this).shallowReduce(context, angleUnit); } @@ -37,7 +31,7 @@ Evaluation MatrixTraceNode::templatedApproximate(Context& context, Preference Expression MatrixTrace::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/matrix_transpose.cpp b/poincare/src/matrix_transpose.cpp index 79c4619d2..9eb9d029b 100644 --- a/poincare/src/matrix_transpose.cpp +++ b/poincare/src/matrix_transpose.cpp @@ -7,12 +7,6 @@ #include namespace Poincare { -MatrixTransposeNode * MatrixTransposeNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - Expression MatrixTransposeNode::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { return MatrixTranspose(this).shallowReduce(context, angleUnit); } @@ -41,7 +35,7 @@ Evaluation MatrixTransposeNode::templatedApproximate(Context& context, Prefer Expression MatrixTranspose::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/multiplication.cpp b/poincare/src/multiplication.cpp index b590207b1..58b4cc66a 100644 --- a/poincare/src/multiplication.cpp +++ b/poincare/src/multiplication.cpp @@ -17,12 +17,6 @@ namespace Poincare { -MultiplicationNode * MultiplicationNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - ExpressionNode::Sign MultiplicationNode::sign() const { if (numberOfChildren() == 0) { return Sign::Unknown; @@ -257,7 +251,7 @@ Expression Multiplication::denominator(Context & context, Preferences::AngleUnit Expression Multiplication::privateShallowReduce(Context & context, Preferences::AngleUnit angleUnit, bool shouldExpand, bool canBeInterrupted) { { Expression e = Expression::defaultShallowReduce(context, angleUnit);; - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/naperian_logarithm.cpp b/poincare/src/naperian_logarithm.cpp index 9ed4897fc..d46e208b9 100644 --- a/poincare/src/naperian_logarithm.cpp +++ b/poincare/src/naperian_logarithm.cpp @@ -5,12 +5,6 @@ namespace Poincare { -NaperianLogarithmNode * NaperianLogarithmNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - Expression NaperianLogarithmNode::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { return NaperianLogarithm(this).shallowReduce(context, angleUnit); } @@ -18,7 +12,7 @@ Expression NaperianLogarithmNode::shallowReduce(Context & context, Preferences:: Expression NaperianLogarithm::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/nth_root.cpp b/poincare/src/nth_root.cpp index a7f980088..283d4923e 100644 --- a/poincare/src/nth_root.cpp +++ b/poincare/src/nth_root.cpp @@ -8,12 +8,6 @@ namespace Poincare { -NthRootNode * NthRootNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - LayoutReference NthRootNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return NthRootLayoutRef( childAtIndex(0)->createLayout(floatDisplayMode, numberOfSignificantDigits), @@ -42,7 +36,7 @@ Evaluation NthRootNode::templatedApproximate(Context& context, Preferences::A Expression NthRoot::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/nth_root_layout_node.cpp b/poincare/src/nth_root_layout_node.cpp index 66b67a711..ef0a327cc 100644 --- a/poincare/src/nth_root_layout_node.cpp +++ b/poincare/src/nth_root_layout_node.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -20,12 +19,6 @@ const uint8_t radixPixel[NthRootLayoutNode::k_leftRadixHeight][NthRootLayoutNode {0xFF, 0xFF, 0xFF, 0xFF, 0x00}, }; -NthRootLayoutNode * NthRootLayoutNode::FailedAllocationStaticNode() { - static AllocationFailureLayoutNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - void NthRootLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) { if (!radicandLayout()->isUninitialized() && cursor->layoutNode() == radicandLayout() @@ -151,13 +144,8 @@ void NthRootLayoutNode::deleteBeforeCursor(LayoutCursor * cursor) { // Case: Left of the radicand. Delete the layout, keep the radicand. LayoutRef radicand = LayoutRef(radicandLayout()); LayoutRef thisRef = LayoutRef(this); - LayoutRef rootRef = LayoutRef(root()); thisRef.replaceChildWithGhostInPlace(radicand); // WARNING: Do not call "this" afterwards - if (rootRef.isAllocationFailure()) { - cursor->setLayoutReference(rootRef); - return; - } cursor->setLayoutReference(thisRef.childAtIndex(0)); thisRef.replaceWith(radicand, cursor); return; diff --git a/poincare/src/opposite.cpp b/poincare/src/opposite.cpp index 29605c173..35405fa39 100644 --- a/poincare/src/opposite.cpp +++ b/poincare/src/opposite.cpp @@ -13,12 +13,6 @@ extern "C" { namespace Poincare { -OppositeNode * OppositeNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - int OppositeNode::polynomialDegree(char symbolName) const { return childAtIndex(0)->polynomialDegree(symbolName); } @@ -71,7 +65,7 @@ Expression OppositeNode::shallowReduce(Context & context, Preferences::AngleUnit Expression Opposite::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { Expression result = Expression::defaultShallowReduce(context, angleUnit); - if (result.isUndefinedOrAllocationFailure()) { + if (result.isUndefined()) { return result; } Expression child = result.childAtIndex(0); diff --git a/poincare/src/parenthesis.cpp b/poincare/src/parenthesis.cpp index 226c70a30..5f5a3f364 100644 --- a/poincare/src/parenthesis.cpp +++ b/poincare/src/parenthesis.cpp @@ -1,15 +1,8 @@ #include -#include #include namespace Poincare { -ParenthesisNode * ParenthesisNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - int ParenthesisNode::polynomialDegree(char symbolName) const { return childAtIndex(0)->polynomialDegree(symbolName); } @@ -33,7 +26,7 @@ Evaluation ParenthesisNode::templatedApproximate(Context& context, Preference Expression Parenthesis::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } Expression c = childAtIndex(0); diff --git a/poincare/src/permute_coefficient.cpp b/poincare/src/permute_coefficient.cpp index aa5edd275..fcbdb2e6e 100644 --- a/poincare/src/permute_coefficient.cpp +++ b/poincare/src/permute_coefficient.cpp @@ -9,12 +9,6 @@ extern "C" { namespace Poincare { -PermuteCoefficientNode * PermuteCoefficientNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - LayoutReference PermuteCoefficientNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return LayoutHelper::Prefix(PermuteCoefficient(this), floatDisplayMode, numberOfSignificantDigits, name()); } @@ -48,7 +42,7 @@ Evaluation PermuteCoefficientNode::templatedApproximate(Context& context, Pre Expression PermuteCoefficient::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/power.cpp b/poincare/src/power.cpp index 7b362128f..8b4eedae9 100644 --- a/poincare/src/power.cpp +++ b/poincare/src/power.cpp @@ -22,13 +22,6 @@ namespace Poincare { -// Allocation Failure -PowerNode * PowerNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - // Properties ExpressionNode::Sign PowerNode::sign() const { if (Expression::shouldStopProcessing()) { @@ -238,7 +231,7 @@ Expression Power::shallowReduce(Context & context, Preferences::AngleUnit angleU { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/prediction_interval.cpp b/poincare/src/prediction_interval.cpp index f8c0b913d..e799db3a9 100644 --- a/poincare/src/prediction_interval.cpp +++ b/poincare/src/prediction_interval.cpp @@ -12,12 +12,6 @@ extern "C" { namespace Poincare { -PredictionIntervalNode * PredictionIntervalNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - LayoutReference PredictionIntervalNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return LayoutHelper::Prefix(PredictionInterval(this), floatDisplayMode, numberOfSignificantDigits, name()); } @@ -44,7 +38,7 @@ Evaluation PredictionIntervalNode::templatedApproximate(Context& context, Pre Expression PredictionInterval::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/product.cpp b/poincare/src/product.cpp index 4419b1a46..e9db0deba 100644 --- a/poincare/src/product.cpp +++ b/poincare/src/product.cpp @@ -9,12 +9,6 @@ extern "C" { namespace Poincare { -ProductNode * ProductNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - LayoutRef ProductNode::createSequenceLayout(LayoutRef argumentLayout, LayoutRef subscriptLayout, LayoutRef superscriptLayout) const { return ProductLayoutRef(argumentLayout, subscriptLayout, superscriptLayout); } diff --git a/poincare/src/product_layout_node.cpp b/poincare/src/product_layout_node.cpp index 2ff2e766d..f1e6a4060 100644 --- a/poincare/src/product_layout_node.cpp +++ b/poincare/src/product_layout_node.cpp @@ -1,5 +1,4 @@ #include -#include #include #include @@ -7,12 +6,6 @@ namespace Poincare { static inline KDCoordinate max(KDCoordinate x, KDCoordinate y) { return x > y ? x : y; } -ProductLayoutNode * ProductLayoutNode::FailedAllocationStaticNode() { - static AllocationFailureLayoutNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - int ProductLayoutNode::serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return SequenceLayoutNode::writeDerivedClassInBuffer("product", buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits); } diff --git a/poincare/src/randint.cpp b/poincare/src/randint.cpp index cbe511096..1036f94c6 100644 --- a/poincare/src/randint.cpp +++ b/poincare/src/randint.cpp @@ -1,6 +1,6 @@ #include +#include #include -#include #include extern "C" { @@ -10,12 +10,6 @@ extern "C" { namespace Poincare { -RandintNode * RandintNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - LayoutReference RandintNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return LayoutHelper::Prefix(Randint(this), floatDisplayMode, numberOfSignificantDigits, name()); } diff --git a/poincare/src/random.cpp b/poincare/src/random.cpp index 54f243e91..04894d814 100644 --- a/poincare/src/random.cpp +++ b/poincare/src/random.cpp @@ -1,20 +1,11 @@ #include -#include +#include #include - -extern "C" { #include -} #include namespace Poincare { -RandomNode * RandomNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - Expression RandomNode::setSign(Sign s, Context & context, Preferences::AngleUnit angleUnit) { return Random(this).setSign(s, context, angleUnit); } diff --git a/poincare/src/rational.cpp b/poincare/src/rational.cpp index 8dd8b0814..2502e0708 100644 --- a/poincare/src/rational.cpp +++ b/poincare/src/rational.cpp @@ -27,12 +27,6 @@ void RationalNode::setDigits(const native_uint_t * numeratorDigits, size_t numer } } -RationalNode * RationalNode::FailedAllocationStaticNode() { - static AllocationFailureRationalNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - Integer RationalNode::signedNumerator() const { return Integer((native_uint_t *)m_digits, m_numberOfDigitsNumerator, m_negative); } diff --git a/poincare/src/real_part.cpp b/poincare/src/real_part.cpp index f69c1c0d1..b7fd16caa 100644 --- a/poincare/src/real_part.cpp +++ b/poincare/src/real_part.cpp @@ -5,12 +5,6 @@ namespace Poincare { -RealPartNode * RealPartNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - LayoutReference RealPartNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return LayoutHelper::Prefix(RealPart(this), floatDisplayMode, numberOfSignificantDigits, name()); } @@ -27,7 +21,7 @@ Expression RealPartNode::shallowReduce(Context & context, Preferences::AngleUnit Expression RealPart::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/right_parenthesis_layout_node.cpp b/poincare/src/right_parenthesis_layout_node.cpp index 448b02ab8..70eb38bc4 100644 --- a/poincare/src/right_parenthesis_layout_node.cpp +++ b/poincare/src/right_parenthesis_layout_node.cpp @@ -1,5 +1,4 @@ #include -#include #include #include @@ -48,12 +47,6 @@ void RightParenthesisLayoutNode::RenderWithChildHeight(KDCoordinate childHeight, expressionColor); } -RightParenthesisLayoutNode * RightParenthesisLayoutNode::FailedAllocationStaticNode() { - static AllocationFailureLayoutNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - bool RightParenthesisLayoutNode::isCollapsable(int * numberOfOpenParenthesis, bool goingLeft) const { if (*numberOfOpenParenthesis == 0 && !goingLeft) { return false; diff --git a/poincare/src/right_square_bracket_layout_node.cpp b/poincare/src/right_square_bracket_layout_node.cpp index 92fc228b5..2e97b598d 100644 --- a/poincare/src/right_square_bracket_layout_node.cpp +++ b/poincare/src/right_square_bracket_layout_node.cpp @@ -1,14 +1,7 @@ #include -#include namespace Poincare { -RightSquareBracketLayoutNode * RightSquareBracketLayoutNode::FailedAllocationStaticNode() { - static AllocationFailureLayoutNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - void RightSquareBracketLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { ctx->fillRect(KDRect(p.x()+k_widthMargin, p.y(), k_lineThickness, childHeight()), expressionColor); ctx->fillRect(KDRect(p.x()+k_widthMargin-k_bracketWidth+1, p.y(), k_bracketWidth, k_lineThickness), expressionColor); diff --git a/poincare/src/round.cpp b/poincare/src/round.cpp index e40a542a0..986c4ef07 100644 --- a/poincare/src/round.cpp +++ b/poincare/src/round.cpp @@ -7,12 +7,6 @@ namespace Poincare { -RoundNode * RoundNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - LayoutReference RoundNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return LayoutHelper::Prefix(Round(this), floatDisplayMode, numberOfSignificantDigits, name()); } @@ -37,7 +31,7 @@ Evaluation RoundNode::templatedApproximate(Context& context, Preferences::Ang Expression Round::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/sequence_layout_node.cpp b/poincare/src/sequence_layout_node.cpp index e3b21da92..0c3dfbe8b 100644 --- a/poincare/src/sequence_layout_node.cpp +++ b/poincare/src/sequence_layout_node.cpp @@ -121,13 +121,8 @@ void SequenceLayoutNode::deleteBeforeCursor(LayoutCursor * cursor) { // Case: Left of the argument. Delete the layout, keep the argument. LayoutRef argument = LayoutRef(argumentLayout()); LayoutRef thisRef = LayoutRef(this); - LayoutRef rootRef = LayoutRef(root()); thisRef.replaceChildWithGhostInPlace(argument); // WARNING: Do not call "this" afterwards - if (rootRef.isAllocationFailure()) { - cursor->setLayoutReference(rootRef); - return; - } cursor->setLayoutReference(thisRef.childAtIndex(0)); thisRef.replaceWith(argument, cursor); return; diff --git a/poincare/src/sine.cpp b/poincare/src/sine.cpp index b995d12af..0195510e5 100644 --- a/poincare/src/sine.cpp +++ b/poincare/src/sine.cpp @@ -6,12 +6,6 @@ namespace Poincare { -SineNode * SineNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - float SineNode::characteristicXRange(Context & context, Preferences::AngleUnit angleUnit) const { return Trigonometry::characteristicXRange(Sine(this), context, angleUnit); } @@ -34,7 +28,7 @@ Expression SineNode::shallowReduce(Context & context, Preferences::AngleUnit ang Expression Sine::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/square_root.cpp b/poincare/src/square_root.cpp index d50b4cca8..9f5243cfe 100644 --- a/poincare/src/square_root.cpp +++ b/poincare/src/square_root.cpp @@ -8,12 +8,6 @@ namespace Poincare { -SquareRootNode * SquareRootNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - LayoutReference SquareRootNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return NthRootLayoutRef(childAtIndex(0)->createLayout(floatDisplayMode, numberOfSignificantDigits)); } @@ -43,7 +37,7 @@ Expression SquareRootNode::shallowReduce(Context & context, Preferences::AngleUn Expression SquareRoot::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/store.cpp b/poincare/src/store.cpp index 3bbed295a..f7644ffa0 100644 --- a/poincare/src/store.cpp +++ b/poincare/src/store.cpp @@ -8,19 +8,12 @@ extern "C" { #include #include #include -#include #include #include namespace Poincare { -StoreNode * StoreNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - Expression StoreNode::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { return Store(this).shallowReduce(context, angleUnit); } diff --git a/poincare/src/subtraction.cpp b/poincare/src/subtraction.cpp index 45be3f4b6..2a1d90d7b 100644 --- a/poincare/src/subtraction.cpp +++ b/poincare/src/subtraction.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -9,12 +8,6 @@ namespace Poincare { -SubtractionNode * SubtractionNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - int SubtractionNode::polynomialDegree(char symbolName) const { int degree = 0; for (int i = 0; i < numberOfChildren(); i++) { @@ -58,7 +51,7 @@ Expression SubtractionNode::shallowReduce(Context & context, Preferences::AngleU Expression Subtraction::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } Expression m = Multiplication(Rational(-1), childAtIndex(1)); diff --git a/poincare/src/sum.cpp b/poincare/src/sum.cpp index 63f13017b..fe14ed984 100644 --- a/poincare/src/sum.cpp +++ b/poincare/src/sum.cpp @@ -10,12 +10,6 @@ extern "C" { namespace Poincare { -SumNode * SumNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - LayoutRef SumNode::createSequenceLayout(LayoutRef argumentLayout, LayoutRef subscriptLayout, LayoutRef superscriptLayout) const { return SumLayoutRef(argumentLayout, subscriptLayout, superscriptLayout); diff --git a/poincare/src/sum_layout_node.cpp b/poincare/src/sum_layout_node.cpp index 17149032d..b9186029a 100644 --- a/poincare/src/sum_layout_node.cpp +++ b/poincare/src/sum_layout_node.cpp @@ -1,5 +1,4 @@ #include -#include #include #include @@ -26,12 +25,6 @@ const uint8_t symbolPixel[SumLayoutNode::k_symbolHeight][SumLayoutNode::k_symbol }; -SumLayoutNode * SumLayoutNode::FailedAllocationStaticNode() { - static AllocationFailureLayoutNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - int SumLayoutNode::serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return SequenceLayoutNode::writeDerivedClassInBuffer("sum", buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits); } diff --git a/poincare/src/symbol.cpp b/poincare/src/symbol.cpp index 721c69509..527e457d7 100644 --- a/poincare/src/symbol.cpp +++ b/poincare/src/symbol.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -13,12 +12,6 @@ namespace Poincare { -SymbolNode * SymbolNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - ExpressionNode::Sign SymbolNode::sign() const { /* TODO: Maybe, we will want to know that from a context given in parameter: if (context.expressionForSymbol(this) != nullptr) { diff --git a/poincare/src/tangent.cpp b/poincare/src/tangent.cpp index a587dde73..868c89766 100644 --- a/poincare/src/tangent.cpp +++ b/poincare/src/tangent.cpp @@ -9,12 +9,6 @@ namespace Poincare { -TangentNode * TangentNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - float TangentNode::characteristicXRange(Context & context, Preferences::AngleUnit angleUnit) const { return Trigonometry::characteristicXRange(Tangent(this), context, angleUnit); } @@ -37,7 +31,7 @@ Expression TangentNode::shallowReduce(Context & context, Preferences::AngleUnit Expression Tangent::shallowReduce(Context & context, Preferences::AngleUnit angleUnit) { { Expression e = Expression::defaultShallowReduce(context, angleUnit); - if (e.isUndefinedOrAllocationFailure()) { + if (e.isUndefined()) { return e; } } diff --git a/poincare/src/tree_by_reference.cpp b/poincare/src/tree_by_reference.cpp index 723256986..057997d01 100644 --- a/poincare/src/tree_by_reference.cpp +++ b/poincare/src/tree_by_reference.cpp @@ -18,12 +18,7 @@ TreeByReference TreeByReference::clone() const { /* TODO Remove ? if (isUninitialized()) { return TreeByReference(); }*/ - TreeNode * myNode = node(); - if (myNode->isAllocationFailure()) { - int allocationFailureNodeId = myNode->allocationFailureNodeIdentifier(); - return TreeByReference(TreePool::sharedPool()->node(allocationFailureNodeId)); - } - TreeNode * nodeCopy = TreePool::sharedPool()->deepCopy(myNode); + TreeNode * nodeCopy = TreePool::sharedPool()->deepCopy(node()); nodeCopy->deleteParentIdentifier(); return TreeByReference(nodeCopy); } @@ -32,9 +27,6 @@ TreeByReference TreeByReference::clone() const { void TreeByReference::replaceWithInPlace(TreeByReference t) { assert(!isUninitialized()); - if (isAllocationFailure()) { - return; - } TreeByReference p = parent(); if (!p.isUninitialized()) { p.replaceChildInPlace(*this, t); @@ -50,21 +42,10 @@ void TreeByReference::replaceChildInPlace(TreeByReference oldChild, TreeByRefere } assert(!isUninitialized()); - if (isAllocationFailure()) { - return; - } - if (newChild.isAllocationFailure()) { - replaceWithAllocationFailureInPlace(numberOfChildren()); - return; - } // If the new node is static, copy it in the pool and add the copy if (newChild.isStatic()) { TreeByReference newT = TreeByReference(TreePool::sharedPool()->deepCopy(newChild.node())); - if (newT.isAllocationFailure()) { - replaceWithAllocationFailureInPlace(numberOfChildren()); - return; - } replaceChildInPlace(oldChild, newT); return; } @@ -75,9 +56,6 @@ void TreeByReference::replaceChildInPlace(TreeByReference oldChild, TreeByRefere // Move the new child assert(newChild.isGhost() || newChild.parent().isUninitialized()); TreePool::sharedPool()->move(oldChild.node(), newChild.node(), newChild.numberOfChildren()); - /* We could have moved the new node to oldChild.node()->nextSibling(), but - * nextSibling is not computed correctly if we inserted an - * AllocationFailureNode next to newChild. */ newChild.node()->retain(); newChild.setParentIdentifier(identifier()); @@ -88,63 +66,11 @@ void TreeByReference::replaceChildInPlace(TreeByReference oldChild, TreeByRefere } void TreeByReference::replaceChildAtIndexInPlace(int oldChildIndex, TreeByReference newChild) { - if (oldChildIndex < 0 || oldChildIndex >= numberOfChildren()) { - /* The only case where the index might be out of range is when a tree has - * become an allocation failure, in which case we need to escape the invalid - * child removal. */ - assert(isAllocationFailure()); - return; - } + assert(oldChildIndex >= 0 && oldChildIndex < numberOfChildren()); TreeByReference oldChild = childAtIndex(oldChildIndex); replaceChildInPlace(oldChild, newChild); } -void TreeByReference::replaceWithAllocationFailureInPlace(int currentNumberOfChildren) { - if (isAllocationFailure()) { - return; - } - assert(!isUninitialized()); - TreeByReference p = parent(); - bool hasParent = !p.isUninitialized(); - int indexInParentNode = hasParent ? p.indexOfChild(*this) : -1; - int currentRetainCount = nodeRetainCount(); - TreeNode * staticAllocFailNode = node()->failedAllocationStaticNode(); - - // Release all children and delete the node in the pool - deleteParentIdentifierInChildren(); - TreePool::sharedPool()->removeChildrenAndDestroy(node(), currentNumberOfChildren); - /* WARNING: If we called "p.decrementNumberOfChildren()" here, the number of - * children of the parent layout would be: - * -> numberOfChildren() for "dynamic trees" that have a m_numberOfChildren - * variable (such as HorizontalLayout) - * -> numberOfChildren() - 1 for "static trees" that have a fixed number of - * children (such as IntegralLayout) - * - * By not decrementing the parent's number of children here, we now that it - * has (numberOfChildren() - 1) children. */ - - /* Create an allocation failure node with the previous node id. We know - * there is room in the pool as we deleted the previous node and an - * AllocationFailure nodes size is smaller or equal to any other node size.*/ - //TODO static assert that the size is smaller - TreeNode * newAllocationFailureNode = TreePool::sharedPool()->deepCopy(staticAllocFailNode); - newAllocationFailureNode->rename(m_identifier, true); - newAllocationFailureNode->retain(); - if (hasParent) { - assert(indexInParentNode >= 0); - /* Set the refCount to previousRefCount-1 because the previous parent is - * no longer retaining the node. When we add this node to the parent, it - * will retain it and increment the retain count. */ - newAllocationFailureNode->setReferenceCounter(currentRetainCount - 1); - p.addChildAtIndexInPlace(TreeByReference(newAllocationFailureNode), indexInParentNode, p.numberOfChildren() - 1); - p.decrementNumberOfChildren(); - /* We decrement here the parent's number of children, as we did not do it - * before, see WARNING. */ - } else { - newAllocationFailureNode->setReferenceCounter(currentRetainCount); - } -} - void TreeByReference::replaceChildWithGhostInPlace(TreeByReference t) { GhostReference ghost; return replaceChildInPlace(t, ghost); @@ -203,24 +129,11 @@ void TreeByReference::log() const { void TreeByReference::addChildAtIndexInPlace(TreeByReference t, int index, int currentNumberOfChildren) { assert(!isUninitialized()); assert(!t.isUninitialized()); - - if (isAllocationFailure()) { - return; - } - if (t.isAllocationFailure()) { - replaceWithAllocationFailureInPlace(currentNumberOfChildren); - return; - } - assert(index >= 0 && index <= currentNumberOfChildren); // If the new node is static, copy it in the pool and add the copy if (t.isStatic()) { TreeByReference newT = TreeByReference(TreePool::sharedPool()->deepCopy(t.node())); - if (newT.isAllocationFailure()) { - replaceWithAllocationFailureInPlace(currentNumberOfChildren); - return; - } addChildAtIndexInPlace(newT, index, currentNumberOfChildren); return; } @@ -246,13 +159,7 @@ void TreeByReference::addChildAtIndexInPlace(TreeByReference t, int index, int c void TreeByReference::removeChildAtIndexInPlace(int i) { assert(!isUninitialized()); - if (i < 0 || i >= numberOfChildren()) { - /* The only case where the index might be out of range is when a tree has - * become an allocation failure, in which case we need to escape the invalid - * child removal. */ - assert(isAllocationFailure()); - return; - } + assert(i >= 0 && i < numberOfChildren()); TreeByReference t = childAtIndex(i); removeChildInPlace(t, t.numberOfChildren()); } diff --git a/poincare/src/undefined.cpp b/poincare/src/undefined.cpp index 540f4c5dc..022990b78 100644 --- a/poincare/src/undefined.cpp +++ b/poincare/src/undefined.cpp @@ -9,12 +9,6 @@ extern "C" { namespace Poincare { -UndefinedNode * UndefinedNode::FailedAllocationStaticNode() { - static AllocationFailureExpressionNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - int UndefinedNode::polynomialDegree(char symbolName) const { return -1; } diff --git a/poincare/src/vertical_offset_layout_node.cpp b/poincare/src/vertical_offset_layout_node.cpp index 55e3fc60e..e1fb19abd 100644 --- a/poincare/src/vertical_offset_layout_node.cpp +++ b/poincare/src/vertical_offset_layout_node.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -10,12 +9,6 @@ namespace Poincare { -VerticalOffsetLayoutNode * VerticalOffsetLayoutNode::FailedAllocationStaticNode() { - static AllocationFailureLayoutNode failure; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failure); - return &failure; -} - void VerticalOffsetLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) { if (!indiceLayout()->isUninitialized() && cursor->layoutNode() == indiceLayout() @@ -274,12 +267,6 @@ bool VerticalOffsetLayoutNode::willAddSibling(LayoutCursor * cursor, LayoutNode if (!rightParenthesis.parent().isUninitialized()) { cursor->setLayoutReference(rightParenthesis); } - if (rootLayout.isAllocationFailure()) { - if (moveCursor) { - cursor->setLayoutReference(rootLayout); - } - return false; - } } } return true; diff --git a/poincare/test/tree/blob_node.cpp b/poincare/test/tree/blob_node.cpp index c0ec2a10b..d4abeaddb 100644 --- a/poincare/test/tree/blob_node.cpp +++ b/poincare/test/tree/blob_node.cpp @@ -6,12 +6,6 @@ TreeNode * BlobNode::uninitializedStaticNode() const { return UninitializedBlobNode::UninitializedBlobStaticNode(); } -BlobNode * BlobNode::FailedAllocationStaticNode() { - static AllocationFailureBlobNode failureNode; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failureNode); - return &failureNode; -} - UninitializedBlobNode * UninitializedBlobNode::UninitializedBlobStaticNode() { static UninitializedBlobNode exception; TreePool::sharedPool()->registerStaticNodeIfRequired(&exception); diff --git a/poincare/test/tree/blob_node.h b/poincare/test/tree/blob_node.h index 07ad6e664..982d03645 100644 --- a/poincare/test/tree/blob_node.h +++ b/poincare/test/tree/blob_node.h @@ -8,12 +8,7 @@ namespace Poincare { class BlobNode : public TreeNode { public: - static BlobNode * FailedAllocationStaticNode(); - virtual BlobNode * failedAllocationStaticNode() override { - return BlobNode::FailedAllocationStaticNode(); - } TreeNode * uninitializedStaticNode() const override; - virtual size_t size() const override { return sizeof(BlobNode); } int data() { return m_data; } void setData(int data) { m_data = data; } @@ -33,7 +28,6 @@ public: size_t size() const override { return sizeof(UninitializedBlobNode); } bool isUninitialized() const override { return true; } - BlobNode * failedAllocationStaticNode() override { assert(false); return nullptr; } //TODO ? int numberOfChildren() const override { return 0; } #if POINCARE_TREE_LOG virtual void logNodeName(std::ostream & stream) const override { @@ -42,17 +36,6 @@ public: #endif }; -class AllocationFailureBlobNode : public BlobNode { - size_t size() const override { return sizeof(AllocationFailureBlobNode); } - bool isAllocationFailure() const override { return true; } -#if POINCARE_TREE_LOG - virtual void logNodeName(std::ostream & stream) const override { - stream << "AllocationFailureBlob"; - } -#endif -}; - - class BlobByReference : public TreeByReference { public: BlobByReference(int data = 0) : TreeByReference(TreePool::sharedPool()->createTreeNode()) { diff --git a/poincare/test/tree/pair_node.cpp b/poincare/test/tree/pair_node.cpp index 52497c623..e4d00080d 100644 --- a/poincare/test/tree/pair_node.cpp +++ b/poincare/test/tree/pair_node.cpp @@ -6,12 +6,6 @@ TreeNode * PairNode::uninitializedStaticNode() const { return UninitializedPairNode::UninitializedPairStaticNode(); } -PairNode * PairNode::FailedAllocationStaticNode() { - static AllocationFailurePairNode failureNode; - TreePool::sharedPool()->registerStaticNodeIfRequired(&failureNode); - return &failureNode; -} - UninitializedPairNode * UninitializedPairNode::UninitializedPairStaticNode() { static UninitializedPairNode exception; TreePool::sharedPool()->registerStaticNodeIfRequired(&exception); diff --git a/poincare/test/tree/pair_node.h b/poincare/test/tree/pair_node.h index 105d0fa66..a8ee4565d 100644 --- a/poincare/test/tree/pair_node.h +++ b/poincare/test/tree/pair_node.h @@ -8,12 +8,7 @@ namespace Poincare { class PairNode : public TreeNode { public: - static PairNode * FailedAllocationStaticNode(); - virtual PairNode * failedAllocationStaticNode() override { - return PairNode::FailedAllocationStaticNode(); - } TreeNode * uninitializedStaticNode() const override; - virtual size_t size() const override { return sizeof(PairNode); } virtual int numberOfChildren() const override { return 2; } #if POINCARE_TREE_LOG @@ -29,7 +24,6 @@ public: size_t size() const override { return sizeof(UninitializedPairNode); } bool isUninitialized() const override { return true; } - PairNode * failedAllocationStaticNode() override { assert(false); return nullptr; } //TODO ? int numberOfChildren() const override { return 0; } #if POINCARE_TREE_LOG virtual void logNodeName(std::ostream & stream) const override { @@ -38,17 +32,6 @@ public: #endif }; -class AllocationFailurePairNode : public PairNode { - size_t size() const override { return sizeof(AllocationFailurePairNode); } - bool isAllocationFailure() const override { return true; } - int numberOfChildren() const override { return 0; } -#if POINCARE_TREE_LOG - virtual void logNodeName(std::ostream & stream) const override { - stream << "AllocationFailurePair"; - } -#endif -}; - class PairByReference : public TreeByReference { public: PairByReference(TreeByReference t1, TreeByReference t2) : TreeByReference(TreePool::sharedPool()->createTreeNode()) { diff --git a/poincare/test/tree/tree_by_reference.cpp b/poincare/test/tree/tree_by_reference.cpp index a29803b9e..a9b12f8c2 100644 --- a/poincare/test/tree/tree_by_reference.cpp +++ b/poincare/test/tree/tree_by_reference.cpp @@ -35,23 +35,14 @@ QUIZ_CASE(tree_by_reference_can_be_copied) { static TreeByReference blob_with_data_3() { return BlobByReference(3); } + QUIZ_CASE(tree_by_reference_can_be_returned) { int initialPoolSize = pool_size(); TreeByReference b = blob_with_data_3(); assert_pool_size(initialPoolSize+1); } -QUIZ_CASE(tree_by_reference_allocation_failures) { - int initialPoolSize = pool_size(); - BlobByReference b(1); - assert_pool_size(initialPoolSize+1); - { - BlobByReference array[10000]; - assert(pool_size() > initialPoolSize+1); - assert(pool_size() < 10000); - } - assert_pool_size(initialPoolSize+1); -} +//TODO QUIZ_CASE(tree_by_reference_allocation_failures) { QUIZ_CASE(tree_by_reference_does_not_copy) { int initialPoolSize = pool_size();