aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils/lua.cpp
blob: cb6f9abb1348691cdba6336efd028d18c75d306b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#include "lua.h"

#include "utilstr.h"

namespace Utils {

static LuaInterface *s_luaInterface = nullptr;

void setLuaInterface(LuaInterface *luaInterface)
{
    s_luaInterface = luaInterface;
}

LuaInterface *luaInterface()
{
    return s_luaInterface;
}

Result<std::unique_ptr<LuaState>> runScript(const QString &script, const QString &name)
{
    if (!s_luaInterface)
        return ResultError(Tr::tr("No Lua interface set"));

    return s_luaInterface->runScript(script, name);
}

} // namespace Utils