[poincare] Implement SerializationHelper and

SerializationHelperInterface. WriteTextInBuffer->serialize
This commit is contained in:
Émilie Feral
2018-08-08 15:31:40 +02:00
parent cb4bb4f8f0
commit aaa20a58fa
149 changed files with 247 additions and 277 deletions

View File

@@ -77,7 +77,7 @@ bool App::layoutFieldDidReceiveEvent(::LayoutField * layoutField, Ion::Events::E
int bufferLength = Calculation::k_printedExpressionSize;
char bufferForParsing[bufferLength];
layoutField->writeTextInBuffer(bufferForParsing, bufferLength);
layoutField->serialize(bufferForParsing, bufferLength);
if (!textInputIsCorrect(bufferForParsing)) {
displayWarning(I18n::Message::SyntaxError);

View File

@@ -159,7 +159,7 @@ bool EditExpressionController::inputViewDidFinishEditing(const char * text, Layo
strlcpy(m_cacheBuffer, text, Calculation::k_printedExpressionSize);
} else {
assert(layoutR.isDefined());
layoutR.writeTextInBuffer(m_cacheBuffer, Calculation::k_printedExpressionSize);
layoutR.serialize(m_cacheBuffer, Calculation::k_printedExpressionSize);
}
m_calculationStore->push(m_cacheBuffer, calculationApp->localContext());
m_historyController->reload();

View File

@@ -71,7 +71,7 @@ void EditorView::GutterView::drawRect(KDContext * ctx, KDRect rect) const {
int numberOfLines = bounds().height() / charSize.height() + 1;
for (int i=0; i<numberOfLines; i++) {
Poincare::Integer line(i + firstLine + 1);
line.writeTextInBuffer(lineNumber, 4);
line.serialize(lineNumber, 4);
KDCoordinate leftPadding = (2 - strlen(lineNumber)) * charSize.width();
ctx->drawString(
lineNumber,

View File

@@ -112,7 +112,7 @@ void ListParameterController::willDisplayCellForIndex(HighlightCell * cell, int
return;
}
char buffer[Sequence::k_initialRankNumberOfDigits+1];
Integer(m_sequence->initialRank()).writeTextInBuffer(buffer, Sequence::k_initialRankNumberOfDigits+1);
Integer(m_sequence->initialRank()).serialize(buffer, Sequence::k_initialRankNumberOfDigits+1);
myCell->setAccessoryText(buffer);
}
}

View File

@@ -112,7 +112,7 @@ void SequenceToolbox::buildExtraCellsLayouts(const char * sequenceName, int recu
bool SequenceToolbox::selectAddedCell(int selectedRow){
int bufferSize = 10;
char buffer[bufferSize];
m_addedCellLayout[selectedRow]->writeTextInBuffer(buffer, bufferSize);
m_addedCellLayout[selectedRow]->serialize(buffer, bufferSize);
sender()->handleEventWithText(buffer);
app()->dismissModalViewController();
return true;

View File

@@ -254,7 +254,7 @@ Poincare::ExpressionLayout * Sequence::definitionName() {
Poincare::ExpressionLayout * Sequence::firstInitialConditionName() {
char buffer[k_initialRankNumberOfDigits+1];
Integer(m_initialRank).writeTextInBuffer(buffer, k_initialRankNumberOfDigits+1);
Integer(m_initialRank).serialize(buffer, k_initialRankNumberOfDigits+1);
if (m_firstInitialConditionName == nullptr
&& (m_type == Type::SingleRecurrence
|| m_type == Type::DoubleRecurrence))
@@ -270,7 +270,7 @@ Poincare::ExpressionLayout * Sequence::firstInitialConditionName() {
Poincare::ExpressionLayout * Sequence::secondInitialConditionName() {
char buffer[k_initialRankNumberOfDigits+1];
Integer(m_initialRank+1).writeTextInBuffer(buffer, k_initialRankNumberOfDigits+1);
Integer(m_initialRank+1).serialize(buffer, k_initialRankNumberOfDigits+1);
if (m_secondInitialConditionName == nullptr) {
if (m_type == Type::DoubleRecurrence) {
ExpressionLayout * indexLayout = LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Large);

View File

@@ -177,7 +177,7 @@ void SubController::willDisplayCellForIndex(HighlightCell * cell, int index) {
if (m_messageTreeModel->label() == I18n::Message::DisplayMode && index == numberOfRows()-1) {
MessageTableCellWithEditableText * myCell = (MessageTableCellWithEditableText *)cell;
char buffer[3];
Integer(Preferences::sharedPreferences()->numberOfSignificantDigits()).writeTextInBuffer(buffer, 3);
Integer(Preferences::sharedPreferences()->numberOfSignificantDigits()).serialize(buffer, 3);
myCell->setAccessoryText(buffer);
return;
}

View File

@@ -33,7 +33,7 @@ bool ExpressionFieldDelegateApp::layoutFieldDidReceiveEvent(LayoutField * layout
}
char buffer[TextField::maxBufferSize()];
int bufferSize = TextField::maxBufferSize();
int length = layoutField->writeTextInBuffer(buffer, bufferSize);
int length = layoutField->serialize(buffer, bufferSize);
Expression * exp = Expression::parse(buffer);
if (exp != nullptr) {
delete exp;

View File

@@ -17,7 +17,7 @@ inline int ConvertFloatToText(T d, char * buffer, int bufferSize, int numberOfSi
}
inline int WriteTextInBuffer(const Poincare::Expression * e, char * buffer, int bufferSize, int numberOfSignificantDigits = Poincare::PrintFloat::k_numberOfStoredSignificantDigits) {
return e->writeTextInBuffer(buffer, bufferSize, Poincare::Preferences::sharedPreferences()->displayMode(), numberOfSignificantDigits);
return e->serialize(buffer, bufferSize, Poincare::Preferences::sharedPreferences()->displayMode(), numberOfSignificantDigits);
}
template <class T>

View File

@@ -166,8 +166,8 @@ EquationStore::Error EquationStore::exactSolve(Poincare::Context * context) {
/* Check for identity between exact and approximate layouts */
char exactBuffer[Shared::ExpressionModel::k_expressionBufferSize];
char approximateBuffer[Shared::ExpressionModel::k_expressionBufferSize];
m_exactSolutionExactLayouts[i]->writeTextInBuffer(exactBuffer, Shared::ExpressionModel::k_expressionBufferSize);
m_exactSolutionApproximateLayouts[i]->writeTextInBuffer(approximateBuffer, Shared::ExpressionModel::k_expressionBufferSize);
m_exactSolutionExactLayouts[i]->serialize(exactBuffer, Shared::ExpressionModel::k_expressionBufferSize);
m_exactSolutionApproximateLayouts[i]->serialize(approximateBuffer, Shared::ExpressionModel::k_expressionBufferSize);
m_exactSolutionIdentity[i] = strcmp(exactBuffer, approximateBuffer) == 0;
/* Check for equality between exact and approximate layouts */
if (!m_exactSolutionIdentity[i]) {

View File

@@ -132,11 +132,11 @@ bool ListController::textFieldDidReceiveEvent(TextField * textField, Ion::Events
bool ListController::expressionLayoutFieldDidReceiveEvent(ExpressionLayoutField * expressionLayoutField, Ion::Events::Event event) {
if (expressionLayoutField->isEditing() && expressionLayoutField->expressionLayoutFieldShouldFinishEditing(event)) {
char buffer[TextField::maxBufferSize()];
expressionLayoutField->writeTextInBuffer(buffer, TextField::maxBufferSize());
expressionLayoutField->serialize(buffer, TextField::maxBufferSize());
if (!textRepresentsAnEquality(buffer)) {
expressionLayoutField->handleEvent(Ion::Events::ShiftRight);
expressionLayoutField->handleEventWithText("=0");
expressionLayoutField->writeTextInBuffer(buffer, TextField::maxBufferSize());
expressionLayoutField->serialize(buffer, TextField::maxBufferSize());
if (!textRepresentsAnEquality(buffer)) {
app()->displayWarning(I18n::Message::RequireEquation);
return true;

View File

@@ -40,7 +40,7 @@ void assert_equation_system_exact_solve_to(const char * equations[], EquationSto
}
int n = type == EquationStore::Type::PolynomialMonovariable ? numberOfSolutions+1 : numberOfSolutions; // Check Delta for PolynomialMonovariable
for (int i = 0; i < n; i++) {
equationStore.exactSolutionLayoutAtIndex(i, true)->writeTextInBuffer(buffer, 200);
equationStore.exactSolutionLayoutAtIndex(i, true)->serialize(buffer, 200);
translate_in_ASCII_chars(buffer);
assert(strcmp(buffer, solutions[i]) == 0);
}

View File

@@ -26,7 +26,7 @@ public:
}
void reload();
bool hasText() const { return layoutRef().hasText(); }
int writeTextInBuffer(char * buffer, int bufferLength) { return layoutRef().writeTextInBuffer(buffer, bufferLength); }
int serialize(char * buffer, int bufferLength) { return layoutRef().serialize(buffer, bufferLength); }
Poincare::LayoutRef layoutRef() const { return m_contentView.expressionView()->layoutRef(); }
char XNTChar() { return m_contentView.cursor()->layoutReference().XNTChar(); }

View File

@@ -11,7 +11,7 @@ void Clipboard::store(const char * storedText) {
}
void Clipboard::store(Poincare::LayoutRef layoutR) {
layoutR.writeTextInBuffer(m_textBuffer, TextField::maxBufferSize());
layoutR.serialize(m_textBuffer, TextField::maxBufferSize());
}
const char * Clipboard::storedText() {

View File

@@ -37,7 +37,7 @@ bool ExpressionField::isEditing() const {
const char * ExpressionField::text() {
if (!editionIsInTextField()) {
m_layoutField.writeTextInBuffer(m_textBuffer, m_textBufferLength);
m_layoutField.serialize(m_textBuffer, m_textBufferLength);
}
return m_textBuffer;
}

View File

@@ -174,8 +174,8 @@ bool ExpressionLayoutField::hasText() const {
return expressionLayout()->hasText();
}
int ExpressionLayoutField::writeTextInBuffer(char * buffer, int bufferLength) {
return expressionLayout()->writeTextInBuffer(buffer, bufferLength);
int ExpressionLayoutField::serialize(char * buffer, int bufferLength) {
return expressionLayout()->serialize(buffer, bufferLength);
}
bool ExpressionLayoutField::handleEventWithText(const char * text, bool indentation, bool forceCursorRightOfText) {

View File

@@ -16,7 +16,7 @@ private:
Expression setSign(Sign s, Context & context, Preferences::AngleUnit angleUnit) override;
/* Layout */
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "abs");
}
/* Simplification */

View File

@@ -8,7 +8,7 @@ namespace Poincare {
class AbsoluteValueLayoutNode : public BracketPairLayoutNode {
public:
using BracketPairLayoutNode::BracketPairLayoutNode;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return SerializationHelper::Prefix(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "abs");
}
// TreeNode

View File

@@ -30,11 +30,11 @@ public:
}
private:
/* Layout */
bool needsParenthesisWithParent(SerializableNode * parentNode) const override;
bool needsParenthesesWithParent(SerializableNode * parentNode) const override;
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Infix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
static const char * name() { return "+"; }

View File

@@ -21,7 +21,7 @@ public:
#endif
int numberOfChildren() const override { return 0; }
// LayoutNode
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
assert(false);
int descriptionLength = strlen(description()) + 1;
return strlcpy(buffer, description(), bufferSize < descriptionLength ? bufferSize : descriptionLength);

View File

@@ -16,7 +16,7 @@ public:
ExpressionNode::Type type() const override { return ExpressionNode::Type::AllocationFailure; }
Evaluation<float> approximate(ExpressionNode::SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override { return Complex<float>::Undefined(); }
Evaluation<double> approximate(ExpressionNode::DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override { return Complex<double>::Undefined(); }
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode = Preferences::PrintFloatMode::Decimal, int numberOfSignificantDigits = 0) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode = Preferences::PrintFloatMode::Decimal, int numberOfSignificantDigits = 0) const override {
if (bufferSize == 0) {
return -1;
}

View File

@@ -17,7 +17,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const {

View File

@@ -17,7 +17,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "asin"; }

View File

@@ -17,7 +17,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "atan"; }

View File

@@ -16,7 +16,7 @@ private:
constexpr static int k_maxNValue = 300;
/* Layout */
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "binomial");
}
/* Simplification */

View File

@@ -19,7 +19,7 @@ public:
void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
// SerializableNode
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
// TreeNode
size_t size() const override { return sizeof(BinomialCoefficientLayoutNode); }

View File

@@ -20,7 +20,7 @@ public:
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
void deleteBeforeCursor(LayoutCursor * cursor) override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
bool shouldCollapseSiblingsOnRight() const override{ return true; }
void didCollapseSiblings(LayoutCursor * cursor) override;

View File

@@ -14,7 +14,7 @@ public:
private:
/* Layout */
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "ceil"; }

View File

@@ -9,7 +9,7 @@ namespace Poincare {
class CeilingLayoutNode : public BracketPairLayoutNode {
public:
using BracketPairLayoutNode::BracketPairLayoutNode;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return SerializationHelper::Prefix(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "ceil");
}
// TreeNode

View File

@@ -23,7 +23,7 @@ public:
// LayoutNode
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
bool isCollapsable(int * numberOfOpenParenthesis, bool goingLeft) const override;
// TreeNode

View File

@@ -16,7 +16,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "arg"; }

View File

@@ -16,7 +16,7 @@ public:
* a view with no cursor. */
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override { assert(false); }
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override { assert(false); }
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return SerializationHelper::Prefix(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "sum");
}

View File

@@ -16,7 +16,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
virtual const char * name() const { return "confidence"; }

View File

@@ -14,7 +14,7 @@ public:
private:
/* Layout */
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "conj");
}
/* Simplification */

View File

@@ -14,7 +14,7 @@ public:
// LayoutNode
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
bool shouldCollapseSiblingsOnRight() const override { return true; }
// TreeNode

View File

@@ -21,7 +21,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "cos"; }

View File

@@ -44,9 +44,9 @@ public:
Expression shallowBeautify(Context& context, Preferences::AngleUnit angleUnit) override;
// Layout
bool needsParenthesisWithParent(SerializableNode * parentNode) const override;
bool needsParenthesesWithParent(SerializableNode * parentNode) const override;
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode = Preferences::PrintFloatMode::Decimal, int numberOfSignificantDigits = 0) const override;
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode = Preferences::PrintFloatMode::Decimal, int numberOfSignificantDigits = 0) const override;
private:
// Worst case is -1.2345678901234E-1000
constexpr static int k_maxBufferSize = PrintFloat::k_numberOfStoredSignificantDigits+1+1+1+1+4+1;

View File

@@ -17,7 +17,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "diff"; }

View File

@@ -15,7 +15,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "det"; }

View File

@@ -18,9 +18,9 @@ public:
int polynomialDegree(char symbolName) const override;
private:
/* Layout */
bool needsParenthesisWithParent(SerializableNode * parentNode) const override;
bool needsParenthesesWithParent(SerializableNode * parentNode) const override;
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "/");
}
/* Simplification */

View File

@@ -17,7 +17,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "quo"; }

View File

@@ -16,7 +16,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "rem"; }

View File

@@ -13,7 +13,7 @@ public:
Type type() const override {
return Type::EmptyExpression;
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
private:
/* Layout */
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;

View File

@@ -34,7 +34,7 @@ public:
void deleteBeforeCursor(LayoutCursor * cursor) override;
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
bool isEmpty() const override { return true; }
// TreeNode

View File

@@ -19,7 +19,7 @@ private:
Expression shallowReduce(Context& context, Preferences::AngleUnit angleUnit) override;
/* Layout */
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "=");
}
/* Evalutation */

View File

@@ -1,7 +1,6 @@
#ifndef POINCARE_EXPRESSION_REFERENCE_H
#define POINCARE_EXPRESSION_REFERENCE_H
#include <poincare/serializable_reference.h>
#include <poincare/tree_by_value.h>
#include <poincare/preferences.h>
#include <poincare/print_float.h>
@@ -13,7 +12,7 @@ namespace Poincare {
class Context;
class Expression : public SerializableReference, public TreeByValue {
class Expression : public TreeByValue {
friend class ExpressionNode;
friend class NAryExpressionNode;
friend class SymbolNode;
@@ -25,8 +24,8 @@ public:
/* Reference */
ExpressionNode * node() const override {
assert(!SerializableReference::node()->isGhost());
return static_cast<ExpressionNode *>(SerializableReference::node());
assert(!TreeByValue::node()->isGhost());
return static_cast<ExpressionNode *>(TreeByValue::node());
}
/* Circuit breaker */
@@ -89,7 +88,7 @@ public:
/* Layout Helper */
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return this->node()->createLayout(floatDisplayMode, numberOfSignificantDigits); }
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const { return this->node()->writeTextInBuffer(buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits); }
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const { return this->node()->serialize(buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits); }
/* Simplification */
static Expression ParseAndSimplify(const char * text, Context & context, Preferences::AngleUnit angleUnit);
@@ -112,7 +111,7 @@ public:
Coordinate2D nextIntersection(char symbol, double start, double step, double max, Context & context, Preferences::AngleUnit angleUnit, const Expression expression) const;
protected:
Expression(const ExpressionNode * n) : SerializableReference(n), TreeByValue(n) {}
Expression(const ExpressionNode * n) : TreeByValue(n) {}
/* Hierarchy */
Expression childAtIndex(int i) const {
return Expression(static_cast<ExpressionNode *>(TreeByReference::treeChildAtIndex(i).node()));

View File

@@ -1,9 +1,10 @@
#ifndef POINCARE_EXPRESSION_NODE_H
#define POINCARE_EXPRESSION_NODE_H
#include <poincare/serializable_node.h>
#include <poincare/tree_node.h>
#include <poincare/evaluation.h>
#include <poincare/layout_reference.h>
#include <poincare/serialization_helper_interface.h>
#include <poincare/context.h>
#include <stdint.h>
@@ -13,7 +14,7 @@ namespace Poincare {
* make 'this' outdated. They should only be call only be call in a wrapper on
* Expression. */
class ExpressionNode : public SerializableNode {
class ExpressionNode : public TreeNode, public SerializationHelperInterface {
friend class ApproximationHelper;
friend class SymbolNode;
friend class NAryExpressionNode;
@@ -157,8 +158,12 @@ protected:
/*!*/ virtual Expression cloneDenominator(Context & context, Preferences::AngleUnit angleUnit) const;
/* Hierarchy */
ExpressionNode * childAtIndex(int i) const override { return static_cast<ExpressionNode *>(SerializableNode::childAtIndex(i)); }
ExpressionNode * parent() const override { return static_cast<ExpressionNode *>(SerializableNode::parent()); }
ExpressionNode * childAtIndex(int i) const override { return static_cast<ExpressionNode *>(TreeNode::childAtIndex(i)); }
ExpressionNode * parent() const override { return static_cast<ExpressionNode *>(TreeNode::parent()); }
/* SerializationHelperInterface */
SerializationHelperInterface * serializableChildAtIndex(int i) const override { return childAtIndex(i); }
int numberOfSerializableChildren() const override { return numberOfChildren(); }
};
}

View File

@@ -18,7 +18,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "factor"; }

View File

@@ -13,9 +13,9 @@ public:
private:
constexpr static int k_maxOperandValue = 100;
/* Layout */
bool needsParenthesisWithParent(SerializableNode * parentNode) const override;
bool needsParenthesesWithParent(SerializableNode * parentNode) const override;
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
/* Simplication */
Expression shallowReduce(Context& context, Preferences::AngleUnit angleUnit) override;
Expression shallowBeautify(Context& context, Preferences::AngleUnit angleUnit) override;

View File

@@ -32,7 +32,7 @@ public:
Type type() const override { return Type::Float; }
// Layout
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
assert(false);
return 0;
}

View File

@@ -14,7 +14,7 @@ public:
private:
/* Layout */
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "floor"; }

View File

@@ -9,7 +9,7 @@ namespace Poincare {
class FloorLayoutNode : public BracketPairLayoutNode {
public:
using BracketPairLayoutNode::BracketPairLayoutNode;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return SerializationHelper::Prefix(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "floor");
}

View File

@@ -16,7 +16,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "frac"; }

View File

@@ -17,7 +17,7 @@ public:
void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
void deleteBeforeCursor(LayoutCursor * cursor) override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
bool shouldCollapseSiblingsOnLeft() const override { return true; }
bool shouldCollapseSiblingsOnRight() const override { return true; }
int leftCollapsingAbsorbingChildIndex() const override { return 0; }

View File

@@ -16,7 +16,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "gcd"; }

View File

@@ -34,7 +34,7 @@ public:
void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
// SerializableNode
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
assert(false);
return 0;
}

View File

@@ -29,7 +29,7 @@ public:
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
LayoutCursor equivalentCursor(LayoutCursor * cursor) override;
void deleteBeforeCursor(LayoutCursor * cursor) override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
bool isHorizontal() const override { return true; }
bool isEmpty() const override { return m_numberOfChildren == 1 && const_cast<HorizontalLayoutNode *>(this)->childAtIndex(0)->isEmpty(); }

View File

@@ -16,7 +16,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "acosh"; }

View File

@@ -16,7 +16,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "asinh"; }

View File

@@ -16,7 +16,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "atanh"; }

