mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 22:00:28 +01:00
[poincare] Implement SerializationHelper and
SerializationHelperInterface. WriteTextInBuffer->serialize
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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]) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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(); }
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 "+"; }
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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); }
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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()));
|
||||
|
||||
@@ -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(); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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(); }
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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(); }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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, '(');
|
||||
}
|
||||
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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); }
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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 "^"; }
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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, ')');
|
||||
}
|
||||
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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"; }
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
@@ -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
Reference in New Issue
Block a user