forked from qt-creator/qt-creator
Lua: Interactive Shell
Change-Id: Iedd620abcb62b9dd3e640bcb80ae011016386484 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -81,7 +81,8 @@ public:
|
||||
};
|
||||
|
||||
// Runs the gives script in a new Lua state. The returned Object manages the lifetime of the state.
|
||||
std::unique_ptr<Utils::LuaState> LuaEngine::runScript(const QString &script, const QString &name)
|
||||
std::unique_ptr<Utils::LuaState> LuaEngine::runScript(
|
||||
const QString &script, const QString &name, std::function<void(sol::state &)> customizeState)
|
||||
{
|
||||
std::unique_ptr<LuaStateImpl> opaque = std::make_unique<LuaStateImpl>();
|
||||
|
||||
@@ -124,6 +125,9 @@ std::unique_ptr<Utils::LuaState> LuaEngine::runScript(const QString &script, con
|
||||
for (const auto &func : d->m_autoProviders)
|
||||
func(opaque->lua);
|
||||
|
||||
if (customizeState)
|
||||
customizeState(opaque->lua);
|
||||
|
||||
auto result
|
||||
= opaque->lua
|
||||
.safe_script(script.toStdString(), sol::script_pass_on_error, name.toStdString());
|
||||
|
||||
Reference in New Issue
Block a user