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/translate.cpp
|
||||
bindings/utils.cpp
|
||||
bindings/utils.h
|
||||
luaengine.cpp
|
||||
luaengine.h
|
||||
luaexpander.cpp
|
||||
|
@@ -16,7 +16,8 @@ void setupActionModule()
|
||||
registerProvider("Action", [](sol::state_view lua) -> sol::object {
|
||||
sol::table result = lua.create_table();
|
||||
|
||||
result.new_enum("CommandAttribute",
|
||||
result.new_enum(
|
||||
"CommandAttribute",
|
||||
"CA_Hide",
|
||||
Core::Command::CA_Hide,
|
||||
"CA_UpdateText",
|
||||
|
@@ -3,6 +3,8 @@
|
||||
|
||||
#include "../luaengine.h"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#include <utils/environment.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
|
||||
@@ -10,19 +12,6 @@ using namespace Utils;
|
||||
|
||||
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()
|
||||
{
|
||||
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