[Apps/Calculation] Modified the calculationStore of additional results

-Additional results are now stored in smaller calculationStores

Change-Id: I7d09bfb09e57cbb80e9385668adeb29a31398bc0
This commit is contained in:
Arthur
2020-05-20 11:12:56 +02:00
committed by Émilie Feral
parent d7a0914d13
commit d77e924014
5 changed files with 13 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ namespace Calculation {
IllustratedListController::IllustratedListController(EditExpressionController * editExpressionController) :
ListController(editExpressionController, this),
m_calculationStore(m_calculationStoreBuffer, k_calculationStoreBufferSize),
m_additionalCalculationCells{}
{
for (int i = 0; i < k_maxNumberOfAdditionalCalculations; i++) {

View File

@@ -39,7 +39,10 @@ protected:
private:
int textAtIndex(char * buffer, size_t bufferSize, int index) override;
virtual CodePoint expressionSymbol() const = 0;
// Set the size of the buffer needed to store the additional calculation
constexpr static int k_maxNumberOfAdditionalCalculations = 4;
constexpr static int k_calculationStoreBufferSize = k_maxNumberOfAdditionalCalculations * (sizeof(Calculation) + Calculation::k_numberOfExpressions * Constant::MaxSerializedExpressionSize + sizeof(Calculation *));
char m_calculationStoreBuffer[k_calculationStoreBufferSize];
// Cells
virtual HighlightCell * illustrationCell() = 0;
ScrollableThreeExpressionsCell m_additionalCalculationCells[k_maxNumberOfAdditionalCalculations];

View File

@@ -34,6 +34,10 @@ App::Descriptor * App::Snapshot::descriptor() {
return &descriptor;
}
App::Snapshot::Snapshot() : m_calculationStore(m_calculationBuffer, k_calculationBufferSize)
{
}
App::App(Snapshot * snapshot) :
ExpressionFieldDelegateApp(snapshot, &m_editExpressionController),
m_historyController(&m_editExpressionController, snapshot->calculationStore()),

View File

@@ -19,12 +19,16 @@ public:
};
class Snapshot : public ::App::Snapshot {
public:
Snapshot();
App * unpack(Container * container) override;
void reset() override;
Descriptor * descriptor() override;
CalculationStore * calculationStore() { return &m_calculationStore; }
private:
CalculationStore m_calculationStore;
// Set the size of the buffer needed to store the calculations
static constexpr int k_calculationBufferSize = 10 * (sizeof(Calculation) + Calculation::k_numberOfExpressions * Constant::MaxSerializedExpressionSize + sizeof(Calculation *));
char m_calculationBuffer[k_calculationBufferSize];
};
static App * app() {
return static_cast<App *>(Container::activeApp());
@@ -34,6 +38,7 @@ public:
bool layoutFieldDidReceiveEvent(::LayoutField * layoutField, Ion::Events::Event event) override;
// TextFieldDelegateApp
bool isAcceptableExpression(const Poincare::Expression expression) override;
private:
App(Snapshot * snapshot);
HistoryController m_historyController;

View File

@@ -7,7 +7,6 @@
#include "../shared/text_field_delegate.h"
#include "../shared/layout_field_delegate.h"
#include "history_controller.h"
#include "calculation_store.h"
#include "selectable_table_view.h"
namespace Calculation {