mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[code] Get rid of malloc: keep a buffer in Code::App to be used as python heap
This commit is contained in:
@@ -77,18 +77,24 @@ void App::Snapshot::setOpt(const char * name, char * value) {
|
||||
|
||||
App::App(Container * container, Snapshot * snapshot) :
|
||||
::App(container, snapshot, &m_codeStackViewController, I18n::Message::Warning),
|
||||
m_consoleController(nullptr, snapshot->scriptStore()
|
||||
m_pythonHeap{},
|
||||
m_pythonUser(nullptr),
|
||||
m_consoleController(nullptr, this, snapshot->scriptStore()
|
||||
#if EPSILON_GETOPT
|
||||
, snapshot->lockOnConsole()
|
||||
#endif
|
||||
),
|
||||
m_listFooter(&m_codeStackViewController, &m_menuController, &m_menuController, ButtonRowController::Position::Bottom, ButtonRowController::Style::EmbossedGrey, ButtonRowController::Size::Large),
|
||||
m_menuController(&m_listFooter, snapshot->scriptStore(), &m_listFooter),
|
||||
m_menuController(&m_listFooter, this, snapshot->scriptStore(), &m_listFooter),
|
||||
m_codeStackViewController(&m_modalViewController, &m_listFooter),
|
||||
m_variableBoxController(&m_menuController, snapshot->scriptStore())
|
||||
{
|
||||
}
|
||||
|
||||
App::~App() {
|
||||
deinitPython();
|
||||
}
|
||||
|
||||
bool App::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::Home && m_consoleController.inputRunLoopActive()) {
|
||||
// We need to return true here because we want to actually exit from the
|
||||
@@ -117,4 +123,17 @@ bool App::textInputDidReceiveEvent(TextInput * textInput, Ion::Events::Event eve
|
||||
return false;
|
||||
}
|
||||
|
||||
void App::initPythonWithUser(const void * pythonUser) {
|
||||
assert(m_pythonUser == nullptr);
|
||||
m_pythonUser = pythonUser;
|
||||
MicroPython::init(m_pythonHeap, m_pythonHeap + k_pythonHeapSize);
|
||||
}
|
||||
|
||||
void App::deinitPython() {
|
||||
if (m_pythonUser) {
|
||||
MicroPython::deinit();
|
||||
m_pythonUser = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user