[Sequence & Shared] Changed the location of various files

Moved sequences files to shared in order to allow the system to compile
without the app sequence.

Change-Id: Ia8349814a72776244acc41af964059f24e58cff0
This commit is contained in:
Arthur Camouseigt
2020-07-23 17:41:55 +02:00
committed by Émilie Feral
parent ed358590ce
commit c006ed7b10
33 changed files with 103 additions and 93 deletions

View File

@@ -2,10 +2,7 @@ apps += Sequence::App
app_headers += apps/sequence/app.h
app_sequence_test_src = $(addprefix apps/sequence/,\
cache_context.cpp \
sequence.cpp \
sequence_context.cpp \
sequence_store.cpp \
\
)
app_sequence_src = $(addprefix apps/sequence/,\
@@ -22,7 +19,6 @@ app_sequence_src = $(addprefix apps/sequence/,\
list/type_parameter_controller.cpp \
values/interval_parameter_controller.cpp \
values/values_controller.cpp \
sequence_title_cell.cpp \
)
app_sequence_src += $(app_sequence_test_src)

View File

@@ -64,7 +64,7 @@ App::App(Snapshot * snapshot) :
{
}
SequenceContext * App::localContext() {
Shared::SequenceContext * App::localContext() {
return &m_sequenceContext;
}

View File

@@ -2,8 +2,8 @@
#define SEQUENCE_APP_H
#include <escher.h>
#include "sequence_context.h"
#include "sequence_store.h"
#include "../shared/sequence_context.h"
#include "../shared/sequence_store.h"
#include "graph/graph_controller.h"
#include "graph/curve_view_range.h"
#include "list/list_controller.h"
@@ -27,12 +27,12 @@ public:
App * unpack(Container * container) override;
void reset() override;
Descriptor * descriptor() override;
SequenceStore * functionStore() override { return &m_sequenceStore; }
Shared::SequenceStore * functionStore() override { return &m_sequenceStore; }
CurveViewRange * graphRange() { return &m_graphRange; }
Shared::Interval * interval() { return &m_interval; }
private:
void tidy() override;
SequenceStore m_sequenceStore;
Shared::SequenceStore m_sequenceStore;
CurveViewRange m_graphRange;
Shared::Interval m_interval;
};
@@ -46,8 +46,8 @@ public:
// TODO: override variableBoxForInputEventHandler to lock sequence in the variable box once they appear there
// NestedMenuController * variableBoxForInputEventHandler(InputEventHandler * textInput) override;
CodePoint XNT() override { return 'n'; }
SequenceContext * localContext() override;
SequenceStore * functionStore() override { return snapshot()->functionStore(); }
Shared::SequenceContext * localContext() override;
Shared::SequenceStore * functionStore() override { return snapshot()->functionStore(); }
Shared::Interval * interval() { return snapshot()->interval(); }
ValuesController * valuesController() override {
return &m_valuesController;
@@ -57,7 +57,7 @@ public:
}
private:
App(Snapshot * snapshot);
SequenceContext m_sequenceContext;
Shared::SequenceContext m_sequenceContext;
ListController m_listController;
ButtonRowController m_listFooter;
ButtonRowController m_listHeader;

View File

@@ -1,6 +1,7 @@
#include "curve_parameter_controller.h"
#include "graph_controller.h"
#include <assert.h>
#include <apps/i18n.h>
using namespace Shared;

View File

@@ -5,6 +5,7 @@
#include <float.h>
#include <cmath>
#include <algorithm>
#include <apps/i18n.h>
using namespace Shared;
using namespace Poincare;
@@ -38,7 +39,7 @@ float GraphController::interestingXMin() const {
int nmin = INT_MAX;
int nbOfActiveModels = functionStore()->numberOfActiveFunctions();
for (int i = 0; i < nbOfActiveModels; i++) {
Sequence * s = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(i));
Shared::Sequence * s = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(i));
nmin = std::min(nmin, s->initialRank());
}
assert(nmin < INT_MAX);
@@ -50,7 +51,7 @@ void GraphController::interestingRanges(InteractiveCurveViewRange * range) const
int nmax = 0;
int nbOfActiveModels = functionStore()->numberOfActiveFunctions();
for (int i = 0; i < nbOfActiveModels; i++) {
Sequence * s = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(i));
Shared::Sequence * s = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(i));
int firstInterestingIndex = s->initialRank();
nmin = std::min(nmin, firstInterestingIndex);
nmax = std::max(nmax, firstInterestingIndex + static_cast<int>(k_defaultXHalfRange));
@@ -95,7 +96,7 @@ bool GraphController::moveCursorHorizontally(int direction, int scrollSpeed) {
if (x < 0.0) {
return false;
}
Sequence * s = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(indexFunctionSelectedByCursor()));
Shared::Sequence * s = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(indexFunctionSelectedByCursor()));
double y = s->evaluateXYAtParameter(x, textFieldDelegateApp()->localContext()).x2();
m_cursor->moveTo(x, x, y);
return true;

