[escher/app] Coding style

This commit is contained in:
Léa Saviot
2020-01-21 10:46:45 +01:00
parent 5e45a60f99
commit 90e5a08d3a
2 changed files with 15 additions and 49 deletions

View File

@@ -26,30 +26,30 @@ class App : public Responder {
public:
class Descriptor {
public:
virtual I18n::Message name();
virtual I18n::Message upperName();
virtual const Image * icon();
virtual I18n::Message name() { return (I18n::Message)0; }
virtual I18n::Message upperName() { return (I18n::Message)0; }
virtual const Image * icon() { return nullptr; }
};
class Snapshot {
public:
virtual App * unpack(Container * container) = 0;
void pack(App * app);
/* reset all instances to their initial values */
virtual void reset();
virtual void reset() {}
virtual void storageDidChangeForRecord(Ion::Storage::Record) {}
virtual Descriptor * descriptor() = 0;
#if EPSILON_GETOPT
virtual void setOpt(const char * name, const char * value) {}
#endif
/* tidy clean all dynamically-allocated data */
virtual void tidy();
virtual void tidy() {}
};
/* The destructor has to be virtual. Otherwise calling a destructor on an
* App * pointing to a Derived App would have undefined behaviour. */
virtual ~App() = default;
Snapshot * snapshot() const { return m_snapshot; }
void setFirstResponder(Responder * responder);
Responder * firstResponder();
Responder * firstResponder() { return m_firstResponder; }
virtual bool processEvent(Ion::Events::Event event);
/* prepareForExit returns true if the app can be switched off in the current
* runloop step, else it prepares for a switch off and returns false. */
@@ -62,11 +62,17 @@ public:
virtual void didBecomeActive(Window * window);
virtual void willBecomeInactive();
View * modalView();
virtual int numberOfTimers();
virtual Timer * timerAtIndex(int i);
virtual int numberOfTimers() { return 0; }
virtual Timer * timerAtIndex(int i) { assert(false); return nullptr; }
virtual Poincare::Context * localContext() { return nullptr; }
protected:
App(Snapshot * snapshot, ViewController * rootViewController, I18n::Message warningMessage = (I18n::Message)0);
App(Snapshot * snapshot, ViewController * rootViewController, I18n::Message warningMessage = (I18n::Message)0) :
Responder(nullptr),
m_modalViewController(this, rootViewController),
m_firstResponder(nullptr),
m_snapshot(snapshot),
m_warningController(this, warningMessage)
{}
ModalViewController m_modalViewController;
private:
Responder * m_firstResponder;

View File

@@ -5,39 +5,12 @@ extern "C" {
#include <assert.h>
}
I18n::Message App::Descriptor::name() {
return (I18n::Message)0;
}
I18n::Message App::Descriptor::upperName() {
return (I18n::Message)0;
}
const Image * App::Descriptor::icon() {
return nullptr;
}
void App::Snapshot::pack(App * app) {
tidy();
app->~App();
assert(Poincare::TreePool::sharedPool()->numberOfNodes() == 0);
}
void App::Snapshot::reset() {
}
void App::Snapshot::tidy() {
}
App::App(Snapshot * snapshot, ViewController * rootViewController, I18n::Message warningMessage) :
Responder(nullptr),
m_modalViewController(this, rootViewController),
m_firstResponder(nullptr),
m_snapshot(snapshot),
m_warningController(this, warningMessage)
{
}
bool App::processEvent(Ion::Events::Event event) {
Responder * responder = m_firstResponder;
bool didHandleEvent = false;
@@ -51,10 +24,6 @@ bool App::processEvent(Ion::Events::Event event) {
return false;
}
Responder * App::firstResponder() {
return m_firstResponder;
}
void App::setFirstResponder(Responder * responder) {
Responder * previousResponder = m_firstResponder;
m_firstResponder = responder;
@@ -114,12 +83,3 @@ void App::willBecomeInactive() {
View * App::modalView() {
return m_modalViewController.view();
}
int App::numberOfTimers() {
return 0;
}
Timer * App::timerAtIndex(int i) {
assert(false);
return nullptr;
}