diff --git a/poincare/Makefile b/poincare/Makefile index 1aebe503e..8aadb48bb 100644 --- a/poincare/Makefile +++ b/poincare/Makefile @@ -16,7 +16,12 @@ objs += $(addprefix poincare/src/,\ fraction_layout_node.o\ grid_layout_node.o\ horizontal_layout_node.o\ + integral_layout_node.o\ + left_parenthesis_layout_node.o\ + left_square_bracket_layout_node.o\ matrix_layout_node.o\ + right_parenthesis_layout_node.o\ + right_square_bracket_layout_node.o\ ) objs += $(addprefix poincare/src/,\ diff --git a/poincare/include/poincare/integral_layout_node.h b/poincare/include/poincare/integral_layout_node.h index 2d236dcd0..2bc7039a1 100644 --- a/poincare/include/poincare/integral_layout_node.h +++ b/poincare/include/poincare/integral_layout_node.h @@ -29,6 +29,8 @@ 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 TREE_LOG diff --git a/poincare/include/poincare/left_square_bracket_layout_node.h b/poincare/include/poincare/left_square_bracket_layout_node.h index 528dc1a85..ee3e17342 100644 --- a/poincare/include/poincare/left_square_bracket_layout_node.h +++ b/poincare/include/poincare/left_square_bracket_layout_node.h @@ -3,6 +3,7 @@ #include #include +#include namespace Poincare { @@ -15,7 +16,8 @@ public: bool isLeftBracket() const override { return true; } // TreeNode - size_t size() const override { return sizeof(LeftSquareBracketLayoutNode); } + static LeftSquareBracketLayoutNode * FailedAllocationStaticNode(); + LeftSquareBracketLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); } size_t size() const override { return sizeof(LeftSquareBracketLayoutNode); } #if TREE_LOG const char * description() const override { return "LeftSquareBracketLayout"; } #endif diff --git a/poincare/include/poincare/right_parenthesis_layout_node.h b/poincare/include/poincare/right_parenthesis_layout_node.h index 00ea0aa2a..ededac7df 100644 --- a/poincare/include/poincare/right_parenthesis_layout_node.h +++ b/poincare/include/poincare/right_parenthesis_layout_node.h @@ -3,6 +3,7 @@ #include #include +#include namespace Poincare { diff --git a/poincare/include/poincare/right_square_bracket_layout_node.h b/poincare/include/poincare/right_square_bracket_layout_node.h index 0dd804650..97abbae01 100644 --- a/poincare/include/poincare/right_square_bracket_layout_node.h +++ b/poincare/include/poincare/right_square_bracket_layout_node.h @@ -3,6 +3,7 @@ #include #include +#include namespace Poincare { @@ -15,6 +16,8 @@ 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 TREE_LOG const char * description() const override { return "RightSquareBracketLayout"; } diff --git a/poincare/src/integral_layout_node.cpp b/poincare/src/integral_layout_node.cpp index 1e4f2e8ef..e886e2b52 100644 --- a/poincare/src/integral_layout_node.cpp +++ b/poincare/src/integral_layout_node.cpp @@ -1,6 +1,8 @@ #include +#include #include #include +#include #include #include @@ -22,6 +24,12 @@ 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() && cursor->layoutNode() == upperBoundLayout()) diff --git a/poincare/src/left_parenthesis_layout_node.cpp b/poincare/src/left_parenthesis_layout_node.cpp index 4f6754ad9..e0ec40a6d 100644 --- a/poincare/src/left_parenthesis_layout_node.cpp +++ b/poincare/src/left_parenthesis_layout_node.cpp @@ -1,4 +1,5 @@ #include +#include #include #include diff --git a/poincare/src/left_square_bracket_layout_node.cpp b/poincare/src/left_square_bracket_layout_node.cpp index 95839baa1..e3d1777c1 100644 --- a/poincare/src/left_square_bracket_layout_node.cpp +++ b/poincare/src/left_square_bracket_layout_node.cpp @@ -1,7 +1,14 @@ #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/right_parenthesis_layout_node.cpp b/poincare/src/right_parenthesis_layout_node.cpp index 9d291ab11..448b02ab8 100644 --- a/poincare/src/right_parenthesis_layout_node.cpp +++ b/poincare/src/right_parenthesis_layout_node.cpp @@ -1,4 +1,5 @@ #include +#include #include #include diff --git a/poincare/src/right_square_bracket_layout_node.cpp b/poincare/src/right_square_bracket_layout_node.cpp index 2e97b598d..92fc228b5 100644 --- a/poincare/src/right_square_bracket_layout_node.cpp +++ b/poincare/src/right_square_bracket_layout_node.cpp @@ -1,7 +1,14 @@ #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);