forked from qt-creator/qt-creator
Lua: Move toFilePath to utils helper
Change-Id: I72f0e57ce45e01bb079903377a2530fef5e4d70e Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -21,6 +21,7 @@ add_qtc_plugin(Lua
|
|||||||
bindings/texteditor.cpp
|
bindings/texteditor.cpp
|
||||||
bindings/translate.cpp
|
bindings/translate.cpp
|
||||||
bindings/utils.cpp
|
bindings/utils.cpp
|
||||||
|
bindings/utils.h
|
||||||
luaengine.cpp
|
luaengine.cpp
|
||||||
luaengine.h
|
luaengine.h
|
||||||
luaexpander.cpp
|
luaexpander.cpp
|
||||||
|
@@ -16,15 +16,16 @@ void setupActionModule()
|
|||||||
registerProvider("Action", [](sol::state_view lua) -> sol::object {
|
registerProvider("Action", [](sol::state_view lua) -> sol::object {
|
||||||
sol::table result = lua.create_table();
|
sol::table result = lua.create_table();
|
||||||
|
|
||||||
result.new_enum("CommandAttribute",
|
result.new_enum(
|
||||||
"CA_Hide",
|
"CommandAttribute",
|
||||||
Core::Command::CA_Hide,
|
"CA_Hide",
|
||||||
"CA_UpdateText",
|
Core::Command::CA_Hide,
|
||||||
Core::Command::CA_UpdateText,
|
"CA_UpdateText",
|
||||||
"CA_UpdateIcon",
|
Core::Command::CA_UpdateText,
|
||||||
Core::Command::CA_UpdateIcon,
|
"CA_UpdateIcon",
|
||||||
"CA_NonConfigurable",
|
Core::Command::CA_UpdateIcon,
|
||||||
Core::Command::CA_NonConfigurable);
|
"CA_NonConfigurable",
|
||||||
|
Core::Command::CA_NonConfigurable);
|
||||||
|
|
||||||
struct ScriptCommand
|
struct ScriptCommand
|
||||||
{
|
{
|
||||||
|
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include "../luaengine.h"
|
#include "../luaengine.h"
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
|
|
||||||
@@ -10,19 +12,6 @@ using namespace Utils;
|
|||||||
|
|
||||||
namespace Lua::Internal {
|
namespace Lua::Internal {
|
||||||
|
|
||||||
FilePath toFilePath(std::variant<FilePath, QString> &&v)
|
|
||||||
{
|
|
||||||
return std::visit(
|
|
||||||
[](auto &&arg) -> FilePath {
|
|
||||||
using T = std::decay_t<decltype(arg)>;
|
|
||||||
if constexpr (std::is_same_v<T, QString>)
|
|
||||||
return FilePath::fromUserInput(arg);
|
|
||||||
else
|
|
||||||
return arg;
|
|
||||||
},
|
|
||||||
v);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setupProcessModule()
|
void setupProcessModule()
|
||||||
{
|
{
|
||||||
registerProvider("Process", [](sol::state_view lua) -> sol::object {
|
registerProvider("Process", [](sol::state_view lua) -> sol::object {
|
||||||
|
25
src/plugins/lua/bindings/utils.h
Normal file
25
src/plugins/lua/bindings/utils.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
// 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 <utils/filepath.h>
|
||||||
|
|
||||||
|
namespace Lua::Internal {
|
||||||
|
|
||||||
|
using FilePathOrString = std::variant<Utils::FilePath, QString>;
|
||||||
|
|
||||||
|
inline Utils::FilePath toFilePath(const FilePathOrString &v)
|
||||||
|
{
|
||||||
|
return std::visit(
|
||||||
|
[](auto &&arg) -> Utils::FilePath {
|
||||||
|
using T = std::decay_t<decltype(arg)>;
|
||||||
|
if constexpr (std::is_same_v<T, QString>)
|
||||||
|
return Utils::FilePath::fromUserInput(arg);
|
||||||
|
else
|
||||||
|
return arg;
|
||||||
|
},
|
||||||
|
v);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Lua::Internal
|
Reference in New Issue
Block a user