#include #include extern "C" { #include } namespace Poincare { template StaticLayoutHierarchy::StaticLayoutHierarchy() : ExpressionLayout(), m_children{} { } template StaticLayoutHierarchy::StaticLayoutHierarchy(const ExpressionLayout * const * children, bool cloneChildren) : ExpressionLayout() { build(children, T, cloneChildren); } template<> StaticLayoutHierarchy<1>::StaticLayoutHierarchy(const ExpressionLayout * e, bool cloneChildren) : StaticLayoutHierarchy((ExpressionLayout **)&e, cloneChildren) { } template<> StaticLayoutHierarchy<2>::StaticLayoutHierarchy(const ExpressionLayout * e1, const ExpressionLayout * e2, bool cloneChildren) : StaticLayoutHierarchy(ExpressionLayoutArray(e1, e2).array(), cloneChildren) { } template<> StaticLayoutHierarchy<3>::StaticLayoutHierarchy(const ExpressionLayout * e1, const ExpressionLayout * e2, const ExpressionLayout * e3, bool cloneChildren) : StaticLayoutHierarchy(ExpressionLayoutArray(e1, e2, e3).array(), cloneChildren) { } template StaticLayoutHierarchy::~StaticLayoutHierarchy() { for (int i = 0; i < T; i++) { if (m_children[i] != nullptr) { delete m_children[i]; } } } template void StaticLayoutHierarchy::build(const ExpressionLayout * const * operands, int numberOfOperands, bool cloneOperands) { assert(operands != nullptr); assert(numberOfOperands <= T); for (int i = 0; i < numberOfOperands; i++) { assert(operands[i] != nullptr); if (cloneOperands) { m_children[i] = operands[i]->clone(); } else { m_children[i] = operands[i]; } const_cast(m_children[i])->setParent(this); } } template class Poincare::StaticLayoutHierarchy<0>; template class Poincare::StaticLayoutHierarchy<1>; template class Poincare::StaticLayoutHierarchy<2>; template class Poincare::StaticLayoutHierarchy<3>; }