View File

@@ -17,7 +17,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "cosh"; }

View File

@@ -17,7 +17,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "sinh"; }

View File

@@ -17,7 +17,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "tanh"; }

View File

@@ -16,7 +16,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "im"; }

View File

@@ -33,7 +33,7 @@ public:
// Layout
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode = Preferences::PrintFloatMode::Decimal, int numberOfSignificantDigits = 0) const override;
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode = Preferences::PrintFloatMode::Decimal, int numberOfSignificantDigits = 0) const override;
private:
template<typename T> Evaluation<T> templatedApproximate() const;
bool m_negative;

View File

@@ -32,7 +32,7 @@ public:
size_t numberOfDigits() const { return m_numberOfDigits; }
// Layout
int writeTextInBuffer(char * buffer, int bufferSize) const;
int serialize(char * buffer, int bufferSize) const;
LayoutReference createLayout() const;
// Approximation
@@ -123,7 +123,7 @@ public:
// Layout
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode = Preferences::PrintFloatMode::Decimal, int numberOfSignificantDigits = 0) const override;
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode = Preferences::PrintFloatMode::Decimal, int numberOfSignificantDigits = 0) const override;
// TreeNode
size_t size() const override;

View File

@@ -15,7 +15,7 @@ public:
private:
/* Layout */
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "int");
}
/* Simplification */

