aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lua/luapluginspec.h
blob: a19eb6eb17f5bb87229189f2f844ce6462200e84 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include "sol/forward.hpp"

#include <extensionsystem/iplugin.h>
#include <extensionsystem/pluginspec.h>

#include <utils/filepath.h>

#include <QString>

namespace Lua {
class LuaScriptPluginPrivate;
class LuaPluginSpecPrivate;

class LuaScriptPlugin : public ExtensionSystem::IPlugin
{
public:
    LuaScriptPlugin() = delete;
    LuaScriptPlugin(const LuaScriptPlugin &other);
    LuaScriptPlugin(const std::shared_ptr<LuaScriptPluginPrivate> &d);

    QString name() const;
    QStringList cppDependencies() const;
    void setup() const;

private:
    std::shared_ptr<LuaScriptPluginPrivate> d;
};

class LuaPluginSpec : public ExtensionSystem::PluginSpec
{
    std::unique_ptr<LuaPluginSpecPrivate> d;

    LuaPluginSpec();

public:
    static Utils::Result<LuaPluginSpec *> create(
        const Utils::FilePath &filePath, sol::table pluginTable);

    ExtensionSystem::IPlugin *plugin() const override;

    // For internal use only
    bool loadLibrary() override;
    bool initializePlugin() override;
    bool initializeExtensions() override;
    bool delayedInitialize() override;
    ExtensionSystem::IPlugin::ShutdownFlag stop() override;
    void kill() override;

    Utils::FilePath installLocation(bool inUserFolder) const override;

public:
    bool printToOutputPane() const;
};

} // namespace Lua