forked from qt-creator/qt-creator
Lua: Add Lua plugin support
Adds basic support for writing Plugins using the lua scripting language. Lua Plugins are registered just as native plugins are and can be enabled or disabled via the plugin dialog. see src/plugins/lua/README.md for further details. Change-Id: I9f4d15e9632c46e1c6c132bcd0bbcdd70b150640 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
46
src/plugins/lua/bindings/core.cpp
Normal file
46
src/plugins/lua/bindings/core.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
// 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 "../luaengine.h"
|
||||
|
||||
#include <coreplugin/generatedfile.h>
|
||||
|
||||
using namespace Core;
|
||||
|
||||
namespace Lua::Internal {
|
||||
|
||||
void addCoreModule()
|
||||
{
|
||||
LuaEngine::registerProvider("Core", [](sol::state_view lua) -> sol::object {
|
||||
sol::table core = lua.create_table();
|
||||
|
||||
auto generatedFileType = core.new_usertype<GeneratedFile>(
|
||||
"GeneratedFile",
|
||||
"filePath",
|
||||
sol::property(&GeneratedFile::filePath, &GeneratedFile::setFilePath),
|
||||
"contents",
|
||||
sol::property(&GeneratedFile::contents, &GeneratedFile::setContents),
|
||||
"attributes",
|
||||
sol::property([](GeneratedFile *f) -> int { return f->attributes().toInt(); },
|
||||
[](GeneratedFile *f, int flags) {
|
||||
f->setAttributes(GeneratedFile::Attributes::fromInt(flags));
|
||||
}),
|
||||
"isBinary",
|
||||
sol::property(&GeneratedFile::isBinary, &GeneratedFile::setBinary));
|
||||
|
||||
// clang-format off
|
||||
generatedFileType["Attribute"] = lua.create_table_with(
|
||||
"OpenEditorAttribute", GeneratedFile::OpenEditorAttribute,
|
||||
"OpenProjectAttribute", GeneratedFile::OpenProjectAttribute,
|
||||
"CustomGeneratorAttribute", GeneratedFile::CustomGeneratorAttribute,
|
||||
"KeepExistingFileAttribute", GeneratedFile::KeepExistingFileAttribute,
|
||||
"ForceOverwrite", GeneratedFile::ForceOverwrite,
|
||||
"TemporaryFile", GeneratedFile::TemporaryFile
|
||||
);
|
||||
// clang-format on
|
||||
|
||||
return core;
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace Lua::Internal
|
||||
Reference in New Issue
Block a user