View File

@@ -21,7 +21,7 @@ public:
void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
void deleteBeforeCursor(LayoutCursor * cursor) override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
LayoutNode * layoutToPointWhenInserting() override {
assert(lowerBoundLayout() != nullptr);
return lowerBoundLayout();

View File

@@ -1,7 +1,8 @@
#ifndef POINCARE_LAYOUT_NODE_H
#define POINCARE_LAYOUT_NODE_H
#include <poincare/serializable_node.h>
#include <poincare/tree_node.h>
#include <poincare/serialization_helper_interface.h>
#include <kandinsky.h>
#include <ion/charset.h>
@@ -22,7 +23,7 @@ class LayoutReference;
* We tackle this by not handling any event when the cursor points to an
* AllocationFailure layout. */
class LayoutNode : public SerializableNode {
class LayoutNode : public TreeNode, public SerializationHelperInterface {
friend class LayoutReference;
public:
enum class VerticalDirection {
@@ -32,7 +33,7 @@ public:
// Constructor
LayoutNode() :
SerializableNode(),
TreeNode(),
m_baseline(0),
m_frame(KDRectZero),
m_baselined(false),
@@ -49,6 +50,10 @@ public:
KDCoordinate baseline();
virtual void invalidAllSizesPositionsAndBaselines();
// SerializationHelperInterface
SerializationHelperInterface * serializableChildAtIndex(int i) const override { return childAtIndex(i); }
int numberOfSerializableChildren() const override { return numberOfChildren(); }
// TreeNode
static TreeNode * FailedAllocationStaticNode();
TreeNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }

View File

@@ -2,21 +2,20 @@
#define POINCARE_LAYOUT_REFERENCE_H
#include <poincare/layout_node.h>
#include <poincare/serializable_reference.h>
#include <poincare/tree_by_reference.h>
namespace Poincare {
class LayoutCursor;
class LayoutReference : public SerializableReference {
class LayoutReference : public TreeByReference {
friend class LayoutCursor;
public:
using TreeByReference::operator==;
using TreeByReference::operator!=;
LayoutReference(LayoutNode * node) :
TreeByReference(node),
SerializableReference(node) {}
TreeByReference(node) {}
LayoutReference clone() const {
TreeByReference c = TreeByReference::clone();
@@ -26,8 +25,8 @@ public:
}
LayoutNode * node() const override {
assert(!SerializableReference::node()->isGhost());
return static_cast<LayoutNode *>(SerializableReference::node());
assert(!TreeByReference::node()->isGhost());
return static_cast<LayoutNode *>(TreeByReference::node());
}
// Rendering

View File

@@ -16,7 +16,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "lcm"; }

View File

@@ -17,7 +17,7 @@ public:
bool isLeftParenthesis() const override { return true; }
// Serializable Node
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return SerializationHelper::Char(buffer, bufferSize, '(');
}

View File

@@ -9,7 +9,7 @@ namespace Poincare {
class LeftSquareBracketLayoutNode : public SquareBracketLayoutNode {
public:
using SquareBracketLayoutNode::SquareBracketLayoutNode;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return SerializationHelper::Char(buffer, bufferSize, '[');
}
bool isLeftBracket() const override { return true; }

View File

@@ -15,7 +15,7 @@ public:
private:
/* Layout */
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "log");
}
/* Simplification */

View File

@@ -40,7 +40,7 @@ public:
// Layout
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode = Preferences::PrintFloatMode::Decimal, int numberOfSignificantDigits = 0) const override;
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode = Preferences::PrintFloatMode::Decimal, int numberOfSignificantDigits = 0) const override;
private:
template<typename T> Evaluation<T> templatedApproximate(Context& context, Preferences::AngleUnit angleUnit) const;
int m_numberOfRows;

View File

@@ -15,7 +15,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "dim"; }

