Move workerscript to its own module

Change-Id: I778cfe842ddf1c600a837d8f2061a338887eed95
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Ulf Hermann 2019-04-04 15:41:18 +02:00
parent fee256e641
commit 5032ff5c2b
27 changed files with 396 additions and 42 deletions

View File

@ -1,4 +1,5 @@
TEMPLATE = subdirs
QT_FOR_CONFIG += qml-private
SUBDIRS += \
builtins \
@ -6,6 +7,7 @@ SUBDIRS += \
models \
labsmodels
qtConfig(qml-worker-script): SUBDIRS += workerscript
qtConfig(thread): SUBDIRS += folderlistmodel
qtHaveModule(sql): SUBDIRS += localstorage
qtConfig(settings): SUBDIRS += settings

View File

@ -42,6 +42,9 @@
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QtQml/private/qqmlengine_p.h>
#include <QtQmlModels/private/qqmlmodelsmodule_p.h>
#if QT_CONFIG(qml_worker_script)
#include <QtQmlWorkerScript/private/qqmlworkerscriptmodule_p.h>
#endif
#endif // QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <private/qtquick2_p.h>
@ -63,6 +66,9 @@ public:
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QQmlEnginePrivate::registerQuickTypes();
QQmlModelsModule::registerQuickTypes();
#if QT_CONFIG(qml_worker_script)
QQmlWorkerScriptModule::registerQuickTypes();
#endif
#endif
QQmlQtQuick2Module::defineModule();

View File

@ -8,4 +8,6 @@ SOURCES += \
QT += quick-private qml-private qmlmodels-private
qtConfig(qml-worker-script): QT += qmlworkerscript-private
load(qml_plugin)

View File

@ -0,0 +1,2 @@
[
]

View File

@ -0,0 +1,81 @@
/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtQmlWorkerScript/private/qqmlworkerscriptmodule_p.h>
#include <QtQml/qqmlextensionplugin.h>
#include <QtQml/qqml.h>
QT_BEGIN_NAMESPACE
/*!
\qmlmodule QtQml.WorkerScript 2.\QtMinorVersion
\title Qt QML WorkerScript QML Types
\ingroup qmlmodules
\brief Provides QML types for worker scripts
\since 5.14
This QML module contains types for using worker scripts.
To use the types in this module, import the module with the following line:
\qml \QtMinorVersion
import QtQml.WorkerScript 2.\1
\endqml
*/
class QtQmlWorkerScriptPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
QtQmlWorkerScriptPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { }
void registerTypes(const char *uri) override
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQml.WorkerScript"));
QQmlWorkerScriptModule::defineModule();
// Auto-increment the import to stay in sync with ALL future QtQuick minor versions from 5.11 onward
qmlRegisterModule(uri, 2, QT_VERSION_MINOR);
}
};
QT_END_NAMESPACE
#include "plugin.moc"

View File

@ -0,0 +1,3 @@
module QtQml.WorkerScript
plugin workerscriptsplugin
classname QtQmlWorkerScriptPlugin

View File

@ -0,0 +1,11 @@
CXX_MODULE = qml
TARGET = workerscriptplugin
TARGETPATH = QtQml/WorkerScript.2
IMPORT_VERSION = 2.$$QT_MINOR_VERSION
SOURCES += \
plugin.cpp
QT = qml-private qmlworkerscript-private
load(qml_plugin)

View File

@ -42,7 +42,6 @@ SOURCES += \
$$PWD/qv4objectiterator.cpp \
$$PWD/qv4regexp.cpp \
$$PWD/qv4runtimecodegen.cpp \
$$PWD/qv4serialize.cpp \
$$PWD/qv4script.cpp \
$$PWD/qv4symbol.cpp \
$$PWD/qv4setobject.cpp \
@ -109,7 +108,6 @@ HEADERS += \
$$PWD/qv4property_p.h \
$$PWD/qv4objectiterator_p.h \
$$PWD/qv4regexp_p.h \
$$PWD/qv4serialize_p.h \
$$PWD/qv4script_p.h \
$$PWD/qv4symbol_p.h \
$$PWD/qv4setobject_p.h \

View File