View File

@@ -8,13 +8,13 @@
#include "term_sum_controller.h"
#include "../../shared/function_graph_controller.h"
#include "../../shared/cursor_view.h"
#include "../sequence_store.h"
#include "../../shared/sequence_store.h"
namespace Sequence {
class GraphController final : public Shared::FunctionGraphController {
public:
GraphController(Responder * parentResponder, ::InputEventHandlerDelegate * inputEventHandlerDelegate, SequenceStore * sequenceStore, CurveViewRange * graphRange, Shared::CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * modelVersion, uint32_t * previousModelsVersions, uint32_t * rangeVersion, Poincare::Preferences::AngleUnit * angleUnitVersion, ButtonRowController * header);
GraphController(Responder * parentResponder, ::InputEventHandlerDelegate * inputEventHandlerDelegate, Shared::SequenceStore * sequenceStore, CurveViewRange * graphRange, Shared::CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * modelVersion, uint32_t * previousModelsVersions, uint32_t * rangeVersion, Poincare::Preferences::AngleUnit * angleUnitVersion, ButtonRowController * header);
I18n::Message emptyMessage() override;
void viewWillAppear() override;
TermSumController * termSumController() { return &m_termSumController; }
@@ -28,7 +28,7 @@ private:
bool moveCursorHorizontally(int direction, int scrollSpeed = 1) override;
double defaultCursorT(Ion::Storage::Record record) override;
CurveViewRange * interactiveCurveViewRange() override { return m_graphRange; }
SequenceStore * functionStore() const override { return static_cast<SequenceStore *>(Shared::FunctionGraphController::functionStore()); }
Shared::SequenceStore * functionStore() const override { return static_cast<Shared::SequenceStore *>(Shared::FunctionGraphController::functionStore()); }
GraphView * functionGraphView() override { return &m_view; }
CurveParameterController * curveParameterController() override { return &m_curveParameterController; }
Shared::CursorView m_cursorView;

View File

@@ -19,7 +19,7 @@ void GraphView::drawRect(KDContext * ctx, KDRect rect) const {
const int step = std::ceil(pixelWidth());
for (int i = 0; i < m_sequenceStore->numberOfActiveFunctions(); i++) {
Ion::Storage::Record record = m_sequenceStore->activeRecordAtIndex(i);
Sequence * s = m_sequenceStore->modelForRecord(record);;
Shared::Sequence * s = m_sequenceStore->modelForRecord(record);;
float rectXMin = pixelToFloat(Axis::Horizontal, rect.left() - k_externRectMargin);
rectXMin = rectXMin < 0 ? 0 : rectXMin;
float rectXMax = pixelToFloat(Axis::Horizontal, rect.right() + k_externRectMargin);

View File

@@ -2,17 +2,17 @@
#define SEQUENCE_GRAPH_VIEW_H
#include "../../shared/function_graph_view.h"
#include "../sequence_store.h"
#include "../../shared/sequence_store.h"
namespace Sequence {
class GraphView : public Shared::FunctionGraphView {
public:
GraphView(SequenceStore * sequenceStore, Shared::InteractiveCurveViewRange * graphRange,
GraphView(Shared::SequenceStore * sequenceStore, Shared::InteractiveCurveViewRange * graphRange,
Shared::CurveViewCursor * cursor, Shared::BannerView * bannerView, Shared::CursorView * cursorView);
void drawRect(KDContext * ctx, KDRect rect) const override;
private:
SequenceStore * m_sequenceStore;
Shared::SequenceStore * m_sequenceStore;
};
}

View File

@@ -49,7 +49,7 @@ double TermSumController::cursorNextStep(double x, int direction) {
}
Layout TermSumController::createFunctionLayout(Shared::ExpiringPointer<Shared::Function> function) {
Sequence * sequence = static_cast<Sequence *>(function.pointer());
Shared::Sequence * sequence = static_cast<Shared::Sequence *>(function.pointer());
return sequence->nameLayout();
}

View File

@@ -2,6 +2,7 @@
#include "../app.h"
#include <assert.h>
#include <algorithm>
#include <apps/i18n.h>
using namespace Shared;
using namespace Poincare;
@@ -31,7 +32,7 @@ int ListController::numberOfExpressionRows() const {
SequenceStore * store = const_cast<ListController *>(this)->modelStore();
const int modelsCount = store->numberOfModels();
for (int i = 0; i < modelsCount; i++) {
Sequence * sequence = store->modelForRecord(store->recordAtIndex(i));
Shared::Sequence * sequence = store->modelForRecord(store->recordAtIndex(i));
numberOfRows += sequence->numberOfElements();
}
return numberOfRows + (modelsCount == store->maxNumberOfModels()? 0 : 1);
@@ -42,7 +43,7 @@ KDCoordinate ListController::expressionRowHeight(int j) {
if (isAddEmptyRow(j)) {
return defaultHeight;
}
Sequence * sequence = modelStore()->modelForRecord(modelStore()->recordAtIndex(modelIndexForRow(j)));
Shared::Sequence * sequence = modelStore()->modelForRecord(modelStore()->recordAtIndex(modelIndexForRow(j)));
Layout layout = sequence->layout();
if (sequenceDefinitionForRow(j) == 1) {
layout = sequence->firstInitialConditionLayout();
@@ -67,7 +68,7 @@ Toolbox * ListController::toolboxForInputEventHandler(InputEventHandler * textIn
// Set extra cells
int recurrenceDepth = -1;
int sequenceDefinition = sequenceDefinitionForRow(selectedRow());
Sequence * sequence = modelStore()->modelForRecord(modelStore()->recordAtIndex(modelIndexForRow(selectedRow())));
Shared::Sequence * sequence = modelStore()->modelForRecord(modelStore()->recordAtIndex(modelIndexForRow(selectedRow())));
if (sequenceDefinition == 0) {
recurrenceDepth = sequence->numberOfElements()-1;
}
@@ -85,7 +86,7 @@ void ListController::selectPreviousNewSequenceCell() {
void ListController::editExpression(int sequenceDefinition, Ion::Events::Event event) {
Ion::Storage::Record record = modelStore()->recordAtIndex(modelIndexForRow(selectedRow()));
Sequence * sequence = modelStore()->modelForRecord(record);
Shared::Sequence * sequence = modelStore()->modelForRecord(record);
InputViewController * inputController = Shared::FunctionApp::app()->inputViewController();
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
char initialTextContent[Constant::MaxSerializedExpressionSize];
@@ -147,7 +148,7 @@ bool ListController::editInitialConditionOfSelectedRecordWithText(const char * t
// Reset memoization of the selected cell which always corresponds to the k_memoizedCellsCount/2 memoized cell
resetMemoizationForIndex(k_memoizedCellsCount/2);
Ion::Storage::Record record = modelStore()->recordAtIndex(modelIndexForRow(selectedRow()));
Sequence * sequence = modelStore()->modelForRecord(record);
Shared::Sequence * sequence = modelStore()->modelForRecord(record);
Context * context = App::app()->localContext();
Ion::Storage::Record::ErrorStatus error = firstInitialCondition? sequence->setFirstInitialConditionContent(text, context) : sequence->setSecondInitialConditionContent(text, context);
return (error == Ion::Storage::Record::ErrorStatus::None);
@@ -179,7 +180,7 @@ void ListController::willDisplayTitleCellAtIndex(HighlightCell * cell, int j) {
myCell->setBaseline(baseline(j));
// Set the layout
Ion::Storage::Record record = modelStore()->recordAtIndex(modelIndexForRow(j));
Sequence * sequence = modelStore()->modelForRecord(record);
Shared::Sequence * sequence = modelStore()->modelForRecord(record);
if (sequenceDefinitionForRow(j) == 0) {
myCell->setLayout(sequence->definitionName());
}
@@ -197,7 +198,7 @@ void ListController::willDisplayTitleCellAtIndex(HighlightCell * cell, int j) {
void ListController::willDisplayExpressionCellAtIndex(HighlightCell * cell, int j) {
FunctionExpressionCell * myCell = (FunctionExpressionCell *)cell;
Ion::Storage::Record record = modelStore()->recordAtIndex(modelIndexForRow(j));
Sequence * sequence = modelStore()->modelForRecord(record);
Shared::Sequence * sequence = modelStore()->modelForRecord(record);
if (sequenceDefinitionForRow(j) == 0) {
myCell->setLayout(sequence->layout());
}
@@ -223,7 +224,7 @@ int ListController::modelIndexForRow(int j) {
int sequenceIndex = -1;
do {
sequenceIndex++;
Sequence * sequence = modelStore()->modelForRecord(modelStore()->recordAtIndex(sequenceIndex));
Shared::Sequence * sequence = modelStore()->modelForRecord(modelStore()->recordAtIndex(sequenceIndex));
rowIndex += sequence->numberOfElements();
} while (rowIndex <= j);
return sequenceIndex;
@@ -238,7 +239,7 @@ int ListController::sequenceDefinitionForRow(int j) {
}
int rowIndex = 0;
int sequenceIndex = -1;
Sequence * sequence;
Shared::Sequence * sequence;
do {
sequenceIndex++;
sequence = modelStore()->modelForRecord(modelStore()->recordAtIndex(sequenceIndex));
@@ -259,7 +260,7 @@ void ListController::editExpression(Ion::Events::Event event) {
void ListController::reinitSelectedExpression(ExpiringPointer<ExpressionModelHandle> model) {
// Invalidate the sequences context cache
App::app()->localContext()->resetCache();
Sequence * sequence = static_cast<Sequence *>(model.pointer());
Shared::Sequence * sequence = static_cast<Shared::Sequence *>(model.pointer());
switch (sequenceDefinitionForRow(selectedRow())) {
case 1:
if (sequence->firstInitialConditionExpressionClone().isUninitialized()) {

View File

@@ -2,8 +2,8 @@
#define SEQUENCE_LIST_CONTROLLER_H
#include <escher.h>
#include "../sequence_title_cell.h"
#include "../sequence_store.h"
#include "../../shared/sequence_title_cell.h"
#include "../../shared/sequence_store.h"
#include "../../shared/function_expression_cell.h"
#include "../../shared/function_list_controller.h"
#include "../../shared/input_event_handler_delegate.h"
@@ -40,9 +40,9 @@ private:
void reinitSelectedExpression(Shared::ExpiringPointer<Shared::ExpressionModelHandle> model) override;
void editExpression(Ion::Events::Event event) override;
bool removeModelRow(Ion::Storage::Record record) override;
SequenceStore * modelStore() override;
constexpr static int k_maxNumberOfRows = 3*MaxNumberOfSequences;
SequenceTitleCell m_sequenceTitleCells[k_maxNumberOfRows];
Shared::SequenceStore * modelStore() override;
constexpr static int k_maxNumberOfRows = 3*Shared::MaxNumberOfSequences;
Shared::SequenceTitleCell m_sequenceTitleCells[k_maxNumberOfRows];
Shared::FunctionExpressionCell m_expressionCells[k_maxNumberOfRows];
ListParameterController m_parameterController;
TypeParameterController m_typeParameterController;

View File

@@ -2,6 +2,7 @@
#include "list_controller.h"
#include "../app.h"
#include "../../shared/poincare_helpers.h"
#include <apps/i18n.h>
using namespace Poincare;
using namespace Shared;
@@ -67,7 +68,7 @@ bool ListParameterController::textFieldShouldFinishEditing(TextField * textField
}
bool ListParameterController::textFieldDidFinishEditing(TextField * textField, const char * text, Ion::Events::Event event) {
static float maxFirstIndex = std::pow(10.0f, Sequence::k_initialRankNumberOfDigits) - 1.0f;
static float maxFirstIndex = std::pow(10.0f, Shared::Sequence::k_initialRankNumberOfDigits) - 1.0f;
/* -1 to take into account a double recursive sequence, which has
* SecondIndex = FirstIndex + 1 */
double floatBody;
@@ -141,8 +142,8 @@ void ListParameterController::willDisplayCellForIndex(HighlightCell * cell, int
if (myCell->isEditing()) {
return;
}
char buffer[Sequence::k_initialRankNumberOfDigits+1];
Poincare::Integer(sequence()->initialRank()).serialize(buffer, Sequence::k_initialRankNumberOfDigits+1);
char buffer[Shared::Sequence::k_initialRankNumberOfDigits+1];
Poincare::Integer(sequence()->initialRank()).serialize(buffer, Shared::Sequence::k_initialRankNumberOfDigits+1);
myCell->setAccessoryText(buffer);
}
}
@@ -155,7 +156,7 @@ int ListParameterController::totalNumberOfCells() const {
};
bool ListParameterController::hasInitialRankRow() const {
return !m_record.isNull() && const_cast<ListParameterController *>(this)->sequence()->type() != Sequence::Type::Explicit;
return !m_record.isNull() && const_cast<ListParameterController *>(this)->sequence()->type() != Shared::Sequence::Type::Explicit;
}
}

View File

@@ -3,8 +3,8 @@
#include "../../shared/list_parameter_controller.h"
#include "../../shared/parameter_text_field_delegate.h"
#include "../sequence.h"
#include "../sequence_store.h"
#include "../../shared/sequence.h"
#include "../../shared/sequence_store.h"
#include "type_parameter_controller.h"
namespace Sequence {
@@ -31,7 +31,7 @@ private:
constexpr static int k_totalNumberOfCell = 4;
#endif
int totalNumberOfCells() const override;
Sequence * sequence() { return static_cast<Sequence *>(function().pointer()); }
Shared::Sequence * sequence() { return static_cast<Shared::Sequence *>(function().pointer()); }
bool hasInitialRankRow() const;
MessageTableCellWithChevronAndExpression m_typeCell;
MessageTableCellWithEditableText m_initialRankCell;

View File

@@ -1,5 +1,5 @@
#include "sequence_toolbox.h"
#include "../sequence_store.h"
#include "../../shared/sequence_store.h"
#include <poincare/layout_helper.h>
#include <assert.h>
#include <poincare/code_point_layout.h>
@@ -75,8 +75,8 @@ void SequenceToolbox::buildExtraCellsLayouts(const char * sequenceName, int recu
* There is a special case for double recurrent sequences because we do not
* want to parse symbols u(n+2), v(n+2) or w(n+2). */
m_numberOfAddedCells = 0;
int sequenceIndex = SequenceStore::sequenceIndexForName(sequenceName[0]);
for (int i = 0; i < MaxNumberOfSequences; i++) {
int sequenceIndex = Shared::SequenceStore::sequenceIndexForName(sequenceName[0]);
for (int i = 0; i < Shared::MaxNumberOfSequences; i++) {
for (int j = 0; j < recurrenceDepth+1; j++) {
// When defining u(n+1) for ex, don't add [u|v|w](n+2) or u(n+1)
if (j == 2 || (j == recurrenceDepth && sequenceIndex == i)) {
@@ -84,7 +84,7 @@ void SequenceToolbox::buildExtraCellsLayouts(const char * sequenceName, int recu
}
const char * indice = j == 0 ? "n" : "n+1";
m_addedCellLayout[m_numberOfAddedCells++] = HorizontalLayout::Builder(
CodePointLayout::Builder(SequenceStore::k_sequenceNames[i][0], KDFont::LargeFont),
CodePointLayout::Builder(Shared::SequenceStore::k_sequenceNames[i][0], KDFont::LargeFont),
VerticalOffsetLayout::Builder(LayoutHelper::String(indice, strlen(indice), KDFont::LargeFont), VerticalOffsetLayoutNode::Position::Subscript)
);
}

View File

@@ -5,6 +5,7 @@
#include <poincare/layout_helper.h>
#include <poincare/code_point_layout.h>
#include <poincare/vertical_offset_layout.h>
#include <apps/i18n.h>
using namespace Poincare;
using namespace Shared;
@@ -55,14 +56,14 @@ void TypeParameterController::didBecomeFirstResponder() {
bool TypeParameterController::handleEvent(Ion::Events::Event event) {
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
if (!m_record.isNull()) {
Sequence::Type sequenceType = (Sequence::Type)selectedRow();
Shared::Sequence::Type sequenceType = (Shared::Sequence::Type)selectedRow();
if (sequence()->type() != sequenceType) {
m_listController->selectPreviousNewSequenceCell();
sequence()->setType(sequenceType);
// Invalidate sequence context cache when changing sequence type
App::app()->localContext()->resetCache();
// Reset the first index if the new type is "Explicit"
if (sequenceType == Sequence::Type::Explicit) {
if (sequenceType == Shared::Sequence::Type::Explicit) {
sequence()->setInitialRank(0);
}
}
@@ -79,8 +80,8 @@ bool TypeParameterController::handleEvent(Ion::Events::Event event) {
}
assert(error == Ion::Storage::Record::ErrorStatus::None);
Ion::Storage::Record record = sequenceStore()->recordAtIndex(sequenceStore()->numberOfModels()-1);
Sequence * newSequence = sequenceStore()->modelForRecord(record);
newSequence->setType((Sequence::Type)selectedRow());
Shared::Sequence * newSequence = sequenceStore()->modelForRecord(record);
newSequence->setType((Shared::Sequence::Type)selectedRow());
Container::activeApp()->dismissModalViewController();
m_listController->editExpression(0, Ion::Events::OK);
return true;

View File

@@ -3,7 +3,7 @@
#include <escher.h>
#include <poincare/layout.h>
#include "../sequence_store.h"
#include "../../shared/sequence_store.h"
namespace Sequence {
@@ -28,11 +28,11 @@ public:
void setRecord(Ion::Storage::Record record);
private:
StackViewController * stackController() const;
Sequence * sequence() {
Shared::Sequence * sequence() {
assert(!m_record.isNull());
return sequenceStore()->modelForRecord(m_record);
}
SequenceStore * sequenceStore();
Shared::SequenceStore * sequenceStore();
constexpr static int k_totalNumberOfCell = 3;
ExpressionTableCellWithPointer m_explicitCell;
ExpressionTableCellWithPointer m_singleRecurrenceCell;

View File

@@ -3,14 +3,13 @@
#include <string.h>
#include <assert.h>
#include <cmath>
#include "../sequence_store.h"
#include "../sequence_context.h"
#include "../../shared/sequence_store.h"
#include "../../shared/sequence_context.h"
#include "../../shared/poincare_helpers.h"
using namespace Poincare;
using namespace Shared;
namespace Sequence {
namespace Shared {
Sequence * addSequence(SequenceStore * store, Sequence::Type type, const char * definition, const char * condition1, const char * condition2, Context * context) {
Ion::Storage::Record::ErrorStatus err = store->addEmptyModel();

View File

@@ -3,6 +3,7 @@
#include <cmath>
#include "../../shared/poincare_helpers.h"
#include "../app.h"
#include <apps/i18n.h>
using namespace Poincare;
@@ -51,8 +52,8 @@ void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, in
return;
}
if (typeAtLocation(i,j) == k_functionTitleCellType) {
SequenceTitleCell * myCell = (SequenceTitleCell *)cell;
Sequence * sequence = functionStore()->modelForRecord(recordAtColumn(i));
Shared::SequenceTitleCell * myCell = (Shared::SequenceTitleCell *)cell;
Shared::Sequence * sequence = functionStore()->modelForRecord(recordAtColumn(i));
myCell->setLayout(sequence->nameLayout());
myCell->setColor(sequence->color());
}
@@ -95,7 +96,7 @@ Shared::Interval * ValuesController::intervalAtColumn(int columnIndex) {
void ValuesController::fillMemoizedBuffer(int column, int row, int index) {
char * buffer = memoizedBufferAtIndex(index);
double abscissa = intervalAtColumn(column)->element(row-1); // Subtract the title row from row to get the element index
Shared::ExpiringPointer<Sequence> sequence = functionStore()->modelForRecord(recordAtColumn(column));
Shared::ExpiringPointer<Shared::Sequence> sequence = functionStore()->modelForRecord(recordAtColumn(column));
Coordinate2D<double> xy = sequence->evaluateXYAtParameter(abscissa, textFieldDelegateApp()->localContext());
Shared::PoincareHelpers::ConvertFloatToText<double>(xy.x2(), buffer, k_valuesCellBufferSize, Preferences::LargeNumberOfSignificantDigits);
}

View File

@@ -1,8 +1,8 @@
#ifndef SEQUENCE_VALUES_CONTROLLER_H
#define SEQUENCE_VALUES_CONTROLLER_H
#include "../sequence_store.h"
#include "../sequence_title_cell.h"
#include "../../shared/sequence_store.h"
#include "../../shared/sequence_title_cell.h"
#include "../../shared/values_controller.h"
#include "interval_parameter_controller.h"
@@ -46,7 +46,7 @@ private:
bool setDataAtLocation(double floatBody, int columnIndex, int rowIndex) override;
// Model getters
SequenceStore * functionStore() const override { return static_cast<SequenceStore *>(Shared::ValuesController::functionStore()); }
Shared::SequenceStore * functionStore() const override { return static_cast<Shared::SequenceStore *>(Shared::ValuesController::functionStore()); }
Shared::Interval * intervalAtColumn(int columnIndex) override;
// Function evaluation memoization
@@ -75,7 +75,7 @@ private:
assert (j >= 0 && j < abscissaTitleCellsCount());
return &m_abscissaTitleCell;
}
SequenceTitleCell * functionTitleCells(int j) override {
Shared::SequenceTitleCell * functionTitleCells(int j) override {
assert(j >= 0 && j < k_maxNumberOfDisplayableSequences);
return &m_sequenceTitleCells[j];
}
@@ -85,7 +85,7 @@ private:
}
SelectableTableView m_selectableTableView;
SequenceTitleCell m_sequenceTitleCells[k_maxNumberOfDisplayableSequences];
Shared::SequenceTitleCell m_sequenceTitleCells[k_maxNumberOfDisplayableSequences];
EvenOddBufferTextCell m_floatCells[k_maxNumberOfDisplayableCells];
EvenOddMessageTextCell m_abscissaTitleCell;
EvenOddEditableTextCell m_abscissaCells[k_maxNumberOfDisplayableRows];

View File

@@ -16,6 +16,9 @@ app_shared_test_src = $(addprefix apps/shared/,\
labeled_curve_view.cpp \
memoized_curve_view_range.cpp \
range_1D.cpp \
sequence.cpp\
sequence_context.cpp\
sequence_store.cpp\
toolbox_helpers.cpp \
zoom_and_pan_curve_view_controller.cpp \
zoom_curve_view_controller.cpp \
@@ -26,6 +29,7 @@ app_shared_src = $(addprefix apps/shared/,\
buffer_function_title_cell.cpp \
buffer_text_view_with_text_field.cpp \
button_with_separator.cpp \
cache_context.cpp \
cursor_view.cpp \
editable_cell_table_view_controller.cpp \
expression_field_delegate_app.cpp \
@@ -60,6 +64,10 @@ app_shared_src = $(addprefix apps/shared/,\
range_parameter_controller.cpp \
regular_table_view_data_source.cpp \
round_cursor_view.cpp \
sequence.cpp\
sequence_context.cpp\
sequence_store.cpp\
sequence_title_cell.cpp \
scrollable_multiple_expressions_view.cpp \
scrollable_two_expressions_cell.cpp \
separable.cpp \
@@ -93,9 +101,11 @@ app_shared_test_src += $(addprefix apps/graph/,\
continuous_function_store.cpp\
)
app_shared_test_src += $(addprefix apps/sequence/,\
sequence.cpp\
sequence_store.cpp\
app_shared_test_src += $(addprefix apps/shared/,\
cache_context.cpp \
sequence.cpp \
sequence_context.cpp \
sequence_store.cpp \
)
tests_src += $(addprefix apps/shared/test/,\

View File

@@ -7,7 +7,7 @@
using namespace Poincare;
namespace Sequence {
namespace Shared {
template<typename T>
CacheContext<T>::CacheContext(Context * parentContext) :

View File

@@ -6,7 +6,7 @@
#include <poincare/symbol.h>
#include "sequence_context.h"
namespace Sequence {
namespace Shared {
template<typename T>
class CacheContext : public Poincare::ContextWithParent {

View File

@@ -41,6 +41,8 @@ private:
static Ion::Storage::Record::ErrorStatus SetExpressionForFunction(const Poincare::Expression & expression, const Poincare::SymbolAbstract & symbol, Ion::Storage::Record previousRecord);
// Record getter
static Ion::Storage::Record SymbolAbstractRecordWithBaseName(const char * name);
};
}

View File

@@ -12,10 +12,9 @@
#include <apps/i18n.h>
#include <cmath>
using namespace Shared;
using namespace Poincare;
namespace Sequence {
namespace Shared {
I18n::Message Sequence::parameterMessageName() const {
return I18n::Message::N;

View File

@@ -9,7 +9,7 @@
#include <emscripten.h>
#endif
namespace Sequence {
namespace Shared {
/* WARNING: after calling setType, setInitialRank, setContent, setFirstInitialConditionContent
* or setSecondInitialConditionContent, the sequence context needs to

View File

@@ -5,9 +5,8 @@
#include <cmath>
using namespace Poincare;
using namespace Shared;
namespace Sequence {
namespace Shared {
template<typename T>
TemplatedSequenceContext<T>::TemplatedSequenceContext() :

View File

@@ -5,7 +5,7 @@
#include <poincare/expression.h>
#include <poincare/symbol.h>
namespace Sequence {
namespace Shared {
constexpr static int MaxRecurrenceDepth = 2;
static constexpr int MaxNumberOfSequences = 3;

View File

@@ -5,7 +5,7 @@ extern "C" {
#include <stddef.h>
}
namespace Sequence {
namespace Shared {
constexpr const char * SequenceStore::k_sequenceNames[MaxNumberOfSequences];

View File

@@ -7,7 +7,7 @@
#include <stdint.h>
#include <escher.h>
namespace Sequence {
namespace Shared {
class SequenceStore : public Shared::FunctionStore {
public:

View File

@@ -1,10 +1,9 @@
#include "sequence_title_cell.h"
#include <assert.h>
using namespace Shared;
using namespace Poincare;
namespace Sequence {
namespace Shared {
SequenceTitleCell::SequenceTitleCell() :
Shared::FunctionTitleCell(Orientation::VerticalIndicator),

View File

@@ -4,7 +4,7 @@
#include "../shared/function_title_cell.h"
#include <poincare_layouts.h>
namespace Sequence {
namespace Shared {
class SequenceTitleCell : public Shared::FunctionTitleCell {
public:

View File

@@ -1,8 +1,8 @@
#include <quiz.h>
#include "../continuous_function.h"
#include "../../graph/continuous_function_store.h"
#include "../../sequence/sequence.h"
#include "../../sequence/sequence_store.h"
#include "../sequence.h"
#include "../sequence_store.h"
namespace Shared {
@@ -14,12 +14,12 @@ void interactWithBaseRecordMember(F * fct) {
(void) color; // Silence compilation warning about unused variable.
}
void interactWithRecordMember(Sequence::SequenceStore * store, Ion::Storage::Record rec) {
Sequence::Sequence * seq = store->modelForRecord(rec);
void interactWithRecordMember(SequenceStore * store, Ion::Storage::Record rec) {
Sequence * seq = store->modelForRecord(rec);
/* Setting Sequence type will write record member m_initialConditionSizes,
* which has a 2-byte alignment */
seq->setType(Sequence::Sequence::Type::SingleRecurrence);
interactWithBaseRecordMember<Sequence::Sequence>(seq);
seq->setType(Sequence::Type::SingleRecurrence);
interactWithBaseRecordMember<Sequence>(seq);
}
void interactWithRecordMember(Graph::ContinuousFunctionStore * store, Ion::Storage::Record rec) {
@@ -73,7 +73,7 @@ QUIZ_CASE(alignment_handling) {
* properly. It also ensures that the right test - load and store of
* differently-aligned objects - is performed (if storage/record
* implementations change for instance). */
testAlignmentHandlingFor<Sequence::SequenceStore>();
testAlignmentHandlingFor<SequenceStore>();
testAlignmentHandlingFor<Graph::ContinuousFunctionStore>();
}

View File

@@ -8,7 +8,7 @@
#include <poincare/serialization_helper.h>
#include <poincare/parenthesis.h>
#include <poincare/complex.h>
#include <apps/sequence/sequence.h>
#include <apps/shared/sequence.h>
namespace Poincare {