View File

@@ -15,7 +15,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "inverse"; }

View File

@@ -26,7 +26,7 @@ public:
bool isMatrix() const override { return true; }
// SerializableNode
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
// TreeNode
size_t size() const override { return sizeof(MatrixLayoutNode); }

View File

@@ -16,7 +16,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "trace"; }

View File

@@ -15,7 +15,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "transpose"; }

View File

@@ -34,9 +34,9 @@ private:
/* Property */
Expression setSign(Sign s, Context & context, Preferences::AngleUnit angleUnit) override;
/* Layout */
bool needsParenthesisWithParent(SerializableNode * parentNode) const override;
bool needsParenthesesWithParent(SerializableNode * parentNode) const override;
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
/* Simplification */
Expression shallowReduce(Context& context, Preferences::AngleUnit angleUnit) override;
Expression * privateShallowReduce(Context& context, Preferences::AngleUnit angleUnit, bool expand, bool canBeInterrupted);

View File

@@ -16,7 +16,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "ln"; }

View File

@@ -13,7 +13,7 @@ public:
private:
/* Layout */
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, "root");
}
/* Simplification */

View File

@@ -26,7 +26,7 @@ public:
void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
void deleteBeforeCursor(LayoutCursor * cursor) override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
bool shouldCollapseSiblingsOnRight() const override { return true; }
bool hasUpperLeftIndex() const override { return m_hasIndex; }

