mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps] Prevent function defined as a store
For instance, from the Graph application, one should not be able to defined f(x) as 3->g(x)
This commit is contained in:
@@ -52,6 +52,7 @@ StandardDeviation = "Standardabweichung"
|
||||
Step = "Schrittwert"
|
||||
StorageMemoryFull1 = "Der Speicher ist voll. Löschen Sie"
|
||||
StorageMemoryFull2 = "von Daten und versuchen Sie es erneut."
|
||||
StoreExpressionNotAcceptedAsFunction = "The function cannot be a Store"
|
||||
SyntaxError = "Syntaxfehler"
|
||||
ToZoom = "Zoom: "
|
||||
Trigonometric = "Trigonometrisch"
|
||||
|
||||
@@ -48,6 +48,7 @@ RoundAbscissa = "Integer"
|
||||
Sci = "sci/"
|
||||
SquareSum = "Sum of squares"
|
||||
StandardDeviation = "Standard deviation"
|
||||
StoreExpressionNotAcceptedAsFunction = "The function cannot be a Store"
|
||||
StatTab = "Stats"
|
||||
Step = "Step"
|
||||
StorageMemoryFull1 = "The memory is full."
|
||||
|
||||
@@ -52,6 +52,7 @@ StatTab = "Medidas"
|
||||
Step = "Incremento"
|
||||
StorageMemoryFull1 = "La memoria esta llena."
|
||||
StorageMemoryFull2 = "Borre datos e intente de nuevo."
|
||||
StoreExpressionNotAcceptedAsFunction = "The function cannot be a Store"
|
||||
SyntaxError = "Error sintactico"
|
||||
ToZoom = "Zoom : "
|
||||
Trigonometric = "Trigonometrico"
|
||||
|
||||
@@ -52,6 +52,7 @@ StatTab = "Stats"
|
||||
Step = "Pas"
|
||||
StorageMemoryFull1 = "La mémoire est pleine."
|
||||
StorageMemoryFull2 = "Effacez des données et réessayez."
|
||||
StoreExpressionNotAcceptedAsFunction = "The function cannot be a Store"
|
||||
SyntaxError = "Attention a la syntaxe"
|
||||
ToZoom = "Zoomer : "
|
||||
Trigonometric = "Trigonometrique"
|
||||
|
||||
@@ -52,6 +52,7 @@ StatTab = "Estat"
|
||||
Step = "Passo"
|
||||
StorageMemoryFull1 = "A memoria esta chéia."
|
||||
StorageMemoryFull2 = "Apage dados e tente novamente."
|
||||
StoreExpressionNotAcceptedAsFunction = "The function cannot be a Store"
|
||||
SyntaxError = "Erro de sintaxe"
|
||||
ToZoom = "Zoom : "
|
||||
Trigonometric = "Trigonometrico"
|
||||
|
||||
@@ -32,7 +32,7 @@ bool ExpressionFieldDelegateApp::layoutFieldDidReceiveEvent(LayoutField * layout
|
||||
displayWarning(I18n::Message::SyntaxError);
|
||||
return true;
|
||||
}
|
||||
if (unparsableText(buffer, layoutField)) {
|
||||
if (!isAcceptableText(buffer, layoutField)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,4 +67,18 @@ void StorageFunctionApp::willBecomeInactive() {
|
||||
::App::willBecomeInactive();
|
||||
}
|
||||
|
||||
|
||||
bool StorageFunctionApp::isAcceptableExpression(const Expression exp, Responder * responder) {
|
||||
if (TextFieldDelegateApp::isAcceptableExpression(exp, responder)) {
|
||||
assert(!exp.isUninitialized());
|
||||
if (exp.type() == ExpressionNode::Type::Store) {
|
||||
// We do not want to allow a function to be "3->a" or "5->f(x)"
|
||||
responder->app()->displayWarning(I18n::Message::StoreExpressionNotAcceptedAsFunction);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ public:
|
||||
void willBecomeInactive() override;
|
||||
protected:
|
||||
StorageFunctionApp(Container * container, Snapshot * snapshot, ViewController * rootViewController);
|
||||
bool isAcceptableExpression(const Poincare::Expression expression, Responder * responder) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ bool TextFieldDelegateApp::textFieldShouldFinishEditing(TextField * textField, I
|
||||
|
||||
bool TextFieldDelegateApp::textFieldDidReceiveEvent(TextField * textField, Ion::Events::Event event) {
|
||||
if (textField->isEditing() && textField->shouldFinishEditing(event)) {
|
||||
if (unparsableText(textField->text(), textField)) {
|
||||
if (!isAcceptableText(textField->text(), textField)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -54,13 +54,17 @@ bool TextFieldDelegateApp::isFinishingEvent(Ion::Events::Event event) {
|
||||
return event == Ion::Events::OK || event == Ion::Events::EXE;
|
||||
}
|
||||
|
||||
bool TextFieldDelegateApp::unparsableText(const char * text, Responder * responder) {
|
||||
bool TextFieldDelegateApp::isAcceptableText(const char * text, Responder * responder) {
|
||||
Expression exp = Expression::parse(text);
|
||||
return isAcceptableExpression(exp, responder);
|
||||
}
|
||||
|
||||
bool TextFieldDelegateApp::isAcceptableExpression(const Expression exp, Responder * responder) {
|
||||
if (exp.isUninitialized()) {
|
||||
responder->app()->displayWarning(I18n::Message::SyntaxError);
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ public:
|
||||
virtual bool textFieldDidReceiveEvent(TextField * textField, Ion::Events::Event event) override;
|
||||
protected:
|
||||
TextFieldDelegateApp(Container * container, Snapshot * snapshot, ViewController * rootViewController);
|
||||
protected:
|
||||
bool fieldDidReceiveEvent(EditableField * field, Responder * responder, Ion::Events::Event event);
|
||||
bool isFinishingEvent(Ion::Events::Event event);
|
||||
bool unparsableText(const char * text, Responder * responder);
|
||||
bool isAcceptableText(const char * text, Responder * responder);
|
||||
virtual bool isAcceptableExpression(const Poincare::Expression expression, Responder * responder);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user