@ -74,7 +74,7 @@ struct ObjectCtor: FunctionObject
static ReturnedValue virtualCall(const FunctionObject *m, const Value *thisObject, const Value *argv, int argc);
};
struct ObjectPrototype: Object
struct Q_QML_PRIVATE_EXPORT ObjectPrototype: Object
{
void init(ExecutionEngine *engine, Object *ctor);

View File

@ -198,13 +198,6 @@ QString RegExpObject::toString() const
return p;
}
QString RegExpObject::source() const
{
Scope scope(engine());
ScopedValue s(scope, get(scope.engine->id_source()));
return s->toQString();
}
ReturnedValue RegExpObject::builtinExec(ExecutionEngine *engine, const String *str)
{
QString s = str->toQString();

View File

@ -101,7 +101,7 @@ DECLARE_HEAP_OBJECT(RegExpCtor, FunctionObject) {
}
struct RegExpObject: Object {
struct Q_QML_PRIVATE_EXPORT RegExpObject: Object {
V4_OBJECT2(RegExpObject, Object)
Q_MANAGED_TYPE(RegExpObject)
V4_INTERNALCLASS(RegExpObject)
@ -145,7 +145,12 @@ struct RegExpObject: Object {
QRegularExpression toQRegularExpression() const;
#endif
QString toString() const;
QString source() const;
QString source() const
{
Scope scope(engine());
ScopedValue s(scope, get(scope.engine->id_source()));
return s->toQString();
}
Heap::RegExp *value() const { return d()->value; }
uint flags() const { return d()->value->flags; }

View File

@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE
namespace QV4 {
struct SequencePrototype : public QV4::Object
struct Q_QML_PRIVATE_EXPORT SequencePrototype : public QV4::Object
{
V4_PROTOTYPE(arrayPrototype)
void init();

View File

@ -87,9 +87,6 @@
#include <private/qqmltimer_p.h>
#endif
#include <private/qqmlplatform_p.h>
#if QT_CONFIG(qml_worker_script)
#include <private/qquickworkerscript_p.h>
#endif
#include <private/qqmlloggingcategory_p.h>
#ifdef Q_OS_WIN // for %APPDATA%
@ -239,9 +236,6 @@ void QQmlEnginePrivate::registerQuickTypes()
#endif
qmlRegisterType<QQmlLoggingCategory>(uri, 2, 8, "LoggingCategory");
qmlRegisterType<QQmlLoggingCategory, 1>(uri, 2, 12, "LoggingCategory");
#if QT_CONFIG(qml_worker_script)
qmlRegisterType<QQuickWorkerScript>(uri, 2, 0, "WorkerScript");
#endif
#if QT_CONFIG(qml_locale)
qmlRegisterUncreatableType<QQmlLocale>(uri, 2, 0, "Locale", QQmlEngine::tr("Locale cannot be instantiated. Use Qt.locale()"));
#endif
@ -968,16 +962,6 @@ void QQmlEnginePrivate::init()
rootContext = new QQmlContext(q,true);
}
#if QT_CONFIG(qml_worker_script)
QQuickWorkerScriptEngine *QQmlEnginePrivate::getWorkerScriptEngine()
{
Q_Q(QQmlEngine);
if (!workerScriptEngine)
workerScriptEngine = new QQuickWorkerScriptEngine(q);
return workerScriptEngine;
}
#endif
/*!
\class QQmlEngine
\since 5.0

View File

@ -94,7 +94,6 @@ class QQmlTypeNameCache;
class QQmlComponentAttached;
class QQmlCleanup;
class QQmlDelayedError;
class QQuickWorkerScriptEngine;
class QQmlObjectCreator;
class QDir;
class QQmlIncubator;
@ -154,8 +153,7 @@ public:
QV4::ExecutionEngine *v4engine() const { return q_func()->handle(); }
#if QT_CONFIG(qml_worker_script)
QQuickWorkerScriptEngine *getWorkerScriptEngine();
QQuickWorkerScriptEngine *workerScriptEngine;
QThread *workerScriptEngine;
#endif
QUrl baseUrl;

View File

@ -8,13 +8,6 @@ HEADERS += \
$$PWD/qqmlconnections_p.h \
$$PWD/qqmlmodelindexvaluetype_p.h
qtConfig(qml-worker-script) {
SOURCES += \
$$PWD/qquickworkerscript.cpp
HEADERS += \
$$PWD/qquickworkerscript_p.h
}
qtConfig(qml-animation) {
SOURCES += \
$$PWD/qqmltimer.cpp

View File

@ -0,0 +1,20 @@
TARGET = QtQmlWorkerScript
QT = core-private qml-private
DEFINES += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FOREACH
HEADERS += \
qqmlworkerscriptmodule_p.h \
qquickworkerscript_p.h \
qtqmlworkerscriptglobal.h \
qtqmlworkerscriptglobal_p.h \
qv4serialize_p.h
SOURCES += \
qqmlworkerscriptmodule.cpp \
qquickworkerscript.cpp \
qv4serialize.cpp
include(../3rdparty/masm/masm-defs.pri)
load(qt_module)

View File

@ -0,0 +1,62 @@
/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qqmlworkerscriptmodule_p.h"
#include "qquickworkerscript_p.h"
QT_BEGIN_NAMESPACE
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void QQmlWorkerScriptModule::registerQuickTypes()
{
// Don't add anything here. These are only for backwards compatibility.
const char uri[] = "QtQuick";
qmlRegisterType<QQuickWorkerScript>(uri, 2, 0, "WorkerScript");
}
#endif // QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void QQmlWorkerScriptModule::defineModule()
{
const char uri[] = "QtQml.WorkerScript";
qmlRegisterType<QQuickWorkerScript>(uri, 2, 0, "WorkerScript");
}
QT_END_NAMESPACE

View File

@ -0,0 +1,69 @@
/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QQMLWORKERSCRIPTMODULE_P_H
#define QQMLWORKERSCRIPTMODULE_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <private/qtqmlworkerscriptglobal_p.h>
QT_BEGIN_NAMESPACE
class Q_QMLWORKERSCRIPT_PRIVATE_EXPORT QQmlWorkerScriptModule
{
public:
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
static void registerQuickTypes();
#endif
static void defineModule();
};
QT_END_NAMESPACE
#endif // QQMLWORKERSCRIPTMODULE_P_H

View File

@ -37,7 +37,7 @@
**
****************************************************************************/
#include "qtqmlglobal_p.h"
#include "qtqmlworkerscriptglobal_p.h"
#include "qquickworkerscript_p.h"
#include <private/qqmlengine_p.h>
#include <private/qqmlexpression_p.h>
@ -618,7 +618,11 @@ QQuickWorkerScriptEngine *QQuickWorkerScript::engine()
return nullptr;
}
m_engine = QQmlEnginePrivate::get(engine)->getWorkerScriptEngine();
QQmlEnginePrivate *enginePrivate = QQmlEnginePrivate::get(engine);
if (enginePrivate->workerScriptEngine == nullptr)
enginePrivate->workerScriptEngine = new QQuickWorkerScriptEngine(engine);
m_engine = qobject_cast<QQuickWorkerScriptEngine *>(enginePrivate->workerScriptEngine);
Q_ASSERT(m_engine);
m_scriptId = m_engine->registerWorkerScript(this);
if (m_source.isValid())

View File

@ -0,0 +1,58 @@
/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QTQMLWORKERSCRIPTGLOBAL_H
#define QTQMLWORKERSCRIPTGLOBAL_H
#include <QtQml/qtqmlglobal.h>
QT_BEGIN_NAMESPACE
#if !defined(QT_STATIC)
# if defined(QT_BUILD_QMLWORKERSCRIPT_LIB)
# define Q_QMLWORKERSCRIPT_EXPORT Q_DECL_EXPORT
# else
# define Q_QMLWORKERSCRIPT_EXPORT Q_DECL_IMPORT
# endif
#else
# define Q_QMLWORKERSCRIPT_EXPORT
#endif
QT_END_NAMESPACE
#endif // QTQMLWORKERSCRIPTGLOBAL_H

View File

@ -0,0 +1,60 @@
/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QTQMLWORKERSCRIPTGLOBAL_P_H
#define QTQMLWORKERSCRIPTGLOBAL_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtQml/private/qtqmlglobal_p.h>
#include <QtQmlWorkerScript/qtqmlworkerscriptglobal.h>
#define Q_QMLWORKERSCRIPT_PRIVATE_EXPORT Q_QMLWORKERSCRIPT_EXPORT
#define Q_QMLWORKERSCRIPT_AUTOTEST_EXPORT Q_AUTOTEST_EXPORT
#endif // QTQMLWORKERSCRIPTGLOBAL_P_H

View File

@ -7,6 +7,8 @@ SUBDIRS += \
qml \
qmlmodels
qtConfig(qml-worker-script): \
SUBDIRS += qmlworkerscript
qtHaveModule(gui):qtConfig(qml-animation) {
SUBDIRS += \

View File

@ -8,6 +8,7 @@
"QtPacketProtocol" => "$basedir/src/plugins/qmltooling/packetprotocol",
"QtQmlDebug" => "$basedir/src/qmldebug",
"QtQmlModels" => "$basedir/src/qmlmodels",
"QtQmlWorkerScript" => "$basedir/src/qmlworkerscript",
);
%inject_headers = (
"$basedir/src/qml" => [ "^qqmljsgrammar_p.h", "^qqmljsparser_p.h" ],

View File

@ -8,4 +8,4 @@ include (../../shared/util.pri)
TESTDATA = data/*
QT += core-private gui-private qml-private testlib
QT += core-private gui-private qml-private testlib qmlworkerscript-private