View File

@@ -33,9 +33,9 @@ public:
}
// Layout
bool needsParenthesisWithParent(SerializableNode * parentNode) const override;
bool needsParenthesesWithParent(SerializableNode * parentNode) const override;
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode = Preferences::PrintFloatMode::Decimal, int numberOfSignificantDigits = 0) const override;
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode = Preferences::PrintFloatMode::Decimal, int numberOfSignificantDigits = 0) const override;
// Simplification
virtual Expression shallowReduce(Context& context, Preferences::AngleUnit angleUnit) const override;

View File

@@ -23,7 +23,7 @@ public:
// Layout
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
// Simplification
Expression shallowReduce(Context& context, Preferences::AngleUnit angleUnit) override;

View File

@@ -17,7 +17,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "permute"; }

View File

@@ -31,8 +31,8 @@ private:
Expression setSign(Sign s, Context & context, Preferences::AngleUnit angleUnit) override;
/* Layout */
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
bool needsParenthesisWithParent(SerializableNode * parentNode) const override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
bool needsParenthesesWithParent(SerializableNode * parentNode) const override;
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
static const char * name() { return "^"; }

View File

@@ -16,7 +16,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "prediction95"; }

View File

@@ -9,7 +9,7 @@ namespace Poincare {
class ProductLayoutNode : public SequenceLayoutNode {
public:
using SequenceLayoutNode::SequenceLayoutNode;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
size_t size() const override { return sizeof(ProductLayoutNode); }
#if TREE_LOG
const char * description() const override { return "ProductLayout"; }

View File

@@ -15,7 +15,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "randint"; }

View File

@@ -19,7 +19,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "random"; }

