Port 2V0 UI Python bindings and app module link surface
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "ScriptLib/StdAfx.h"
|
||||
#include "ScriptLib/PythonLauncher.h"
|
||||
#include "UserInterface/StdAfx.h" // initpack and the rest of the module initializer list
|
||||
#include "EterPythonLib/StdAfx.h"
|
||||
#include "PythonBoot.h"
|
||||
#include "PythonHost.h"
|
||||
#include "../EterBase/LogBox.h"
|
||||
@@ -13,6 +14,7 @@ namespace
|
||||
{
|
||||
// 40250 has this on Main()'s stack. CPythonLauncher is a CSingleton, so there is still only ever one.
|
||||
std::unique_ptr<CPythonLauncher> g_launcher;
|
||||
std::unique_ptr<UI::CWindowManager> g_window_manager;
|
||||
|
||||
bool fail(std::string* error, const std::string& text)
|
||||
{
|
||||
@@ -55,6 +57,7 @@ bool Start(const char* stdlib_path, std::string* error)
|
||||
Stop();
|
||||
return fail(error, "InstallStdLib(" + stdlib + "): " + stdlib_error);
|
||||
}
|
||||
g_window_manager = std::make_unique<UI::CWindowManager>();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -66,10 +69,14 @@ bool RunMainScript(const char* lpCmdLine, std::string* error)
|
||||
|
||||
CPythonLauncher& pyLauncher = *g_launcher;
|
||||
|
||||
// The module initializers, in 40250's order. Everything after initpack (initdbg, initime, initgrp,
|
||||
// initgrpImage, initgrpText, initwndMgr, initudp, initapp, ... initServerStateChecker) is a 2V slice:
|
||||
// system.py stops at the first import of one of them, today `app`.
|
||||
// The module initializers follow 40250's order; missing modules arrive in later 2V steps.
|
||||
initpack();
|
||||
initdbg();
|
||||
initgrp();
|
||||
initgrpImage();
|
||||
initgrpText();
|
||||
initwndMgr();
|
||||
initapp();
|
||||
|
||||
ClearLogBoxMessage();
|
||||
|
||||
@@ -122,6 +129,10 @@ bool RunMainScript(const char* lpCmdLine, std::string* error)
|
||||
TraceError("RunMain Error");
|
||||
return fail(error, "RunMain Error: " + LastLogBoxMessage());
|
||||
}
|
||||
// system.py catches failures in prototype.py and calls dbg.LogBox. Its outer
|
||||
// RunFile then succeeds, so surface that recorded failure to the Godot host.
|
||||
if (!LastLogBoxMessage().empty())
|
||||
return fail(error, "RunMain Error: " + LastLogBoxMessage());
|
||||
}
|
||||
|
||||
NANOEND
|
||||
@@ -143,6 +154,7 @@ void Stop()
|
||||
{
|
||||
if (!g_launcher)
|
||||
return;
|
||||
g_window_manager.reset();
|
||||
g_launcher->Clear(); // Main() calls Clear() explicitly before the launcher leaves scope
|
||||
g_launcher.reset();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user