mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[shared] Change name of classes:
FunctionRecordData --> FunctionRecordDataBuffer CartesianFunctionRecordData --> CartesianFunctionRecordDataBuffer SequenceRecordData --> SequenceRecordDataBuffer
This commit is contained in:
@@ -84,7 +84,7 @@ Poincare::Layout Sequence::nameLayout() {
|
||||
}
|
||||
|
||||
bool Sequence::isDefined() {
|
||||
SequenceRecordData * data = recordData();
|
||||
SequenceRecordDataBuffer * data = recordData();
|
||||
switch (type()) {
|
||||
case Type::Explicit:
|
||||
return Function::isDefined();
|
||||
@@ -96,7 +96,7 @@ bool Sequence::isDefined() {
|
||||
}
|
||||
|
||||
bool Sequence::isEmpty() {
|
||||
SequenceRecordData * data = recordData();
|
||||
SequenceRecordDataBuffer * data = recordData();
|
||||
switch (type()) {
|
||||
case Type::Explicit:
|
||||
return Function::isEmpty();
|
||||
@@ -185,10 +185,10 @@ double Sequence::sumBetweenBounds(double start, double end, Context * context) c
|
||||
return result;
|
||||
}
|
||||
|
||||
Sequence::SequenceRecordData * Sequence::recordData() const {
|
||||
Sequence::SequenceRecordDataBuffer * Sequence::recordData() const {
|
||||
assert(!isNull());
|
||||
Ion::Storage::Record::Data d = value();
|
||||
return reinterpret_cast<SequenceRecordData *>(const_cast<void *>(d.buffer));
|
||||
return reinterpret_cast<SequenceRecordDataBuffer *>(const_cast<void *>(d.buffer));
|
||||
}
|
||||
|
||||
/* Sequence Handle */
|
||||
@@ -217,13 +217,13 @@ void Sequence::SequenceModel::updateNewDataWithExpression(Ion::Storage::Record *
|
||||
/* Definition Handle*/
|
||||
|
||||
void * Sequence::DefinitionModel::expressionAddress(const Ion::Storage::Record * record) const {
|
||||
return (char *)record->value().buffer+sizeof(SequenceRecordData);
|
||||
return (char *)record->value().buffer+sizeof(SequenceRecordDataBuffer);
|
||||
}
|
||||
|
||||
size_t Sequence::DefinitionModel::expressionSize(const Ion::Storage::Record * record) const {
|
||||
Ion::Storage::Record::Data data = record->value();
|
||||
SequenceRecordData * dataBuffer = static_cast<const Sequence *>(record)->recordData();
|
||||
return data.size-sizeof(SequenceRecordData) - dataBuffer->firstInitialConditionSize() - dataBuffer->secondInitialConditionSize();
|
||||
SequenceRecordDataBuffer * dataBuffer = static_cast<const Sequence *>(record)->recordData();
|
||||
return data.size-sizeof(SequenceRecordDataBuffer) - dataBuffer->firstInitialConditionSize() - dataBuffer->secondInitialConditionSize();
|
||||
}
|
||||
|
||||
void Sequence::DefinitionModel::buildName(Sequence * sequence) {
|
||||
@@ -248,7 +248,7 @@ void Sequence::DefinitionModel::buildName(Sequence * sequence) {
|
||||
|
||||
void * Sequence::FirstInitialConditionModel::expressionAddress(const Ion::Storage::Record * record) const {
|
||||
Ion::Storage::Record::Data data = record->value();
|
||||
SequenceRecordData * dataBuffer = static_cast<const Sequence *>(record)->recordData();
|
||||
SequenceRecordDataBuffer * dataBuffer = static_cast<const Sequence *>(record)->recordData();
|
||||
size_t offset = data.size - dataBuffer->firstInitialConditionSize() - dataBuffer->secondInitialConditionSize();
|
||||
return (char *)data.buffer+offset;
|
||||
}
|
||||
@@ -275,7 +275,7 @@ void Sequence::FirstInitialConditionModel::buildName(Sequence * sequence) {
|
||||
|
||||
void * Sequence::SecondInitialConditionModel::expressionAddress(const Ion::Storage::Record * record) const {
|
||||
Ion::Storage::Record::Data data = record->value();
|
||||
SequenceRecordData * dataBuffer = static_cast<const Sequence *>(record)->recordData();
|
||||
SequenceRecordDataBuffer * dataBuffer = static_cast<const Sequence *>(record)->recordData();
|
||||
size_t offset = data.size - dataBuffer->secondInitialConditionSize();
|
||||
return (char *)data.buffer+offset;
|
||||
}
|
||||
|
||||
@@ -69,10 +69,12 @@ private:
|
||||
constexpr static const KDFont * k_layoutFont = KDFont::LargeFont;
|
||||
constexpr static double k_maxNumberOfTermsInSum = 100000.0;
|
||||
|
||||
class SequenceRecordData : public FunctionRecordData {
|
||||
/* SequenceRecordDataBuffer is the layout of the data buffer of Record
|
||||
* representing a Sequence. */
|
||||
class SequenceRecordDataBuffer : public FunctionRecordDataBuffer {
|
||||
public:
|
||||
SequenceRecordData(KDColor color) :
|
||||
FunctionRecordData(color),
|
||||
SequenceRecordDataBuffer(KDColor color) :
|
||||
FunctionRecordDataBuffer(color),
|
||||
m_type(Type::Explicit),
|
||||
m_initialRank(0),
|
||||
m_firstInitialConditionSize(0),
|
||||
@@ -134,9 +136,9 @@ private:
|
||||
};
|
||||
|
||||
template<typename T> T templatedApproximateAtAbscissa(T x, SequenceContext * sqctx) const;
|
||||
size_t metaDataSize() const override { return sizeof(SequenceRecordData); }
|
||||
size_t metaDataSize() const override { return sizeof(SequenceRecordDataBuffer); }
|
||||
const Shared::ExpressionModel * model() const override { return &m_definition; }
|
||||
SequenceRecordData * recordData() const;
|
||||
SequenceRecordDataBuffer * recordData() const;
|
||||
DefinitionModel m_definition;
|
||||
FirstInitialConditionModel m_firstInitialCondition;
|
||||
SecondInitialConditionModel m_secondInitialCondition;
|
||||
|
||||
@@ -32,7 +32,7 @@ Ion::Storage::Record::ErrorStatus SequenceStore::addEmptyModel() {
|
||||
assert(name);
|
||||
// Choose the corresponding color
|
||||
KDColor color = Palette::DataColor[nameIndex];
|
||||
Sequence::SequenceRecordData data(color);
|
||||
Sequence::SequenceRecordDataBuffer data(color);
|
||||
// m_sequences
|
||||
return Ion::Storage::sharedStorage()->createRecordWithExtension(name, modelExtension(), &data, sizeof(data));
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ CartesianFunction CartesianFunction::NewModel(Ion::Storage::Record::ErrorStatus
|
||||
// Create the record
|
||||
char nameBuffer[SymbolAbstract::k_maxNameSize];
|
||||
int numberOfColors = sizeof(Palette::DataColor)/sizeof(KDColor);
|
||||
CartesianFunctionRecordData data(Palette::DataColor[s_colorIndex++ % numberOfColors]);
|
||||
CartesianFunctionRecordDataBuffer data(Palette::DataColor[s_colorIndex++ % numberOfColors]);
|
||||
if (baseName == nullptr) {
|
||||
DefaultName(nameBuffer, SymbolAbstract::k_maxNameSize);
|
||||
baseName = nameBuffer;
|
||||
@@ -124,17 +124,17 @@ Expression::Coordinate2D CartesianFunction::nextIntersectionFrom(double start, d
|
||||
}
|
||||
|
||||
void * CartesianFunction::Model::expressionAddress(const Ion::Storage::Record * record) const {
|
||||
return (char *)record->value().buffer+sizeof(CartesianFunctionRecordData);
|
||||
return (char *)record->value().buffer+sizeof(CartesianFunctionRecordDataBuffer);
|
||||
}
|
||||
|
||||
size_t CartesianFunction::Model::expressionSize(const Ion::Storage::Record * record) const {
|
||||
return record->value().size-sizeof(CartesianFunctionRecordData);
|
||||
return record->value().size-sizeof(CartesianFunctionRecordDataBuffer);
|
||||
}
|
||||
|
||||
CartesianFunction::CartesianFunctionRecordData * CartesianFunction::recordData() const {
|
||||
CartesianFunction::CartesianFunctionRecordDataBuffer * CartesianFunction::recordData() const {
|
||||
assert(!isNull());
|
||||
Ion::Storage::Record::Data d = value();
|
||||
return reinterpret_cast<CartesianFunctionRecordData *>(const_cast<void *>(d.buffer));
|
||||
return reinterpret_cast<CartesianFunctionRecordDataBuffer *>(const_cast<void *>(d.buffer));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,10 +31,12 @@ public:
|
||||
double nextRootFrom(double start, double step, double max, Poincare::Context * context) const;
|
||||
Poincare::Expression::Coordinate2D nextIntersectionFrom(double start, double step, double max, Poincare::Context * context, Poincare::Expression expression) const;
|
||||
private:
|
||||
class CartesianFunctionRecordData : public FunctionRecordData {
|
||||
/* CartesianFunctionRecordDataBuffer is the layout of the data buffer of Record
|
||||
* representing a CartesianFunction. */
|
||||
class CartesianFunctionRecordDataBuffer : public FunctionRecordDataBuffer {
|
||||
public:
|
||||
CartesianFunctionRecordData(KDColor color) :
|
||||
FunctionRecordData(color),
|
||||
CartesianFunctionRecordDataBuffer(KDColor color) :
|
||||
FunctionRecordDataBuffer(color),
|
||||
m_displayDerivative(false)
|
||||
{}
|
||||
bool displayDerivative() const { return m_displayDerivative; }
|
||||
@@ -51,9 +53,9 @@ private:
|
||||
private:
|
||||
size_t expressionSize(const Ion::Storage::Record * record) const override;
|
||||
};
|
||||
size_t metaDataSize() const override { return sizeof(CartesianFunctionRecordData); }
|
||||
size_t metaDataSize() const override { return sizeof(CartesianFunctionRecordDataBuffer); }
|
||||
const ExpressionModel * model() const override { return &m_model; }
|
||||
CartesianFunctionRecordData * recordData() const;
|
||||
CartesianFunctionRecordDataBuffer * recordData() const;
|
||||
Model m_model;
|
||||
};
|
||||
|
||||
|
||||
@@ -85,10 +85,10 @@ T Function::templatedApproximateAtAbscissa(T x, Poincare::Context * context, cha
|
||||
return PoincareHelpers::ApproximateWithValueForSymbol(expressionReduced(context), unknownX, x, *context);
|
||||
}
|
||||
|
||||
Function::FunctionRecordData * Function::recordData() const {
|
||||
Function::FunctionRecordDataBuffer * Function::recordData() const {
|
||||
assert(!isNull());
|
||||
Ion::Storage::Record::Data d = value();
|
||||
return reinterpret_cast<FunctionRecordData *>(const_cast<void *>(d.buffer));
|
||||
return reinterpret_cast<FunctionRecordDataBuffer *>(const_cast<void *>(d.buffer));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,13 +40,15 @@ public:
|
||||
}
|
||||
virtual double sumBetweenBounds(double start, double end, Poincare::Context * context) const = 0;
|
||||
protected:
|
||||
class FunctionRecordData {
|
||||
/* FunctionRecordDataBuffer is the layout of the data buffer of Record
|
||||
* representing a Function. */
|
||||
class FunctionRecordDataBuffer {
|
||||
public:
|
||||
FunctionRecordData(KDColor color) : m_color(color), m_active(true) {}
|
||||
FunctionRecordDataBuffer(KDColor color) : m_color(color), m_active(true) {}
|
||||
KDColor color() const {
|
||||
/* Record::value() is a pointer to an address inside
|
||||
* Ion::Storage::sharedStorage(), and it might be unaligned. In the method
|
||||
* recordData(), we cast Record::value() to the type FunctionRecordData.
|
||||
* recordData(), we cast Record::value() to the type FunctionRecordDataBuffer.
|
||||
* We must thus do some convolutions to read KDColor, which is a uint16_t
|
||||
* and might produce an alignment error on the emscripten platform. */
|
||||
return KDColor::RGB16(Ion::StorageHelper::unalignedShort(reinterpret_cast<char *>(const_cast<KDColor *>(&m_color))));
|
||||
@@ -59,7 +61,7 @@ protected:
|
||||
};
|
||||
private:
|
||||
template<typename T> T templatedApproximateAtAbscissa(T x, Poincare::Context * context, char unknownSymbol) const;
|
||||
FunctionRecordData * recordData() const;
|
||||
FunctionRecordDataBuffer * recordData() const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user