forked from qt-creator/qt-creator
Remove script manager and script debugger engine.
Doesn't really serve a purpose any more. Change-Id: I8c3bc11bf7b05a15eafd2a22456a40b270cefadf Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com> Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -15,8 +15,7 @@ win32-msvc*:QMAKE_CXXFLAGS += -wd4251 -wd4290 -wd4250
|
||||
INCLUDEPATH += dialogs \
|
||||
actionmanager \
|
||||
editormanager \
|
||||
progressmanager \
|
||||
scriptmanager
|
||||
progressmanager
|
||||
SOURCES += mainwindow.cpp \
|
||||
editmode.cpp \
|
||||
tabpositionindicator.cpp \
|
||||
@@ -55,7 +54,6 @@ SOURCES += mainwindow.cpp \
|
||||
progressmanager/progressview.cpp \
|
||||
progressmanager/progressbar.cpp \
|
||||
progressmanager/futureprogress.cpp \
|
||||
scriptmanager/scriptmanager.cpp \
|
||||
statusbarwidget.cpp \
|
||||
coreplugin.cpp \
|
||||
variablemanager.cpp \
|
||||
@@ -155,9 +153,6 @@ HEADERS += mainwindow.h \
|
||||
ifilewizardextension.h \
|
||||
icorelistener.h \
|
||||
versiondialog.h \
|
||||
scriptmanager/metatypedeclarations.h \
|
||||
scriptmanager/scriptmanager.h \
|
||||
scriptmanager/scriptmanager_p.h \
|
||||
core_global.h \
|
||||
statusbarwidget.h \
|
||||
coreplugin.h \
|
||||
|
||||
@@ -20,7 +20,6 @@ QtcPlugin {
|
||||
"dialogs",
|
||||
"editormanager",
|
||||
"progressmanager",
|
||||
"scriptmanager",
|
||||
"actionmanager"
|
||||
])
|
||||
|
||||
@@ -225,10 +224,6 @@ QtcPlugin {
|
||||
"progressmanager/progressmanager_p.h",
|
||||
"progressmanager/progressview.cpp",
|
||||
"progressmanager/progressview.h",
|
||||
"scriptmanager/metatypedeclarations.h",
|
||||
"scriptmanager/scriptmanager.cpp",
|
||||
"scriptmanager/scriptmanager.h",
|
||||
"scriptmanager/scriptmanager_p.h",
|
||||
]
|
||||
|
||||
Group {
|
||||
|
||||
@@ -432,11 +432,6 @@ ProgressManager *ICore::progressManager()
|
||||
return m_mainwindow->progressManager();
|
||||
}
|
||||
|
||||
ScriptManager *ICore::scriptManager()
|
||||
{
|
||||
return m_mainwindow->scriptManager();
|
||||
}
|
||||
|
||||
VariableManager *ICore::variableManager()
|
||||
{
|
||||
return m_mainwindow->variableManager();
|
||||
|
||||
@@ -98,7 +98,6 @@ public:
|
||||
static QT_DEPRECATED MessageManager *messageManager(); // Use MessageManager::... directly.
|
||||
static EditorManager *editorManager();
|
||||
static ProgressManager *progressManager();
|
||||
static ScriptManager *scriptManager();
|
||||
static QT_DEPRECATED VariableManager *variableManager(); // Use VariableManager::... directly.
|
||||
static VcsManager *vcsManager();
|
||||
static QT_DEPRECATED ModeManager *modeManager(); // Use ModeManager::... directly.
|
||||
|
||||
@@ -53,7 +53,6 @@
|
||||
#include "progressview.h"
|
||||
#include "shortcutsettings.h"
|
||||
#include "vcsmanager.h"
|
||||
#include "scriptmanager_p.h"
|
||||
#include "settingsdialog.h"
|
||||
#include "variablemanager.h"
|
||||
#include "versiondialog.h"
|
||||
@@ -130,7 +129,6 @@ MainWindow::MainWindow() :
|
||||
m_editorManager(0),
|
||||
m_externalToolManager(0),
|
||||
m_progressManager(new ProgressManagerPrivate()),
|
||||
m_scriptManager(new ScriptManagerPrivate(this)),
|
||||
m_variableManager(new VariableManager),
|
||||
m_vcsManager(new VcsManager),
|
||||
m_statusBarManager(0),
|
||||
@@ -999,11 +997,6 @@ ProgressManager *MainWindow::progressManager() const
|
||||
return m_progressManager;
|
||||
}
|
||||
|
||||
ScriptManager *MainWindow::scriptManager() const
|
||||
{
|
||||
return m_scriptManager;
|
||||
}
|
||||
|
||||
VariableManager *MainWindow::variableManager() const
|
||||
{
|
||||
return m_variableManager;
|
||||
|
||||
@@ -61,7 +61,6 @@ class ModeManager;
|
||||
class ProgressManager;
|
||||
class NavigationWidget;
|
||||
class RightPaneWidget;
|
||||
class ScriptManager;
|
||||
class SettingsDatabase;
|
||||
class VariableManager;
|
||||
class VcsManager;
|
||||
@@ -101,7 +100,6 @@ public:
|
||||
Core::MessageManager *messageManager() const;
|
||||
Core::EditorManager *editorManager() const;
|
||||
Core::ProgressManager *progressManager() const;
|
||||
Core::ScriptManager *scriptManager() const;
|
||||
Core::VariableManager *variableManager() const;
|
||||
Core::ModeManager *modeManager() const;
|
||||
Core::MimeDatabase *mimeDatabase() const;
|
||||
@@ -183,7 +181,6 @@ private:
|
||||
ExternalToolManager *m_externalToolManager;
|
||||
MessageManager *m_messageManager;
|
||||
ProgressManagerPrivate *m_progressManager;
|
||||
ScriptManager *m_scriptManager;
|
||||
VariableManager *m_variableManager;
|
||||
VcsManager *m_vcsManager;
|
||||
StatusBarManager *m_statusBarManager;
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef METATYPEDECLARATIONS_H
|
||||
#define METATYPEDECLARATIONS_H
|
||||
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <QList>
|
||||
#include <QMetaType>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QMainWindow;
|
||||
class QStatusBar;
|
||||
class QSettings;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
Q_DECLARE_METATYPE(Core::MessageManager*)
|
||||
Q_DECLARE_METATYPE(Core::DocumentManager*)
|
||||
Q_DECLARE_METATYPE(Core::IDocument*)
|
||||
Q_DECLARE_METATYPE(QList<Core::IDocument*>)
|
||||
Q_DECLARE_METATYPE(QList<Core::IEditor*>)
|
||||
Q_DECLARE_METATYPE(Core::EditorManager*)
|
||||
Q_DECLARE_METATYPE(Core::ICore*)
|
||||
|
||||
Q_DECLARE_METATYPE(QMainWindow*)
|
||||
Q_DECLARE_METATYPE(QStatusBar*)
|
||||
Q_DECLARE_METATYPE(QSettings*)
|
||||
|
||||
#endif // METATYPEDECLARATIONS_H
|
||||
@@ -1,280 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "scriptmanager_p.h"
|
||||
#include "metatypedeclarations.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <interface_wrap_helpers.h>
|
||||
#include <wrap_helpers.h>
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QSettings>
|
||||
#include <QMessageBox>
|
||||
#include <QInputDialog>
|
||||
#include <QFileDialog>
|
||||
#include <QMainWindow>
|
||||
#include <QStatusBar>
|
||||
|
||||
// Script function template to pop up a message box
|
||||
// with a certain icon and buttons.
|
||||
template <int MsgBoxIcon, int MsgBoxButtons>
|
||||
static QScriptValue messageBox(QScriptContext *context, QScriptEngine *engine)
|
||||
{
|
||||
if (context->argumentCount() < 3)
|
||||
return QScriptValue(engine, -1);
|
||||
|
||||
QWidget *parent = qscriptvalue_cast<QWidget *>(context->argument(0));
|
||||
const QString title = context->argument(1).toString();
|
||||
const QString msg = context->argument(2).toString();
|
||||
|
||||
QMessageBox msgBox(static_cast<QMessageBox::Icon>(MsgBoxIcon), title, msg,
|
||||
static_cast<QMessageBox::StandardButtons>(MsgBoxButtons), parent);
|
||||
|
||||
return QScriptValue(engine, msgBox.exec());
|
||||
}
|
||||
|
||||
static QScriptValue inputDialogGetText(QScriptContext *context, QScriptEngine *engine)
|
||||
{
|
||||
const int argumentCount = context->argumentCount();
|
||||
if (argumentCount < 3)
|
||||
return QScriptValue(engine, QScriptValue::NullValue);
|
||||
|
||||
QWidget *parent = qscriptvalue_cast<QWidget *>(context->argument(0));
|
||||
const QString title = context->argument(1).toString();
|
||||
const QString label = context->argument(2).toString();
|
||||
const QString defaultValue = argumentCount > 3 ? context->argument(3).toString() : QString();
|
||||
|
||||
bool ok;
|
||||
const QString rc = QInputDialog::getText(parent, title, label, QLineEdit::Normal, defaultValue, &ok);
|
||||
if (!ok)
|
||||
return QScriptValue(engine, QScriptValue::NullValue);
|
||||
return QScriptValue(engine, rc);
|
||||
}
|
||||
|
||||
static QScriptValue inputDialogGetInteger(QScriptContext *context, QScriptEngine *engine)
|
||||
{
|
||||
const int argumentCount = context->argumentCount();
|
||||
if (argumentCount < 3)
|
||||
return QScriptValue(engine, QScriptValue::NullValue);
|
||||
|
||||
QWidget *parent = qscriptvalue_cast<QWidget *>(context->argument(0));
|
||||
const QString title = context->argument(1).toString();
|
||||
const QString label = context->argument(2).toString();
|
||||
const int defaultValue = argumentCount > 3 ? context->argument(3).toInt32() : 0;
|
||||
const int minValue = argumentCount > 4 ? context->argument(4).toInt32() : INT_MIN;
|
||||
const int maxValue = argumentCount > 5 ? context->argument(5).toInt32() : INT_MAX;
|
||||
|
||||
bool ok;
|
||||
const int rc = QInputDialog::getInt(parent, title, label, defaultValue, minValue, maxValue, 1, &ok);
|
||||
if (!ok)
|
||||
return QScriptValue(engine, QScriptValue::NullValue);
|
||||
return QScriptValue(engine, rc);
|
||||
}
|
||||
|
||||
static QScriptValue inputDialogGetDouble(QScriptContext *context, QScriptEngine *engine)
|
||||
{
|
||||
const int argumentCount = context->argumentCount();
|
||||
if (argumentCount < 3)
|
||||
return QScriptValue(engine, QScriptValue::NullValue);
|
||||
|
||||
QWidget *parent = qscriptvalue_cast<QWidget *>(context->argument(0));
|
||||
const QString title = context->argument(1).toString();
|
||||
const QString label = context->argument(2).toString();
|
||||
const double defaultValue = argumentCount > 3 ? context->argument(3).toNumber() : 0;
|
||||
// Use QInputDialog defaults
|
||||
const double minValue = argumentCount > 4 ? context->argument(4).toNumber() : INT_MIN;
|
||||
const double maxValue = argumentCount > 5 ? context->argument(5).toNumber() : INT_MAX;
|
||||
|
||||
bool ok;
|
||||
const double rc = QInputDialog::getDouble(parent, title, label, defaultValue, minValue, maxValue, 1, &ok);
|
||||
if (!ok)
|
||||
return QScriptValue(engine, QScriptValue::NullValue);
|
||||
return QScriptValue(engine, rc);
|
||||
}
|
||||
|
||||
static QScriptValue inputDialogGetItem(QScriptContext *context, QScriptEngine *engine)
|
||||
{
|
||||
const int argumentCount = context->argumentCount();
|
||||
if (argumentCount < 4)
|
||||
return QScriptValue(engine, QScriptValue::NullValue);
|
||||
|
||||
QWidget *parent = qscriptvalue_cast<QWidget *>(context->argument(0));
|
||||
const QString title = context->argument(1).toString();
|
||||
const QString label = context->argument(2).toString();
|
||||
const QStringList items = qscriptvalue_cast<QStringList>(context->argument(3));
|
||||
const int defaultItem = argumentCount > 4 ? context->argument(4).toInt32() : 0;
|
||||
const bool editable = argumentCount > 5 ? context->argument(5).toInt32() : 0;
|
||||
|
||||
bool ok;
|
||||
const QString rc = QInputDialog::getItem (parent, title, label, items, defaultItem, editable, &ok);
|
||||
if (!ok)
|
||||
return QScriptValue(engine, QScriptValue::NullValue);
|
||||
|
||||
return QScriptValue(engine, rc);
|
||||
}
|
||||
|
||||
// Script function template to pop up a file box
|
||||
// with a certain icon and buttons.
|
||||
template <int TAcceptMode, int TFileMode>
|
||||
static QScriptValue fileBox(QScriptContext *context, QScriptEngine *engine)
|
||||
{
|
||||
const int argumentCount = context->argumentCount();
|
||||
if (argumentCount < 2)
|
||||
return QScriptValue(engine, QScriptValue::NullValue);
|
||||
|
||||
QWidget *parent = qscriptvalue_cast<QWidget *>(context->argument(0));
|
||||
const QString title = context->argument(1).toString();
|
||||
const QString directory = argumentCount > 2 ? context->argument(2).toString() : QString();
|
||||
const QString filter = argumentCount > 3 ? context->argument(3).toString() : QString();
|
||||
QFileDialog fileDialog(parent, title, directory, filter);
|
||||
fileDialog.setAcceptMode(static_cast<QFileDialog::AcceptMode>(TAcceptMode));
|
||||
fileDialog.setFileMode (static_cast<QFileDialog::FileMode>(TFileMode));
|
||||
if (fileDialog.exec() == QDialog::Rejected)
|
||||
return QScriptValue(engine, QScriptValue::NullValue);
|
||||
const QStringList rc = fileDialog.selectedFiles();
|
||||
QTC_CHECK(!rc.empty());
|
||||
return TFileMode == QFileDialog::ExistingFiles ?
|
||||
engine->toScriptValue(rc) : engine->toScriptValue(rc.front());
|
||||
}
|
||||
|
||||
// ------ ScriptManagerPrivate
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
||||
ScriptManagerPrivate::ScriptManagerPrivate(QObject *parent)
|
||||
: ScriptManager(parent),
|
||||
m_engine(0)
|
||||
{
|
||||
}
|
||||
|
||||
// Split a backtrace of the form:
|
||||
// "<anonymous>(BuildManagerCommand(ls))@:0
|
||||
// demoProjectExplorer()@:237
|
||||
// <anonymous>()@:276
|
||||
// <global>()@:0"
|
||||
static void parseBackTrace(const QStringList &backTrace, ScriptManagerPrivate::Stack &stack)
|
||||
{
|
||||
const QChar at = QLatin1Char('@');
|
||||
const QChar colon = QLatin1Char(':');
|
||||
stack.clear();
|
||||
foreach (const QString &line, backTrace) {
|
||||
const int atPos = line.lastIndexOf(at);
|
||||
if (atPos == -1)
|
||||
continue;
|
||||
const int colonPos = line.indexOf(colon, atPos + 1);
|
||||
if (colonPos == -1)
|
||||
continue;
|
||||
|
||||
ScriptManagerPrivate::StackFrame frame;
|
||||
frame.function = line.left(atPos);
|
||||
frame.fileName = line.mid(atPos + 1, colonPos - atPos - 1);
|
||||
frame.lineNumber = line.right(line.size() - colonPos - 1).toInt();
|
||||
stack.push_back(frame);
|
||||
}
|
||||
}
|
||||
|
||||
bool ScriptManagerPrivate::runScript(const QString &script, QString *errorMessage)
|
||||
{
|
||||
Stack stack;
|
||||
return runScript(script, errorMessage, &stack);
|
||||
}
|
||||
|
||||
bool ScriptManagerPrivate::runScript(const QString &script, QString *errorMessage, Stack *stack)
|
||||
{
|
||||
ensureEngineInitialized();
|
||||
stack->clear();
|
||||
|
||||
m_engine->pushContext();
|
||||
m_engine->evaluate(script);
|
||||
|
||||
const bool failed = m_engine->hasUncaughtException ();
|
||||
if (failed) {
|
||||
const int errorLineNumber = m_engine->uncaughtExceptionLineNumber();
|
||||
const QStringList backTrace = m_engine->uncaughtExceptionBacktrace();
|
||||
parseBackTrace(backTrace, *stack);
|
||||
const QString backtrace = backTrace.join(QString(QLatin1Char('\n')));
|
||||
*errorMessage = ScriptManager::tr("Exception at line %1: %2\n%3").arg(errorLineNumber).arg(engineError(m_engine)).arg(backtrace);
|
||||
}
|
||||
m_engine->popContext();
|
||||
return !failed;
|
||||
}
|
||||
|
||||
ScriptManager::QScriptEnginePtr ScriptManagerPrivate::ensureEngineInitialized()
|
||||
{
|
||||
if (!m_engine.isNull())
|
||||
return m_engine;
|
||||
m_engine = QScriptEnginePtr(new QScriptEngine);
|
||||
// register QObjects that occur as properties
|
||||
SharedTools::registerQObject<QMainWindow>(m_engine.data());
|
||||
SharedTools::registerQObject<QStatusBar>(m_engine.data());
|
||||
SharedTools::registerQObject<QSettings>(m_engine.data());
|
||||
|
||||
qScriptRegisterSequenceMetaType<QList<Core::IEditor *> >(m_engine.data());
|
||||
|
||||
// CLASSIC: registerInterfaceWithDefaultPrototype<Core::MessageManager, MessageManagerPrototype>(m_engine);
|
||||
|
||||
// Message box conveniences
|
||||
m_engine->globalObject().setProperty(QLatin1String("critical"),
|
||||
m_engine->newFunction(messageBox<QMessageBox::Critical, QMessageBox::Ok>, 3));
|
||||
m_engine->globalObject().setProperty(QLatin1String("warning"),
|
||||
m_engine->newFunction(messageBox<QMessageBox::Warning, QMessageBox::Ok>, 3));
|
||||
m_engine->globalObject().setProperty(QLatin1String("information"),
|
||||
m_engine->newFunction(messageBox<QMessageBox::Information, QMessageBox::Ok>, 3));
|
||||
// StandardButtons has overloaded operator '|' - grrr.
|
||||
enum { MsgBoxYesNo = 0x00014000 };
|
||||
m_engine->globalObject().setProperty(QLatin1String("yesNoQuestion"),
|
||||
m_engine->newFunction(messageBox<QMessageBox::Question, MsgBoxYesNo>, 3));
|
||||
|
||||
m_engine->globalObject().setProperty(QLatin1String("getText"), m_engine->newFunction(inputDialogGetText, 3));
|
||||
m_engine->globalObject().setProperty(QLatin1String("getInteger"), m_engine->newFunction(inputDialogGetInteger, 3));
|
||||
m_engine->globalObject().setProperty(QLatin1String("getDouble"), m_engine->newFunction(inputDialogGetDouble, 3));
|
||||
m_engine->globalObject().setProperty(QLatin1String("getItem"), m_engine->newFunction(inputDialogGetItem, 3));
|
||||
|
||||
// file box
|
||||
m_engine->globalObject().setProperty(QLatin1String("getOpenFileNames"), m_engine->newFunction(fileBox<QFileDialog::AcceptOpen, QFileDialog::ExistingFiles> , 2));
|
||||
m_engine->globalObject().setProperty(QLatin1String("getOpenFileName"), m_engine->newFunction(fileBox<QFileDialog::AcceptOpen, QFileDialog::ExistingFile> , 2));
|
||||
m_engine->globalObject().setProperty(QLatin1String("getSaveFileName"), m_engine->newFunction(fileBox<QFileDialog::AcceptSave, QFileDialog::AnyFile> , 2));
|
||||
m_engine->globalObject().setProperty(QLatin1String("getExistingDirectory"), m_engine->newFunction(fileBox<QFileDialog::AcceptSave, QFileDialog::DirectoryOnly> , 2));
|
||||
return m_engine;
|
||||
}
|
||||
|
||||
QString ScriptManagerPrivate::engineError(const QScriptEnginePtr &scriptEngine)
|
||||
{
|
||||
QScriptValue error = scriptEngine->evaluate(QLatin1String("Error"));
|
||||
if (error.isValid())
|
||||
return error.toString();
|
||||
return ScriptManager::tr("Unknown error");
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Core
|
||||
@@ -1,77 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef SCRIPTMANAGER_H
|
||||
#define SCRIPTMANAGER_H
|
||||
|
||||
#include <coreplugin/core_global.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QSharedPointer>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QScriptEngine;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
|
||||
/* Script Manager.
|
||||
* Provides a script engine that is initialized with
|
||||
* Qt Creator's interfaces and allows for running scripts.
|
||||
* @{todo} Should it actually manage script files, too? */
|
||||
|
||||
class CORE_EXPORT ScriptManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
typedef QSharedPointer<QScriptEngine> QScriptEnginePtr;
|
||||
|
||||
// A stack frame as returned by a failed invocation (exception)
|
||||
// fileName may be empty. lineNumber can be 0 for the top frame (goof-up?).
|
||||
struct StackFrame {
|
||||
QString function;
|
||||
QString fileName;
|
||||
int lineNumber;
|
||||
};
|
||||
typedef QList<StackFrame> Stack;
|
||||
|
||||
ScriptManager(QObject *parent = 0) : QObject(parent) {}
|
||||
virtual ~ScriptManager() { }
|
||||
|
||||
// Run a script
|
||||
virtual bool runScript(const QString &script, QString *errorMessage, Stack *errorStack) = 0;
|
||||
virtual bool runScript(const QString &script, QString *errorMessage) = 0;
|
||||
|
||||
virtual QScriptEnginePtr scriptEngine() = 0;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
||||
#endif // SCRIPTMANAGER_H
|
||||
@@ -1,63 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef SCRIPTMANAGER_P_H
|
||||
#define SCRIPTMANAGER_P_H
|
||||
|
||||
#include "scriptmanager.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QScriptEngine>
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
||||
class ScriptManagerPrivate : public Core::ScriptManager
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ScriptManagerPrivate(QObject *parent);
|
||||
|
||||
bool runScript(const QString &script, QString *errorMessage, Stack *stack);
|
||||
bool runScript(const QString &script, QString *errorMessage);
|
||||
virtual QScriptEnginePtr scriptEngine() { return ensureEngineInitialized(); }
|
||||
|
||||
static QString engineError(const QScriptEnginePtr &scriptEngine);
|
||||
|
||||
private:
|
||||
QScriptEnginePtr ensureEngineInitialized();
|
||||
|
||||
QScriptEnginePtr m_engine;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Core
|
||||
|
||||
#endif // SCRIPTMANAGER_P_H
|
||||
Reference in New Issue
Block a user