mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[escher/app] Remove poor man's RTTI
This commit is contained in:
committed by
EmilieNumworks
parent
443f974cbb
commit
ba2a98f5e5
@@ -45,7 +45,6 @@ public:
|
||||
/* 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;
|
||||
constexpr static uint8_t Magic = 0xA8;
|
||||
Snapshot * snapshot();
|
||||
void setFirstResponder(Responder * responder);
|
||||
Responder * firstResponder();
|
||||
@@ -57,7 +56,6 @@ public:
|
||||
KDCoordinate topMargin = 0, KDCoordinate leftMargin = 0, KDCoordinate bottomMargin = 0, KDCoordinate rightMargin = 0);
|
||||
void dismissModalViewController();
|
||||
void displayWarning(I18n::Message warningMessage1, I18n::Message warningMessage2 = (I18n::Message) 0, bool specialExitKeys = false);
|
||||
uint8_t m_magic; // Poor man's RTTI
|
||||
|
||||
virtual void didBecomeActive(Window * window);
|
||||
virtual void willBecomeInactive();
|
||||
|
||||
@@ -31,7 +31,6 @@ void App::Snapshot::tidy() {
|
||||
|
||||
App::App(Snapshot * snapshot, ViewController * rootViewController, I18n::Message warningMessage) :
|
||||
Responder(nullptr),
|
||||
m_magic(Magic),
|
||||
m_modalViewController(this, rootViewController),
|
||||
m_firstResponder(nullptr),
|
||||
m_snapshot(snapshot),
|
||||
|
||||
@@ -69,10 +69,6 @@ App * Responder::app() const {
|
||||
while (rootResponder->parentResponder() != nullptr) {
|
||||
rootResponder = rootResponder->parentResponder();
|
||||
}
|
||||
/* If we used RTTI we could use a dynamic_cast, which would be a lot more
|
||||
* safe, as such:
|
||||
* return dynamic_cast<App *>(rootResponder); */
|
||||
App * result = (App *)rootResponder;
|
||||
assert(result->m_magic == App::Magic); // Poor man's RTTI
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user