diff --git a/poincare/include/poincare/absolute_value_layout_node.h b/poincare/include/poincare/absolute_value_layout_node.h index 92220b0b3..c78037a96 100644 --- a/poincare/include/poincare/absolute_value_layout_node.h +++ b/poincare/include/poincare/absolute_value_layout_node.h @@ -28,7 +28,7 @@ class AbsoluteValueLayoutRef : public LayoutReference { public: AbsoluteValueLayoutRef(TreeNode * n) : LayoutReference(n) {} AbsoluteValueLayoutRef(LayoutRef l) : AbsoluteValueLayoutRef() { - addChildAtIndex(l, 0, 0); + addChildTreeAtIndex(l, 0, 0); } private: AbsoluteValueLayoutRef() : LayoutReference() { diff --git a/poincare/include/poincare/binomial_coefficient_layout_node.h b/poincare/include/poincare/binomial_coefficient_layout_node.h index 100b9dc34..82cd38960 100644 --- a/poincare/include/poincare/binomial_coefficient_layout_node.h +++ b/poincare/include/poincare/binomial_coefficient_layout_node.h @@ -45,8 +45,8 @@ public: BinomialCoefficientLayoutRef(LayoutRef n, LayoutRef k) : BinomialCoefficientLayoutRef() { - addChildAtIndex(n, 0, 0); - addChildAtIndex(k, 1, 1); + addChildTreeAtIndex(n, 0, 0); + addChildTreeAtIndex(k, 1, 1); } BinomialCoefficientLayoutRef(TreeNode * n) : LayoutReference(n) {} private: diff --git a/poincare/include/poincare/ceiling_layout_node.h b/poincare/include/poincare/ceiling_layout_node.h index 2b5be00be..6b8671c5c 100644 --- a/poincare/include/poincare/ceiling_layout_node.h +++ b/poincare/include/poincare/ceiling_layout_node.h @@ -26,7 +26,7 @@ class CeilingLayoutRef : public LayoutReference { public: CeilingLayoutRef(TreeNode * n) : LayoutReference(n) {} CeilingLayoutRef(LayoutRef l) : CeilingLayoutRef() { - addChildAtIndex(l, 0, 0); + addChildTreeAtIndex(l, 0, 0); } private: CeilingLayoutRef() : LayoutReference() { diff --git a/poincare/include/poincare/condensed_sum_layout_node.h b/poincare/include/poincare/condensed_sum_layout_node.h index c2dc8135c..349771bf2 100644 --- a/poincare/include/poincare/condensed_sum_layout_node.h +++ b/poincare/include/poincare/condensed_sum_layout_node.h @@ -51,9 +51,9 @@ public: CondensedSumLayoutRef(LayoutRef base, LayoutRef subscript, LayoutRef superscript) : CondensedSumLayoutRef() { - addChildAtIndex(base, 0, 0); - addChildAtIndex(subscript, 1, 1); - addChildAtIndex(superscript, 2, 2); + addChildTreeAtIndex(base, 0, 0); + addChildTreeAtIndex(subscript, 1, 1); + addChildTreeAtIndex(superscript, 2, 2); } CondensedSumLayoutRef(TreeNode * n) : LayoutReference(n) {} diff --git a/poincare/include/poincare/conjugate_layout_node.h b/poincare/include/poincare/conjugate_layout_node.h index f987196f0..fea4385f5 100644 --- a/poincare/include/poincare/conjugate_layout_node.h +++ b/poincare/include/poincare/conjugate_layout_node.h @@ -42,7 +42,7 @@ private: class ConjugateLayoutRef : public LayoutReference { public: ConjugateLayoutRef(LayoutRef l) : ConjugateLayoutRef() { - addChildAtIndex(l, 0, 0); + addChildTreeAtIndex(l, 0, 0); } ConjugateLayoutRef(TreeNode * n) : LayoutReference(n) {} private: diff --git a/poincare/include/poincare/floor_layout_node.h b/poincare/include/poincare/floor_layout_node.h index 1f4fc7706..1aba2831e 100644 --- a/poincare/include/poincare/floor_layout_node.h +++ b/poincare/include/poincare/floor_layout_node.h @@ -27,7 +27,7 @@ class FloorLayoutRef : public LayoutReference { public: FloorLayoutRef(TreeNode * n) : LayoutReference(n) {} FloorLayoutRef(LayoutRef l) : FloorLayoutRef() { - addChildAtIndex(l, 0, 0); + addChildTreeAtIndex(l, 0, 0); } private: FloorLayoutRef() : LayoutReference() { diff --git a/poincare/include/poincare/fraction_layout_node.h b/poincare/include/poincare/fraction_layout_node.h index f56474dd5..7ca9a50dc 100644 --- a/poincare/include/poincare/fraction_layout_node.h +++ b/poincare/include/poincare/fraction_layout_node.h @@ -56,8 +56,8 @@ public: FractionLayoutRef(LayoutRef numerator, LayoutRef denominator) : FractionLayoutRef() { - addChildAtIndex(numerator, 0, 0); - addChildAtIndex(denominator, 1, 1); + addChildTreeAtIndex(numerator, 0, 0); + addChildTreeAtIndex(denominator, 1, 1); } FractionLayoutRef(TreeNode * n) : LayoutReference(n) {} private: diff --git a/poincare/include/poincare/horizontal_layout_node.h b/poincare/include/poincare/horizontal_layout_node.h index 4410f050d..b7a024cd7 100644 --- a/poincare/include/poincare/horizontal_layout_node.h +++ b/poincare/include/poincare/horizontal_layout_node.h @@ -69,26 +69,26 @@ public: } HorizontalLayoutRef(LayoutRef l) : HorizontalLayoutRef() { - addChildAtIndex(l, 0, 0); + addChildTreeAtIndex(l, 0, 0); } HorizontalLayoutRef(LayoutRef l1, LayoutRef l2) : HorizontalLayoutRef() { - addChildAtIndex(l1, 0, 0); - addChildAtIndex(l2, 1, 1); + addChildTreeAtIndex(l1, 0, 0); + addChildTreeAtIndex(l2, 1, 1); } HorizontalLayoutRef(LayoutRef l1, LayoutRef l2, LayoutRef l3) : HorizontalLayoutRef() { - addChildAtIndex(l1, 0, 0); - addChildAtIndex(l2, 1, 1); - addChildAtIndex(l3, 2, 2); + addChildTreeAtIndex(l1, 0, 0); + addChildTreeAtIndex(l2, 1, 1); + addChildTreeAtIndex(l3, 2, 2); } HorizontalLayoutRef(LayoutRef l1, LayoutRef l2, LayoutRef l3, LayoutRef l4) : HorizontalLayoutRef() { - addChildAtIndex(l1, 0, 0); - addChildAtIndex(l2, 1, 1); - addChildAtIndex(l3, 2, 2); - addChildAtIndex(l4, 3, 3); + addChildTreeAtIndex(l1, 0, 0); + addChildTreeAtIndex(l2, 1, 1); + addChildTreeAtIndex(l3, 2, 2); + addChildTreeAtIndex(l4, 3, 3); } - void addChildAtIndex(TreeReference t, int index, int currentNumberOfChildren) override { - ExpressionReference::addChildAtIndex(t, index, currentNumberOfChildren); + void addChildTreeAtIndex(TreeReference t, int index, int currentNumberOfChildren) override { + ExpressionReference::addChildTreeAtIndex(t, index, currentNumberOfChildren); } // Remove puts a child at the end of the pool void removeChildAtIndex(int i) override { diff --git a/poincare/include/poincare/integral_layout_node.h b/poincare/include/poincare/integral_layout_node.h index b04bf531e..bffba4b10 100644 --- a/poincare/include/poincare/integral_layout_node.h +++ b/poincare/include/poincare/integral_layout_node.h @@ -58,9 +58,9 @@ public: IntegralLayoutRef(LayoutRef integrand, LayoutRef lowerBound, LayoutRef upperBound) : IntegralLayoutRef() { - addChildAtIndex(integrand, 0, 0); - addChildAtIndex(lowerBound, 1, 1); - addChildAtIndex(upperBound, 2, 2); + addChildTreeAtIndex(integrand, 0, 0); + addChildTreeAtIndex(lowerBound, 1, 1); + addChildTreeAtIndex(upperBound, 2, 2); } IntegralLayoutRef(TreeNode * n) : LayoutReference(n) {} private: diff --git a/poincare/include/poincare/layout_reference.h b/poincare/include/poincare/layout_reference.h index 04942fe1b..5c52b365f 100644 --- a/poincare/include/poincare/layout_reference.h +++ b/poincare/include/poincare/layout_reference.h @@ -73,7 +73,7 @@ public: // Tree modification // Add - void addChildAtIndex(LayoutReference l, int index, int currentNumberOfChildren, LayoutCursor * cursor); + void addChildTreeAtIndex(LayoutReference l, int index, int currentNumberOfChildren, LayoutCursor * cursor); void addSibling(LayoutCursor * cursor, LayoutReference sibling, bool moveCursor); // Replace //void replaceChildAtIndex(int oldChildIndex, LayoutReference newChild) { TreeReference::replaceTreeChildAtIndex(oldChildIndex, newChild); } diff --git a/poincare/include/poincare/matrix.h b/poincare/include/poincare/matrix.h index 549a8ad58..ae408d70e 100644 --- a/poincare/include/poincare/matrix.h +++ b/poincare/include/poincare/matrix.h @@ -55,7 +55,7 @@ public: MatrixNode * typedNode() const { assert(!isAllocationFailure()); return static_cast(node()); } int numberOfRows() const; int numberOfColumns() const; - void addChildAtIndex(TreeReference t, int index, int currentNumberOfChildren) override; + void addChildTreeAtIndex(TreeReference t, int index, int currentNumberOfChildren) override; ExpressionReference matrixChild(int i, int j) { assert(!isAllocationFailure()); return childAtIndex(i*numberOfColumns()+j); } /* Operation on matrix */ diff --git a/poincare/include/poincare/matrix_complex.h b/poincare/include/poincare/matrix_complex.h index f25f4c9a0..b3e494d05 100644 --- a/poincare/include/poincare/matrix_complex.h +++ b/poincare/include/poincare/matrix_complex.h @@ -60,7 +60,7 @@ public: int numberOfRows() const; int numberOfColumns() const; void setDimensions(int rows, int columns); - void addChildAtIndex(TreeReference t, int index, int currentNumberOfChildren) override; + void addChildTreeAtIndex(TreeReference t, int index, int currentNumberOfChildren) override; private: void setNumberOfRows(int rows); void setNumberOfColumns(int columns); diff --git a/poincare/include/poincare/matrix_layout_node.h b/poincare/include/poincare/matrix_layout_node.h index 1c6d6cc40..c0009ff7d 100644 --- a/poincare/include/poincare/matrix_layout_node.h +++ b/poincare/include/poincare/matrix_layout_node.h @@ -64,10 +64,10 @@ public: MatrixLayoutRef(LayoutRef l1, LayoutRef l2, LayoutRef l3, LayoutRef l4) : MatrixLayoutRef() { - addChildAtIndex(l1, 0, 0); - addChildAtIndex(l2, 1, 1); - addChildAtIndex(l3, 2, 2); - addChildAtIndex(l4, 3, 3); + addChildTreeAtIndex(l1, 0, 0); + addChildTreeAtIndex(l2, 1, 1); + addChildTreeAtIndex(l3, 2, 2); + addChildTreeAtIndex(l4, 3, 3); setDimensions(2, 2); } @@ -102,7 +102,7 @@ public: } } void setDimensions(int rows, int columns); - void addChildAtIndex(TreeReference t, int index, int currentNumberOfChildren) override; + void addChildTreeAtIndex(TreeReference t, int index, int currentNumberOfChildren) override; private: MatrixLayoutNode * typedNode() const { assert(!isAllocationFailure()); return static_cast(node()); } void setNumberOfRows(int rows); diff --git a/poincare/include/poincare/n_ary_expression_node.h b/poincare/include/poincare/n_ary_expression_node.h index 9af45e532..7db109612 100644 --- a/poincare/include/poincare/n_ary_expression_node.h +++ b/poincare/include/poincare/n_ary_expression_node.h @@ -33,8 +33,8 @@ private: class NAryExpressionRef : public ExpressionReference { public: - void addChildAtIndex(TreeReference t, int index, int currentNumberOfChildren) override { - ExpressionReference::addChildAtIndex(t, index, currentNumberOfChildren); + void addChildTreeAtIndex(TreeReference t, int index, int currentNumberOfChildren) override { + ExpressionReference::addChildTreeAtIndex(t, index, currentNumberOfChildren); } // Remove puts a child at the end of the pool void removeChildAtIndex(int i) override { diff --git a/poincare/include/poincare/nth_root_layout_node.h b/poincare/include/poincare/nth_root_layout_node.h index 9ed13d05b..2df542628 100644 --- a/poincare/include/poincare/nth_root_layout_node.h +++ b/poincare/include/poincare/nth_root_layout_node.h @@ -69,19 +69,19 @@ public: NthRootLayoutRef(TreeNode * n) : LayoutReference(n) {} NthRootLayoutRef(LayoutRef radicand) : NthRootLayoutRef() { - addChildAtIndex(radicand, 0, 0); + addChildTreeAtIndex(radicand, 0, 0); if (!node()->isAllocationFailure()) { static_cast(node())->setNumberOfChildren(1); } } NthRootLayoutRef(LayoutRef radicand, LayoutRef index) : NthRootLayoutRef() { - addChildAtIndex(radicand, 0, 0); + addChildTreeAtIndex(radicand, 0, 0); if (node()->isAllocationFailure()) { return; } static_cast(node())->setNumberOfChildren(1); - addChildAtIndex(index, 1, 1); + addChildTreeAtIndex(index, 1, 1); if (!node()->isAllocationFailure()) { static_cast(node())->setNumberOfChildren(2); } diff --git a/poincare/include/poincare/parenthesis.h b/poincare/include/poincare/parenthesis.h index 4a90e4007..16011931f 100644 --- a/poincare/include/poincare/parenthesis.h +++ b/poincare/include/poincare/parenthesis.h @@ -39,7 +39,7 @@ public: ParenthesisReference(ExpressionReference exp) { TreeNode * node = TreePool::sharedPool()->createTreeNode(); m_identifier = node->identifier(); - addChildAtIndex(exp, 0, 0); + addChildTreeAtIndex(exp, 0, 0); } }; diff --git a/poincare/include/poincare/product_layout_node.h b/poincare/include/poincare/product_layout_node.h index 11e76de72..a425bcae7 100644 --- a/poincare/include/poincare/product_layout_node.h +++ b/poincare/include/poincare/product_layout_node.h @@ -27,9 +27,9 @@ public: ProductLayoutRef(LayoutRef argument, LayoutRef lowerB, LayoutRef upperB) : ProductLayoutRef() { - addChildAtIndex(argument, 0, 0); - addChildAtIndex(lowerB, 1, 1); - addChildAtIndex(upperB, 2, 2); + addChildTreeAtIndex(argument, 0, 0); + addChildTreeAtIndex(lowerB, 1, 1); + addChildTreeAtIndex(upperB, 2, 2); } private: ProductLayoutRef() : LayoutReference() { diff --git a/poincare/include/poincare/sum_layout_node.h b/poincare/include/poincare/sum_layout_node.h index a8c901b42..d877dc09c 100644 --- a/poincare/include/poincare/sum_layout_node.h +++ b/poincare/include/poincare/sum_layout_node.h @@ -20,9 +20,9 @@ public: SumLayoutRef(LayoutRef argument, LayoutRef lowerB, LayoutRef upperB) : SumLayoutRef() { - addChildAtIndex(argument, 0, 0); - addChildAtIndex(lowerB, 1, 1); - addChildAtIndex(upperB, 2, 2); + addChildTreeAtIndex(argument, 0, 0); + addChildTreeAtIndex(lowerB, 1, 1); + addChildTreeAtIndex(upperB, 2, 2); } private: SumLayoutRef() : LayoutReference() { diff --git a/poincare/include/poincare/tree_reference.h b/poincare/include/poincare/tree_reference.h index 4478da3b7..e935509c3 100644 --- a/poincare/include/poincare/tree_reference.h +++ b/poincare/include/poincare/tree_reference.h @@ -113,7 +113,7 @@ public: protected: // Hierarchy operations // Add - virtual void addChildAtIndex(TreeReference t, int index, int currentNumberOfChildren); + virtual void addChildTreeAtIndex(TreeReference t, int index, int currentNumberOfChildren); // Remove puts a child at the end of the pool virtual void removeChildAtIndex(int i); virtual void removeChild(TreeReference t, int childNumberOfChildren); diff --git a/poincare/include/poincare/vertical_offset_layout_node.h b/poincare/include/poincare/vertical_offset_layout_node.h index 97a9703d2..48dc28522 100644 --- a/poincare/include/poincare/vertical_offset_layout_node.h +++ b/poincare/include/poincare/vertical_offset_layout_node.h @@ -66,7 +66,7 @@ public: if (!(node()->isAllocationFailure())) { static_cast(node())->setType(type); } - addChildAtIndex(l, 0, 0); + addChildTreeAtIndex(l, 0, 0); } private: VerticalOffsetLayoutRef() : LayoutReference() { diff --git a/poincare/src/approximation_engine.cpp b/poincare/src/approximation_engine.cpp index 9be578c84..50b9c2ca4 100644 --- a/poincare/src/approximation_engine.cpp +++ b/poincare/src/approximation_engine.cpp @@ -40,9 +40,9 @@ template EvaluationReference ApproximationEngine::map(const Expre for (int i = 0; i < result.numberOfRows()*result.numberOfColumns(); i++) { ComplexNode * child = static_cast *>(m.node())->childAtIndex(i); if (child) { - result.addChildAtIndex(compute(*child, angleUnit), i, i); + result.addChildTreeAtIndex(compute(*child, angleUnit), i, i); } else { - result.addChildAtIndex(ComplexReference::Undefined(), i, i); + result.addChildTreeAtIndex(ComplexReference::Undefined(), i, i); } } result.setDimensions(m.numberOfRows(), m.numberOfColumns()); @@ -95,9 +95,9 @@ template MatrixComplexReference ApproximationEngine::elementWiseO for (int i = 0; i < m.numberOfChildren(); i++) { ComplexNode * child = static_cast *>(m.node())->childAtIndex(i); if (child) { - matrix.addChildAtIndex(computeOnComplexes(*child, c), i, i); + matrix.addChildTreeAtIndex(computeOnComplexes(*child, c), i, i); } else { - matrix.addChildAtIndex(ComplexReference::Undefined(), i, i); + matrix.addChildTreeAtIndex(ComplexReference::Undefined(), i, i); } } matrix.setDimensions(m.numberOfRows(), m.numberOfColumns()); @@ -116,9 +116,9 @@ template MatrixComplexReference ApproximationEngine::elementWiseO ComplexNode * childM = static_cast *>(m.node())->childAtIndex(i); ComplexNode * childN = static_cast *>(n.node())->childAtIndex(i); if (childM && childN) { - matrix.addChildAtIndex(computeOnComplexes(*childM, *childN), i, i); + matrix.addChildTreeAtIndex(computeOnComplexes(*childM, *childN), i, i); } else { - matrix.addChildAtIndex(ComplexReference::Undefined(), i, i); + matrix.addChildTreeAtIndex(ComplexReference::Undefined(), i, i); } } matrix.setDimensions(m.numberOfRows(), m.numberOfColumns()); diff --git a/poincare/src/equal.cpp b/poincare/src/equal.cpp index b03c992ee..3ae73dfe6 100644 --- a/poincare/src/equal.cpp +++ b/poincare/src/equal.cpp @@ -52,7 +52,7 @@ ExpressionReference Equal::shallowReduce(Context& context, Preferences::AngleUni LayoutRef Equal::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { HorizontalLayoutRef result; result.addOrMergeChildAtIndex(operand(0)->createLayout(floatDisplayMode, numberOfSignificantDigits), 0, false); - result.addChildAtIndex(CharLayoutRef('='), result.numberOfChildren(), result.numberOfChildren(), nullptr); + result.addChildTreeAtIndex(CharLayoutRef('='), result.numberOfChildren(), result.numberOfChildren(), nullptr); result.addOrMergeChildAtIndex(operand(1)->createLayout(floatDisplayMode, numberOfSignificantDigits), result.numberOfChildren(), false); return result; } diff --git a/poincare/src/expression_node.cpp b/poincare/src/expression_node.cpp index 59b11cecf..36d1ff1fc 100644 --- a/poincare/src/expression_node.cpp +++ b/poincare/src/expression_node.cpp @@ -23,7 +23,7 @@ ExpressionReference ExpressionNode::replaceSymbolWithExpression(char symbol, Exp for (int i = 0; i < nbChildren; i++) { ExpressionReference newChild = reference.childAtIndex(i).node()->replaceSymbolWithExpression(symbol, expression); if (reference.numberOfChildren() < nbChildren) { - reference.addChildAtIndex(newChild, i, nbChildren - 1); + reference.addChildTreeAtIndex(newChild, i, nbChildren - 1); } else { reference.replaceTreeChildAtIndex(i, newChild); } diff --git a/poincare/src/expression_reference.cpp b/poincare/src/expression_reference.cpp index 57cb30851..6af3a826d 100644 --- a/poincare/src/expression_reference.cpp +++ b/poincare/src/expression_reference.cpp @@ -202,7 +202,7 @@ ExpressionReference ExpressionReference::deepReduce(Context & context, Preferenc for (int i = 0; i < nbChildren; i++) { ExpressionReference reducedChild = childAtIndex(i).deepReduce(context, angleUnit); if (numberOfChildren() < nbChildren) { - addChildAtIndex(reducedChild, i, nbChildren-1); + addChildTreeAtIndex(reducedChild, i, nbChildren-1); } else { replaceTreeChildAtIndex(i, reducedChild); } @@ -216,7 +216,7 @@ ExpressionReference ExpressionReference::deepBeautify(Context & context, Prefere for (int i = 0; i < nbChildren; i++) { ExpressionReference beautifiedChild = beautifiedExpression.childAtIndex(i).deepBeautify(context, angleUnit); if (beautifiedExpression.numberOfChildren() < nbChildren) { - beautifiedExpression.addChildAtIndex(beautifiedChild, i, nbChildren-1); + beautifiedExpression.addChildTreeAtIndex(beautifiedChild, i, nbChildren-1); } else { beautifiedExpression.replaceTreeChildAtIndex(i, beautifiedChild); } diff --git a/poincare/src/factorial.cpp b/poincare/src/factorial.cpp index 88e2ac670..719fafd46 100644 --- a/poincare/src/factorial.cpp +++ b/poincare/src/factorial.cpp @@ -96,7 +96,7 @@ LayoutRef Factorial::createLayout(Preferences::PrintFloatMode floatDisplayMode, HorizontalLayoutRef result; result.addOrMergeChildAtIndex(operand(0)->createLayout(floatDisplayMode, numberOfSignificantDigits), 0, false); int childrenCount = result.numberOfChildren(); - result.addChildAtIndex(CharLayoutRef('!'), childrenCount, childrenCount, nullptr); + result.addChildTreeAtIndex(CharLayoutRef('!'), childrenCount, childrenCount, nullptr); return result; } diff --git a/poincare/src/grid_layout_node.cpp b/poincare/src/grid_layout_node.cpp index 57b8e8e2f..aad382ad1 100644 --- a/poincare/src/grid_layout_node.cpp +++ b/poincare/src/grid_layout_node.cpp @@ -96,7 +96,7 @@ void GridLayoutNode::addEmptyRow(EmptyLayoutNode::Color color) { int previousNumberOfChildren = numberOfChildren(); int columnsCount = m_numberOfColumns; for (int i = 0; i < columnsCount; i++) { - thisRef.addChildAtIndex( + thisRef.addChildTreeAtIndex( EmptyLayoutRef(color), previousNumberOfChildren, previousNumberOfChildren + i, @@ -114,7 +114,7 @@ void GridLayoutNode::addEmptyColumn(EmptyLayoutNode::Color color) { int rowsCount = m_numberOfRows; int futureColumnsCount = m_numberOfColumns + 1; for (int i = 0; i < rowsCount; i++) { - thisRef.addChildAtIndex( + thisRef.addChildTreeAtIndex( EmptyLayoutRef(color), i*futureColumnsCount + futureColumnsCount-1, previousNumberOfChildren + i, diff --git a/poincare/src/horizontal_layout_node.cpp b/poincare/src/horizontal_layout_node.cpp index 05719ba40..9389e263c 100644 --- a/poincare/src/horizontal_layout_node.cpp +++ b/poincare/src/horizontal_layout_node.cpp @@ -245,7 +245,7 @@ void HorizontalLayoutNode::didRemoveChildAtIndex(int index, LayoutCursor * curso * sibling (e.g. a VerticalOffsetLayout), add an empty layout at index 0 */ if (!force && index == 0 && numberOfChildren() > 0 && childAtIndex(0)->mustHaveLeftSibling()) { - LayoutRef(this).addChildAtIndex(EmptyLayoutRef(), 0, numberOfChildren(), cursor); + LayoutRef(this).addChildTreeAtIndex(EmptyLayoutRef(), 0, numberOfChildren(), cursor); } } @@ -347,7 +347,7 @@ void HorizontalLayoutRef::addOrMergeChildAtIndex(LayoutRef l, int index, bool re if (l.isHorizontal()) { mergeChildrenAtIndex(HorizontalLayoutRef(l.node()), index, removeEmptyChildren, cursor); } else { - addChildAtIndex(l, index, numberOfChildren(),cursor); + addChildTreeAtIndex(l, index, numberOfChildren(),cursor); } } diff --git a/poincare/src/integer.cpp b/poincare/src/integer.cpp index f4542d268..fbdea185b 100644 --- a/poincare/src/integer.cpp +++ b/poincare/src/integer.cpp @@ -422,7 +422,7 @@ T IntegerNode::templatedApproximate() const { LayoutRef IntegerNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { LayoutRef naturalLayout = NaturalIntegerAbstract::createLayout(); if (m_negative) { - naturalLayout.addChildAtIndex(CharLayoutRef('-'), 0, naturalLayout.numberOfChildren(), nullptr); + naturalLayout.addChildTreeAtIndex(CharLayoutRef('-'), 0, naturalLayout.numberOfChildren(), nullptr); } return naturalLayout; } diff --git a/poincare/src/layout_engine.cpp b/poincare/src/layout_engine.cpp index 80029e90e..cf6817709 100644 --- a/poincare/src/layout_engine.cpp +++ b/poincare/src/layout_engine.cpp @@ -34,7 +34,7 @@ LayoutRef LayoutEngine::createPrefixLayout(const Expression * expression, Prefer if (numberOfChildren > 0) { args.addOrMergeChildAtIndex(expression->operand(0)->createLayout(floatDisplayMode, numberOfSignificantDigits), 0, true); for (int i = 1; i < numberOfChildren; i++) { - args.addChildAtIndex(CharLayoutRef(','), args.numberOfChildren(), args.numberOfChildren(), nullptr); + args.addChildTreeAtIndex(CharLayoutRef(','), args.numberOfChildren(), args.numberOfChildren(), nullptr); args.addOrMergeChildAtIndex(expression->operand(i)->createLayout(floatDisplayMode, numberOfSignificantDigits), args.numberOfChildren(), true); } } @@ -45,11 +45,11 @@ LayoutRef LayoutEngine::createPrefixLayout(const Expression * expression, Prefer LayoutRef LayoutEngine::createParenthesedLayout(LayoutRef layoutRef, bool cloneLayout) { HorizontalLayoutRef result; - result.addChildAtIndex(LeftParenthesisLayoutRef(), 0, 0); + result.addChildTreeAtIndex(LeftParenthesisLayoutRef(), 0, 0); if (layoutRef.isDefined()) { result.addOrMergeChildAtIndex(cloneLayout ? layoutRef.clone() : layoutRef, 1, true); } - result.addChildAtIndex(RightParenthesisLayoutRef(), result.numberOfChildren(), result.numberOfChildren()); + result.addChildTreeAtIndex(RightParenthesisLayoutRef(), result.numberOfChildren(), result.numberOfChildren()); return result; } @@ -57,7 +57,7 @@ LayoutRef LayoutEngine::createStringLayout(const char * buffer, int bufferSize, assert(bufferSize > 0); HorizontalLayoutRef resultLayout; for (int i = 0; i < bufferSize; i++) { - resultLayout.addChildAtIndex(CharLayoutRef(buffer[i], fontSize), i, i, nullptr); + resultLayout.addChildTreeAtIndex(CharLayoutRef(buffer[i], fontSize), i, i, nullptr); } return resultLayout; } @@ -65,7 +65,7 @@ LayoutRef LayoutEngine::createStringLayout(const char * buffer, int bufferSize, LayoutRef LayoutEngine::createLogLayout(LayoutRef argument, LayoutRef index) { HorizontalLayoutRef resultLayout = HorizontalLayoutRef(createStringLayout("log", 3)); VerticalOffsetLayoutRef offsetLayout = VerticalOffsetLayoutRef(index, VerticalOffsetLayoutNode::Type::Subscript); - resultLayout.addChildAtIndex(offsetLayout, resultLayout.numberOfChildren(), resultLayout.numberOfChildren(), nullptr); + resultLayout.addChildTreeAtIndex(offsetLayout, resultLayout.numberOfChildren(), resultLayout.numberOfChildren(), nullptr); resultLayout.addOrMergeChildAtIndex(createParenthesedLayout(argument, false), resultLayout.numberOfChildren(), true); return resultLayout; } diff --git a/poincare/src/layout_reference.cpp b/poincare/src/layout_reference.cpp index 7677f4067..b415d1d7c 100644 --- a/poincare/src/layout_reference.cpp +++ b/poincare/src/layout_reference.cpp @@ -80,7 +80,7 @@ void LayoutReference::replaceWithJuxtapositionOf(LayoutRef leftChild, LayoutRef p.removeChild(*this, cursor->layoutReference() == *this ? cursor : nullptr); } -void LayoutReference::addChildAtIndex(LayoutRef l, int index, int currentNumberOfChildren, LayoutCursor * cursor) { +void LayoutReference::addChildTreeAtIndex(LayoutRef l, int index, int currentNumberOfChildren, LayoutCursor * cursor) { int newIndex = index; int newCurrentNumberOfChildren = currentNumberOfChildren; if (!this->node()->willAddChildAtIndex(l.node(), &newIndex, &newCurrentNumberOfChildren, cursor)) { @@ -98,7 +98,7 @@ void LayoutReference::addChildAtIndex(LayoutRef l, int index, int currentNumberO } } - this->addChildAtIndex(l, newIndex, newCurrentNumberOfChildren); + this->addChildTreeAtIndex(l, newIndex, newCurrentNumberOfChildren); if (cursor != nullptr) { if (this->isAllocationFailure()) { diff --git a/poincare/src/matrix.cpp b/poincare/src/matrix.cpp index 223319df8..c6cf401d7 100644 --- a/poincare/src/matrix.cpp +++ b/poincare/src/matrix.cpp @@ -23,7 +23,7 @@ LayoutRef MatrixNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, layout.setNumberOfColumns(1); LayoutRef castedLayout(layout.node()); for (int i = 0; i < numberOfChildren(); i++) { - castedLayout.addChildAtIndex(childAtIndex(i)->createLayout(floatDisplayMode, numberOfSignificantDigits), i, i, nullptr); + castedLayout.addChildTreeAtIndex(childAtIndex(i)->createLayout(floatDisplayMode, numberOfSignificantDigits), i, i, nullptr); layout.setNumberOfRows(i+1); } layout.setNumberOfRows(m_numberOfRows); @@ -83,9 +83,9 @@ EvaluationReference MatrixNode::templatedApproximate(Context& context, Prefer for (int i = 0; i < numberOfChildren(); i++) { EvaluationReference operandEvaluation = childAtIndex(i)->approximate(T(), context, angleUnit); if (operandEvaluation.node()->type() != Evaluation::Type::Complex) { - result.addChildAtIndex(ComplexReference::Undefined(), i, i); + result.addChildTreeAtIndex(ComplexReference::Undefined(), i, i); } else { - result.addChildAtIndex(compute(*child, angleUnit), i, i); + result.addChildTreeAtIndex(compute(*child, angleUnit), i, i); } } matrix.setDimensions(m.numberOfRows(), m.numberOfColumns()); @@ -117,8 +117,8 @@ int MatrixReference::numberOfColumns() const { return typedNode()->numberOfColumns(); } -void MatrixReference::addChildAtIndex(TreeReference t, int index, int currentNumberOfChildren) { - ExpressionReference::addChildAtIndex(t, index, currentNumberOfChildren); +void MatrixReference::addChildTreeAtIndex(TreeReference t, int index, int currentNumberOfChildren) { + ExpressionReference::addChildTreeAtIndex(t, index, currentNumberOfChildren); if (isAllocationFailure()) { return; } @@ -163,7 +163,7 @@ void MatrixReference::rowCanonize(Context & context, Preferences::AngleUnit angl // No non-null coefficient in this column, skip k++; // Update determinant: det *= 0 - if (determinant) { determinant.addChildAtIndex(RationalReference(0), 0, determinant.numberOfChildren()); } + if (determinant) { determinant.addChildTreeAtIndex(RationalReference(0), 0, determinant.numberOfChildren()); } } else { // Swap row h and iPivot if (iPivot != h) { @@ -171,12 +171,12 @@ void MatrixReference::rowCanonize(Context & context, Preferences::AngleUnit angl swapChildren(iPivot*n+col, h*n+col); } // Update determinant: det *= -1 - if (determinant) { determinant.addChildAtIndex(RationalReference(-1), 0, determinant.numberOfChildren()); } + if (determinant) { determinant.addChildTreeAtIndex(RationalReference(-1), 0, determinant.numberOfChildren()); } } /* Set to 1 M[h][k] by linear combination */ ExpressionReference divisor = matrixChild(h, k); // Update determinant: det *= divisor - if (determinant) { determinant.addChildAtIndex(divisor.clone()); } + if (determinant) { determinant.addChildTreeAtIndex(divisor.clone()); } for (int j = k+1; j < n; j++) { ExpressionReference opHJ = matrixChild(h, j); ExpressionReference newOpHJ = DivisionReference(opHJ, divisor.clone()); diff --git a/poincare/src/matrix_complex.cpp b/poincare/src/matrix_complex.cpp index 244dcceba..1f77fdad9 100644 --- a/poincare/src/matrix_complex.cpp +++ b/poincare/src/matrix_complex.cpp @@ -39,9 +39,9 @@ ExpressionReference MatrixComplexNode::complexToExpression(Preferences::Compl for (int i = 0; i < numberOfComplexOperands(); i++) { ComplexNode * child = childAtIndex(i); if (child) { - matrix.addChildAtIndex(child->complexToExpression(complexFormat), i, i); + matrix.addChildTreeAtIndex(child->complexToExpression(complexFormat), i, i); } else { - matrix.addChildAtIndex(UndefinedReference(), i, i); + matrix.addChildTreeAtIndex(UndefinedReference(), i, i); } } matrix.setDimensions(numberOfRows(), numberOfColumns()); @@ -113,9 +113,9 @@ EvaluationReference MatrixComplexNode::transpose() const { for (int j = 0; j < numberOfColumns(); j++) { ComplexNode * child = childAtIndex(i*numberOfColumns()+i); if (child) { - result.addChildAtIndex(child, j*numberOfRows()+i, j*numberOfRows()+i); + result.addChildTreeAtIndex(child, j*numberOfRows()+i, j*numberOfRows()+i); } else { - result.addChildAtIndex(ComplexReference::Undefined(), j*numberOfRows()+i, j*numberOfRows()+i); + result.addChildTreeAtIndex(ComplexReference::Undefined(), j*numberOfRows()+i, j*numberOfRows()+i); } } } @@ -138,7 +138,7 @@ MatrixComplexReference::MatrixComplexReference(std::complex * operands, in MatrixComplexReference() { for (int i=0; i(operands[i]), i, i); + addChildTreeAtIndex(ComplexReference(operands[i]), i, i); } setDimensions(numberOfRows, numberOfColumns); } @@ -149,7 +149,7 @@ MatrixComplexReference MatrixComplexReference::createIdentity(int dim) { for (int i = 0; i < dim; i++) { for (int j = 0; j < dim; j++) { ComplexReference c = i == j ? ComplexReference(1.0) : ComplexReference(0.0); - result.addChildAtIndex(c, i*dim+j, i*dim+j); + result.addChildTreeAtIndex(c, i*dim+j, i*dim+j); } } result.setDimensions(dim, dim); @@ -183,8 +183,8 @@ void MatrixComplexReference::setDimensions(int rows, int columns) { } template -void MatrixComplexReference::addChildAtIndex(TreeReference t, int index, int currentNumberOfChildren) { - ExpressionReference::addChildAtIndex(t, index, currentNumberOfChildren); +void MatrixComplexReference::addChildTreeAtIndex(TreeReference t, int index, int currentNumberOfChildren) { + ExpressionReference::addChildTreeAtIndex(t, index, currentNumberOfChildren); if (isAllocationFailure()) { return; } diff --git a/poincare/src/matrix_layout_node.cpp b/poincare/src/matrix_layout_node.cpp index 32e7fef59..4ef95ef02 100644 --- a/poincare/src/matrix_layout_node.cpp +++ b/poincare/src/matrix_layout_node.cpp @@ -296,8 +296,8 @@ void MatrixLayoutRef::setDimensions(int rows, int columns) { setNumberOfColumns(columns); } -void MatrixLayoutRef::addChildAtIndex(TreeReference t, int index, int currentNumberOfChildren) { - ExpressionReference::addChildAtIndex(t, index, currentNumberOfChildren); +void MatrixLayoutRef::addChildTreeAtIndex(TreeReference t, int index, int currentNumberOfChildren) { + ExpressionReference::addChildTreeAtIndex(t, index, currentNumberOfChildren); if (isAllocationFailure()) { return; } diff --git a/poincare/src/power.cpp b/poincare/src/power.cpp index 62138baac..3fc1c152a 100644 --- a/poincare/src/power.cpp +++ b/poincare/src/power.cpp @@ -179,7 +179,7 @@ LayoutRef Power::createLayout(Preferences::PrintFloatMode floatDisplayMode, int } HorizontalLayoutRef result = HorizontalLayoutRef(); result.addOrMergeChildAtIndex(m_operands[0]->createLayout(floatDisplayMode, numberOfSignificantDigits), 0, false); - result.addChildAtIndex(VerticalOffsetLayoutRef( + result.addChildTreeAtIndex(VerticalOffsetLayoutRef( indiceOperand->createLayout(floatDisplayMode, numberOfSignificantDigits), VerticalOffsetLayoutNode::Type::Superscript), result.numberOfChildren(), diff --git a/poincare/src/rational.cpp b/poincare/src/rational.cpp index 0242378ba..c17d7ca2b 100644 --- a/poincare/src/rational.cpp +++ b/poincare/src/rational.cpp @@ -89,7 +89,7 @@ void RationalNode::setSign(Sign s) { LayoutRef RationalNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { LayoutRef numeratorLayout = numerator().createLayout(); if (m_negative) { - numeratorLayout.addChildAtIndex(CharLayoutRef('-'), 0, numeratorLayout.numberOfChildren(), nullptr); + numeratorLayout.addChildTreeAtIndex(CharLayoutRef('-'), 0, numeratorLayout.numberOfChildren(), nullptr); } if (denominator().isOne()) { return numeratorLayout; diff --git a/poincare/src/store.cpp b/poincare/src/store.cpp index 57dafda38..c962fd0c6 100644 --- a/poincare/src/store.cpp +++ b/poincare/src/store.cpp @@ -36,7 +36,7 @@ ExpressionReference Store::shallowReduce(Context& context, Preferences::AngleUni LayoutRef Store::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { HorizontalLayoutRef result = HorizontalLayoutRef(); result.addOrMergeChildAtIndex(value()->createLayout(floatDisplayMode, numberOfSignificantDigits), 0, false); - result.addChildAtIndex(CharLayoutRef(Ion::Charset::Sto), result.numberOfChildren(), result.numberOfChildren(), nullptr); + result.addChildTreeAtIndex(CharLayoutRef(Ion::Charset::Sto), result.numberOfChildren(), result.numberOfChildren(), nullptr); result.addOrMergeChildAtIndex(symbol()->createLayout(floatDisplayMode, numberOfSignificantDigits), result.numberOfChildren(), false); return result; } diff --git a/poincare/src/tree_reference.cpp b/poincare/src/tree_reference.cpp index 2636a1f35..bebfbda3e 100644 --- a/poincare/src/tree_reference.cpp +++ b/poincare/src/tree_reference.cpp @@ -137,7 +137,7 @@ void TreeReference::replaceWithAllocationFailure(int currentNumberOfChildren) { * 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.addChildAtIndex(TreeRef(newAllocationFailureNode), indexInParentNode, p.numberOfChildren() - 1); + p.addChildTreeAtIndex(TreeRef(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. */ @@ -183,7 +183,7 @@ void TreeReference::setTo(const TreeReference & tr) { } // Add -void TreeReference::addChildAtIndex(TreeReference t, int index, int currentNumberOfChildren) { +void TreeReference::addChildTreeAtIndex(TreeReference t, int index, int currentNumberOfChildren) { assert(isDefined()); if (node()->isAllocationFailure()) { return; diff --git a/poincare/src/vertical_offset_layout_node.cpp b/poincare/src/vertical_offset_layout_node.cpp index 6c1a17ec8..6b8ce3a09 100644 --- a/poincare/src/vertical_offset_layout_node.cpp +++ b/poincare/src/vertical_offset_layout_node.cpp @@ -253,16 +253,16 @@ bool VerticalOffsetLayoutNode::willAddSibling(LayoutCursor * cursor, LayoutNode { leftParenthesisIndex--; } - parentRef.addChildAtIndex(leftParenthesis, leftParenthesisIndex, parentRef.numberOfChildren(), nullptr); + parentRef.addChildTreeAtIndex(leftParenthesis, leftParenthesisIndex, parentRef.numberOfChildren(), nullptr); idxInParent = parentRef.indexOfChild(thisRef); // Add the Right parenthesis RightParenthesisLayoutRef rightParenthesis = RightParenthesisLayoutRef(); if (cursor->position() == LayoutCursor::Position::Right) { - parentRef.addChildAtIndex(rightParenthesis, idxInParent + 1, parentRef.numberOfChildren(), nullptr); + parentRef.addChildTreeAtIndex(rightParenthesis, idxInParent + 1, parentRef.numberOfChildren(), nullptr); } else { assert(cursor->position() == LayoutCursor::Position::Left); - parentRef.addChildAtIndex(rightParenthesis, idxInParent, parentRef.numberOfChildren(), nullptr); + parentRef.addChildTreeAtIndex(rightParenthesis, idxInParent, parentRef.numberOfChildren(), nullptr); } if (rightParenthesis.parent().isDefined()) { cursor->setLayoutReference(rightParenthesis); diff --git a/poincare/test/parentheses_layout.cpp b/poincare/test/parentheses_layout.cpp index 0b175a54d..7cbeb508e 100644 --- a/poincare/test/parentheses_layout.cpp +++ b/poincare/test/parentheses_layout.cpp @@ -15,18 +15,18 @@ QUIZ_CASE(poincare_parenthesis_layout_size) { HorizontalLayout * layout = new HorizontalLayout(); LeftParenthesisLayout leftPar = new LeftParenthesisLayout(); RightParenthesisLayout rightPar = new RightParenthesisLayout(); - layout->addChildAtIndex(leftPar, 0); - layout->addChildAtIndex(new CharLayout('2'), 1); - layout->addChildAtIndex(new CharLayout('+'), 2); - layout->addChildAtIndex(new LeftParenthesisLayout(), 3); - layout->addChildAtIndex(new FractionLayout( + layout->addChildTreeAtIndex(leftPar, 0); + layout->addChildTreeAtIndex(new CharLayout('2'), 1); + layout->addChildTreeAtIndex(new CharLayout('+'), 2); + layout->addChildTreeAtIndex(new LeftParenthesisLayout(), 3); + layout->addChildTreeAtIndex(new FractionLayout( new CharLayout('3'), new CharLayout('4')), 4); - layout->addChildAtIndex(new RightParenthesisLayout(), 3); - layout->addChildAtIndex(new CharLayout('6'), 5); - layout->addChildAtIndex(rightPar, 7); - layout->addChildAtIndex(new CharLayout('1'), 8); + layout->addChildTreeAtIndex(new RightParenthesisLayout(), 3); + layout->addChildTreeAtIndex(new CharLayout('6'), 5); + layout->addChildTreeAtIndex(rightPar, 7); + layout->addChildTreeAtIndex(new CharLayout('1'), 8); assert(leftPar->size().height() == rightPar->size().height()); delete layout; }