View File

@@ -19,8 +19,8 @@ public:
#endif
// Serialization Node
bool needsParenthesisWithParent(SerializableNode * e) const override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
bool needsParenthesesWithParent(SerializableNode * e) const override;
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
// Expression subclassing
Type type() const override { return Type::Rational; }

View File

@@ -16,7 +16,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "re"; }

View File

@@ -17,7 +17,7 @@ public:
bool isRightParenthesis() const override { return true; }
// SerializableNode
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return SerializationHelper::Char(buffer, bufferSize, ')');
}

View File

@@ -9,7 +9,7 @@ namespace Poincare {
class RightSquareBracketLayoutNode : public SquareBracketLayoutNode {
public:
using SquareBracketLayoutNode::SquareBracketLayoutNode;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return SerializationHelper::Char(buffer, bufferSize, ']');
}
bool isRightBracket() const override { return true; }

View File

@@ -16,7 +16,7 @@ private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::Prefix(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "round"; }

View File

@@ -11,7 +11,7 @@ class Sequence : public StaticHierarchy<3> {
using StaticHierarchy<3>::StaticHierarchy;
private:
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutHelper::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
virtual LayoutRef createSequenceLayout(LayoutRef subscriptLayout, LayoutRef superscriptLayout, LayoutRef argumentLayout) const = 0;

View File

@@ -1,19 +0,0 @@
#ifndef POINCARE_SERIALIZABLE_NODE_H
#define POINCARE_SERIALIZABLE_NODE_H
#include <poincare/tree_node.h>
#include <poincare/preferences.h>
namespace Poincare {
class SerializableNode : public TreeNode {
public:
using TreeNode::TreeNode;
virtual bool needsParenthesisWithParent(SerializableNode * parentNode) const { return false; } //TODO
virtual int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode = Preferences::PrintFloatMode::Decimal, int numberOfSignificantDigits = 0) const = 0;
};
}
#endif

View File

@@ -1,34 +0,0 @@
#ifndef POINCARE_SERIALIZABLE_REFERENCE_H
#define POINCARE_SERIALIZABLE_REFERENCE_H
#include <poincare/preferences.h>
#include <poincare/tree_by_reference.h>
#include <poincare/serializable_node.h>
namespace Poincare {
class SerializableReference : virtual public TreeByReference {
public:
SerializableNode * node() const override { return static_cast<SerializableNode *>(TreeByReference::node()); }
// Serialization
bool needsParenthesisWithParent(SerializableReference parentRef) {
assert(isDefined());
return node()->needsParenthesisWithParent(parentRef.node());
}
int writeTextInBuffer(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode = Preferences::PrintFloatMode::Decimal, int numberOfSignificantDigits = 0) const {
assert(isDefined());
return node()->writeTextInBuffer(buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits);
}
// Tree
SerializableReference serializableChildAtIndex(int i) {
TreeByReference treeRefChild = TreeByReference::treeChildAtIndex(i);
return SerializableReference(static_cast<SerializableNode *>(treeRefChild.node()));
}
protected:
SerializableReference(const SerializableNode * n) : TreeByReference(n) {}
};
}
#endif

Some files were not shown because too many files have changed in this diff Show More