aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-12-14 19:01:23 +0100
committerLiang Qi <liang.qi@qt.io>2016-12-14 19:01:23 +0100
commit0e80d28aa5892d6bbb4d0017b1bc9a33489f4176 (patch)
tree0db2e10c8776d172bccaeaa7ee1fab3934b93073 /src/qml/qml
parented32558d6280cae40578f735fd326327d571d993 (diff)
parent16c81bb0d493af00bc376784bcb7e03a4a037b04 (diff)
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts: src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp src/qml/qml/qqmlimport.cpp src/quick/items/context2d/qquickcontext2dtexture_p.h tools/qmleasing/splineeditor.h Change-Id: I8f6630fcac243824350986c8e9f4bd6483bf20b5
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qml.pri3
-rw-r--r--src/qml/qml/qqmlapplicationengine.cpp6
-rw-r--r--src/qml/qml/qqmlapplicationengine_p.h2
-rw-r--r--src/qml/qml/qqmlbinding.cpp73
-rw-r--r--src/qml/qml/qqmlbinding_p.h10
-rw-r--r--src/qml/qml/qqmlboundsignal.cpp68
-rw-r--r--src/qml/qml/qqmlboundsignal_p.h6
-rw-r--r--src/qml/qml/qqmlcontextwrapper.cpp323
-rw-r--r--src/qml/qml/qqmlcontextwrapper_p.h105
-rw-r--r--src/qml/qml/qqmldelayedcallqueue.cpp1
-rw-r--r--src/qml/qml/qqmlerror.cpp2
-rw-r--r--src/qml/qml/qqmlexpression.cpp4
-rw-r--r--src/qml/qml/qqmlglobal.cpp2
-rw-r--r--src/qml/qml/qqmlglobal_p.h2
-rw-r--r--src/qml/qml/qqmlimport.cpp14
-rw-r--r--src/qml/qml/qqmljavascriptexpression.cpp59
-rw-r--r--src/qml/qml/qqmljavascriptexpression_p.h13
-rw-r--r--src/qml/qml/qqmllocale.cpp64
-rw-r--r--src/qml/qml/qqmlmetatype.cpp2
-rw-r--r--src/qml/qml/qqmlnotifier.cpp6
-rw-r--r--src/qml/qml/qqmlnotifier_p.h2
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp25
-rw-r--r--src/qml/qml/qqmlproperty_p.h16
-rw-r--r--src/qml/qml/qqmlstringconverters.cpp12
-rw-r--r--src/qml/qml/qqmlstringconverters_p.h2
-rw-r--r--src/qml/qml/qqmltypeloader.cpp3
-rw-r--r--src/qml/qml/qqmltypewrapper.cpp1
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp7
-rw-r--r--src/qml/qml/qqmlvme.cpp1
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp6
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp11
-rw-r--r--src/qml/qml/qqmlxmlhttprequest_p.h4
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp37
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions_p.h18
-rw-r--r--src/qml/qml/v8/qv8engine.cpp5
35 files changed, 220 insertions, 695 deletions
diff --git a/src/qml/qml/qml.pri b/src/qml/qml/qml.pri
index 8d8da3742d..412dc6cba2 100644
--- a/src/qml/qml/qml.pri
+++ b/src/qml/qml/qml.pri
@@ -42,7 +42,6 @@ SOURCES += \
$$PWD/qqmlabstracturlinterceptor.cpp \
$$PWD/qqmlapplicationengine.cpp \
$$PWD/qqmllistwrapper.cpp \
- $$PWD/qqmlcontextwrapper.cpp \
$$PWD/qqmlvaluetypewrapper.cpp \
$$PWD/qqmltypewrapper.cpp \
$$PWD/qqmlfileselector.cpp \
@@ -113,8 +112,6 @@ HEADERS += \
$$PWD/qqmlapplicationengine_p.h \
$$PWD/qqmlapplicationengine.h \
$$PWD/qqmllistwrapper_p.h \
- $$PWD/qqmlcontextwrapper_p.h \
- $$PWD/qqmlvaluetypewrapper_p.h \
$$PWD/qqmltypewrapper_p.h \
$$PWD/qqmlfileselector_p.h \
$$PWD/qqmlfileselector.h \
diff --git a/src/qml/qml/qqmlapplicationengine.cpp b/src/qml/qml/qqmlapplicationengine.cpp
index 1a912d53e6..8a97b7eba7 100644
--- a/src/qml/qml/qqmlapplicationengine.cpp
+++ b/src/qml/qml/qqmlapplicationengine.cpp
@@ -58,7 +58,7 @@ QQmlApplicationEnginePrivate::~QQmlApplicationEnginePrivate()
void QQmlApplicationEnginePrivate::cleanUp()
{
qDeleteAll(objects);
-#ifndef QT_NO_TRANSLATION
+#if QT_CONFIG(translation)
qDeleteAll(translators);
#endif
}
@@ -70,7 +70,7 @@ void QQmlApplicationEnginePrivate::init()
q, SLOT(_q_finishLoad(QObject*)));
q->connect(q, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit()));
q->connect(q, &QQmlApplicationEngine::exit, QCoreApplication::instance(), &QCoreApplication::exit);
-#ifndef QT_NO_TRANSLATION
+#if QT_CONFIG(translation)
QTranslator* qtTranslator = new QTranslator;
if (qtTranslator->load(QLatin1String("qt_") + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
QCoreApplication::installTranslator(qtTranslator);
@@ -82,7 +82,7 @@ void QQmlApplicationEnginePrivate::init()
void QQmlApplicationEnginePrivate::loadTranslations(const QUrl &rootFile)
{
-#ifndef QT_NO_TRANSLATION
+#if QT_CONFIG(translation)
if (rootFile.scheme() != QLatin1String("file") && rootFile.scheme() != QLatin1String("qrc"))
return;
diff --git a/src/qml/qml/qqmlapplicationengine_p.h b/src/qml/qml/qqmlapplicationengine_p.h
index e1d1b4a7bb..8c342a43a9 100644
--- a/src/qml/qml/qqmlapplicationengine_p.h
+++ b/src/qml/qml/qqmlapplicationengine_p.h
@@ -78,7 +78,7 @@ public:
QSignalMapper statusMapper;
QObject *appObj;
-#ifndef QT_NO_TRANSLATIONS
+#if QT_CONFIG(translation)
QList<QTranslator *> translators;
#endif
};
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp
index 4fe76ddf29..284ae1f36f 100644
--- a/src/qml/qml/qqmlbinding.cpp
+++ b/src/qml/qml/qqmlbinding.cpp
@@ -46,7 +46,6 @@
#include <private/qqmlprofiler_p.h>
#include <private/qqmlexpression_p.h>
#include <private/qqmlscriptstring_p.h>
-#include <private/qqmlcontextwrapper_p.h>
#include <private/qqmlbuiltinfunctions_p.h>
#include <private/qqmlvmemetaobject_p.h>
#include <private/qqmlvaluetypewrapper_p.h>
@@ -58,18 +57,6 @@
QT_BEGIN_NAMESPACE
-QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QString &str, QObject *obj, QQmlContext *ctxt)
-{
- QQmlBinding *b = newBinding(QQmlEnginePrivate::get(ctxt), property);
- b->setNotifyOnValueChanged(true);
- b->QQmlJavaScriptExpression::setContext(QQmlContextData::get(ctxt));
- b->setScopeObject(obj);
-
- b->createQmlBinding(b->context(), obj, str, QString(), 0);
-
- return b;
-}
-
QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QQmlScriptString &script, QObject *obj, QQmlContext *ctxt)
{
QQmlBinding *b = newBinding(QQmlEnginePrivate::get(ctxt), property);
@@ -98,7 +85,9 @@ QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QQmlScr
QV4::ExecutionEngine *v4 = QQmlEnginePrivate::get(b->context()->engine)->v4engine();
if (runtimeFunction) {
- b->m_function.set(v4, QV4::FunctionObject::createQmlFunction(ctxtdata, b->scopeObject(), runtimeFunction));
+ QV4::Scope scope(v4);
+ QV4::Scoped<QV4::QmlContext> qmlContext(scope, QV4::QmlContext::create(v4->rootContext(), ctxtdata, b->scopeObject()));
+ b->setupFunction(qmlContext, runtimeFunction);
} else {
QString code = scriptPrivate->script;
b->createQmlBinding(b->context(), b->scopeObject(), code, url, scriptPrivate->lineNumber);
@@ -107,26 +96,11 @@ QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QQmlScr
return b;
}
-QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QString &str, QObject *obj, QQmlContextData *ctxt)
-{
- QQmlBinding *b = newBinding(QQmlEnginePrivate::get(ctxt), property);
-
- b->setNotifyOnValueChanged(true);
- b->QQmlJavaScriptExpression::setContext(ctxt);
- b->setScopeObject(obj);
-
- b->createQmlBinding(ctxt, obj, str, QString(), 0);
-
- return b;
-}
-
QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QString &str, QObject *obj,
- QQmlContextData *ctxt, const QString &url, quint16 lineNumber,
- quint16 columnNumber)
+ QQmlContextData *ctxt, const QString &url, quint16 lineNumber)
{
QQmlBinding *b = newBinding(QQmlEnginePrivate::get(ctxt), property);
- Q_UNUSED(columnNumber);
b->setNotifyOnValueChanged(true);
b->QQmlJavaScriptExpression::setContext(ctxt);
b->setScopeObject(obj);
@@ -136,7 +110,8 @@ QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QString
return b;
}
-QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QV4::Value &functionPtr, QObject *obj, QQmlContextData *ctxt)
+QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, QV4::Function *function,
+ QObject *obj, QQmlContextData *ctxt, QV4::ExecutionContext *scope)
{
QQmlBinding *b = newBinding(QQmlEnginePrivate::get(ctxt), property);
@@ -144,7 +119,8 @@ QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QV4::Va
b->QQmlJavaScriptExpression::setContext(ctxt);
b->setScopeObject(obj);
- b->m_function.set(functionPtr.as<QV4::Object>()->engine(), functionPtr);
+ Q_ASSERT(scope);
+ b->setupFunction(scope, function);
return b;
}
@@ -183,14 +159,12 @@ void QQmlBinding::update(QQmlPropertyData::WriteFlags flags)
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context()->engine);
QV4::Scope scope(ep->v4engine());
- QV4::ScopedFunctionObject f(scope, m_function.value());
- Q_ASSERT(f);
if (canUseAccessor())
flags.setFlag(QQmlPropertyData::BypassInterceptor);
- QQmlBindingProfiler prof(ep->profiler, this, f);
- doUpdate(watcher, flags, scope, f);
+ QQmlBindingProfiler prof(ep->profiler, this, function());
+ doUpdate(watcher, flags, scope);
if (!watcher.wasDeleted())
setUpdatingFlag(false);
@@ -205,8 +179,7 @@ class QQmlBindingBinding: public QQmlBinding
{
protected:
void doUpdate(const DeleteWatcher &,
- QQmlPropertyData::WriteFlags flags, QV4::Scope &,
- const QV4::ScopedFunctionObject &) Q_DECL_OVERRIDE Q_DECL_FINAL
+ QQmlPropertyData::WriteFlags flags, QV4::Scope &) Q_DECL_OVERRIDE Q_DECL_FINAL
{
Q_ASSERT(!m_targetIndex.hasValueTypeIndex());
QQmlPropertyData *pd = nullptr;
@@ -222,8 +195,7 @@ class QQmlNonbindingBinding: public QQmlBinding
{
protected:
void doUpdate(const DeleteWatcher &watcher,
- QQmlPropertyData::WriteFlags flags, QV4::Scope &scope,
- const QV4::ScopedFunctionObject &f) Q_DECL_OVERRIDE Q_DECL_FINAL
+ QQmlPropertyData::WriteFlags flags, QV4::Scope &scope) Q_DECL_OVERRIDE Q_DECL_FINAL
{
auto ep = QQmlEnginePrivate::get(scope.engine);
ep->referenceScarceResources();
@@ -240,7 +212,7 @@ protected:
if (!watcher.wasDeleted()) {
if (error) {
- delayedError()->setErrorLocation(f->sourceLocation());
+ delayedError()->setErrorLocation(sourceLocation());
delayedError()->setErrorObject(m_target.data());
}
@@ -250,10 +222,9 @@ protected:
clearError();
}
+ cancelPermanentGuards();
}
- cancelPermanentGuards();
-
ep->dereferenceScarceResources();
}
@@ -451,14 +422,10 @@ QVariant QQmlBinding::evaluate()
QString QQmlBinding::expressionIdentifier() const
{
- QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context()->engine);
- QV4::Scope scope(ep->v4engine());
- QV4::ScopedValue f(scope, m_function.value());
- QV4::Function *function = f->as<QV4::FunctionObject>()->function();
-
- QString url = function->sourceFile();
- quint16 lineNumber = function->compiledFunction->location.line;
- quint16 columnNumber = function->compiledFunction->location.column;
+ auto f = function();
+ QString url = f->sourceFile();
+ quint16 lineNumber = f->compiledFunction->location.line;
+ quint16 columnNumber = f->compiledFunction->location.column;
return url + QString::asprintf(":%u:%u", uint(lineNumber), uint(columnNumber));
}
@@ -489,9 +456,7 @@ void QQmlBinding::setEnabled(bool e, QQmlPropertyData::WriteFlags flags)
QString QQmlBinding::expression() const
{
- QV4::Scope scope(QQmlEnginePrivate::get(context()->engine)->v4engine());
- QV4::ScopedValue v(scope, m_function.value());
- return v->toQStringNoThrow();
+ return QStringLiteral("function() { [code] }");
}
void QQmlBinding::setTarget(const QQmlProperty &prop)
diff --git a/src/qml/qml/qqmlbinding_p.h b/src/qml/qml/qqmlbinding_p.h
index be23a96d01..0f2fb329f5 100644
--- a/src/qml/qml/qqmlbinding_p.h
+++ b/src/qml/qml/qqmlbinding_p.h
@@ -72,12 +72,11 @@ class Q_QML_PRIVATE_EXPORT QQmlBinding : public QQmlJavaScriptExpression,
{
friend class QQmlAbstractBinding;
public:
- static QQmlBinding *create(const QQmlPropertyData *, const QString &, QObject *, QQmlContext *);
static QQmlBinding *create(const QQmlPropertyData *, const QQmlScriptString &, QObject *, QQmlContext *);
- static QQmlBinding *create(const QQmlPropertyData *, const QString &, QObject *, QQmlContextData *);
static QQmlBinding *create(const QQmlPropertyData *, const QString &, QObject *, QQmlContextData *,
- const QString &url, quint16 lineNumber, quint16 columnNumber);
- static QQmlBinding *create(const QQmlPropertyData *, const QV4::Value &, QObject *, QQmlContextData *);
+ const QString &url = QString(), quint16 lineNumber = 0);
+ static QQmlBinding *create(const QQmlPropertyData *property, QV4::Function *function,
+ QObject *obj, QQmlContextData *ctxt, QV4::ExecutionContext *scope);
~QQmlBinding();
void setTarget(const QQmlProperty &);
@@ -103,8 +102,7 @@ public:
protected:
virtual void doUpdate(const DeleteWatcher &watcher,
- QQmlPropertyData::WriteFlags flags, QV4::Scope &scope,
- const QV4::ScopedFunctionObject &f) = 0;
+ QQmlPropertyData::WriteFlags flags, QV4::Scope &scope) = 0;
void getPropertyData(QQmlPropertyData **propertyData, QQmlPropertyData *valueTypeData) const;
int getPropertyType() const;
diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp
index dfb1b98ca0..254d5e1907 100644
--- a/src/qml/qml/qqmlboundsignal.cpp
+++ b/src/qml/qml/qqmlboundsignal.cpp
@@ -98,20 +98,20 @@ QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index,
function += parameterString;
function += QLatin1String(") { ") + expression + QLatin1String(" })");
- m_function.set(v4, evalFunction(context(), scopeObject(), function, fileName, line));
-
- if (m_function.isNullOrUndefined())
- return; // could not evaluate function. Not valid.
-
+ QV4::Scope valueScope(v4);
+ QV4::ScopedFunctionObject f(valueScope, evalFunction(context(), scopeObject(), function, fileName, line));
+ QV4::ScopedContext context(valueScope, f->scope());
+ setupFunction(context, f->function());
}
-QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, QQmlContextData *ctxt, QObject *scope, const QV4::Value &function)
+QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, QQmlContextData *ctxt, QObject *scopeObject,
+ QV4::Function *function, QV4::ExecutionContext *scope)
: QQmlJavaScriptExpression(),
m_index(index),
m_target(target)
{
- m_function.set(function.as<QV4::Object>()->engine(), function);
- init(ctxt, scope);
+ setupFunction(scope, function);
+ init(ctxt, scopeObject);
}
QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, QQmlContextData *ctxt, QObject *scope, QV4::Function *runtimeFunction)
@@ -122,14 +122,22 @@ QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index,
// It's important to call init first, because m_index gets remapped in case of cloned signals.
init(ctxt, scope);
- QMetaMethod signal = QMetaObjectPrivate::signal(m_target->metaObject(), m_index);
- QString error;
QV4::ExecutionEngine *engine = QQmlEnginePrivate::getV4Engine(ctxt->engine);
- m_function.set(engine, QV4::FunctionObject::createQmlFunction(ctxt, scope, runtimeFunction, signal.parameterNames(), &error));
- if (!error.isEmpty()) {
- qmlInfo(scopeObject()) << error;
- m_function.clear();
+
+ QList<QByteArray> signalParameters = QMetaObjectPrivate::signal(m_target->metaObject(), m_index).parameterNames();
+ if (!signalParameters.isEmpty()) {
+ QString error;
+ QQmlPropertyCache::signalParameterStringForJS(engine, signalParameters, &error);
+ if (!error.isEmpty()) {
+ qmlInfo(scopeObject()) << error;
+ return;
+ }
+ runtimeFunction->updateInternalClass(engine, signalParameters);
}
+
+ QV4::Scope valueScope(engine);
+ QV4::Scoped<QV4::QmlContext> qmlContext(valueScope, QV4::QmlContext::create(engine->rootContext(), ctxt, scope));
+ setupFunction(qmlContext, runtimeFunction);
}
void QQmlBoundSignalExpression::init(QQmlContextData *ctxt, QObject *scope)
@@ -157,41 +165,13 @@ void QQmlBoundSignalExpression::expressionChanged()
// bound signals do not notify on change.
}
-QQmlSourceLocation QQmlBoundSignalExpression::sourceLocation() const
-{
- QV4::Function *f = function();
- if (f) {
- QQmlSourceLocation loc;
- loc.sourceFile = f->sourceFile();
- loc.line = f->compiledFunction->location.line;
- loc.column = f->compiledFunction->location.column;
- return loc;
- }
- return QQmlSourceLocation();
-}
-
QString QQmlBoundSignalExpression::expression() const
{
- if (expressionFunctionValid()) {
- Q_ASSERT (context() && engine());
- QV4::Scope scope(QQmlEnginePrivate::get(engine())->v4engine());
- QV4::ScopedValue v(scope, m_function.value());
- return v->toQStringNoThrow();
- }
+ if (expressionFunctionValid())
+ return QStringLiteral("function() { [code] }");
return QString();
}
-QV4::Function *QQmlBoundSignalExpression::function() const
-{
- if (expressionFunctionValid()) {
- Q_ASSERT (context() && engine());
- QV4::Scope scope(QQmlEnginePrivate::get(engine())->v4engine());
- QV4::ScopedFunctionObject v(scope, m_function.value());
- return v ? v->function() : 0;
- }
- return 0;
-}
-
// Parts of this function mirror code in QQmlExpressionPrivate::value() and v8value().
// Changes made here may need to be made there and vice versa.
void QQmlBoundSignalExpression::evaluate(void **a)
diff --git a/src/qml/qml/qqmlboundsignal_p.h b/src/qml/qml/qqmlboundsignal_p.h
index 4356c6cbfa..3a0b8aed59 100644
--- a/src/qml/qml/qqmlboundsignal_p.h
+++ b/src/qml/qml/qqmlboundsignal_p.h
@@ -73,7 +73,7 @@ public:
const QString &parameterString = QString());
QQmlBoundSignalExpression(QObject *target, int index,
- QQmlContextData *ctxt, QObject *scope, const QV4::Value &function);
+ QQmlContextData *ctxt, QObject *scopeObject, QV4::Function *function, QV4::ExecutionContext *scope);
QQmlBoundSignalExpression(QObject *target, int index,
QQmlContextData *ctxt, QObject *scope, QV4::Function *runtimeFunction);
@@ -86,9 +86,7 @@ public:
void evaluate(void **a);
void evaluate(const QList<QVariant> &args);
- QQmlSourceLocation sourceLocation() const;
QString expression() const;
- QV4::Function *function() const;
QObject *target() const { return m_target; }
QQmlEngine *engine() const { return context() ? context()->engine : 0; }
@@ -98,7 +96,7 @@ private:
void init(QQmlContextData *ctxt, QObject *scope);
- bool expressionFunctionValid() const { return !m_function.isNullOrUndefined(); }
+ bool expressionFunctionValid() const { return function() != 0; }
int m_index;
QObject *m_target;
diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp
deleted file mode 100644
index 2418003519..0000000000
--- a/src/qml/qml/qqmlcontextwrapper.cpp
+++ /dev/null
@@ -1,323 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 "qqmlcontextwrapper_p.h"
-#include <private/qv8engine_p.h>
-
-#include <private/qqmlengine_p.h>
-#include <private/qqmlcontext_p.h>
-
-#include <private/qv4engine_p.h>
-#include <private/qv4value_p.h>
-#include <private/qv4objectproto_p.h>
-#include <private/qv4mm_p.h>
-#include <private/qv4function_p.h>
-#include <private/qv4compileddata_p.h>
-#include <private/qqmltypewrapper_p.h>
-#include <private/qqmllistwrapper_p.h>
-#include <private/qqmljavascriptexpression_p.h>
-#include <private/qjsvalue_p.h>
-#include <private/qv4qobjectwrapper_p.h>
-
-QT_BEGIN_NAMESPACE
-
-using namespace QV4;
-
-DEFINE_OBJECT_VTABLE(QmlContextWrapper);
-
-void Heap::QmlContextWrapper::init(QQmlContextData *context, QObject *scopeObject, bool ownsContext)
-{
- Object::init();
- readOnly = true;
- this->ownsContext = ownsContext;
- isNullWrapper = false;
- this->context = new QQmlGuardedContextData(context);
- this->scopeObject.init(scopeObject);
-}
-
-void Heap::QmlContextWrapper::destroy()
-{
- if (*context && ownsContext)
- (*context)->destroy();
- delete context;
- scopeObject.destroy();
- Object::destroy();
-}
-
-ReturnedValue QmlContextWrapper::qmlScope(ExecutionEngine *v4, QQmlContextData *ctxt, QObject *scope)
-{
- Scope valueScope(v4);
-
- Scoped<QmlContextWrapper> w(valueScope, v4->memoryManager->allocObject<QmlContextWrapper>(ctxt, scope));
- return w.asReturnedValue();
-}
-
-ReturnedValue QmlContextWrapper::urlScope(ExecutionEngine *v4, const QUrl &url)
-{
- Scope scope(v4);
-
- QQmlContextData *context = new QQmlContextData;
- context->baseUrl = url;
- context->baseUrlString = url.toString();
- context->isInternal = true;
- context->isJSContext = true;
-
- Scoped<QmlContextWrapper> w(scope, v4->memoryManager->allocObject<QmlContextWrapper>(context, (QObject*)0, true));
- w->d()->isNullWrapper = true;
- return w.asReturnedValue();
-}
-
-ReturnedValue QmlContextWrapper::get(const Managed *m, String *name, bool *hasProperty)
-{
- Q_ASSERT(m->as<QmlContextWrapper>());
- const QmlContextWrapper *resource = static_cast<const QmlContextWrapper *>(m);
- QV4::ExecutionEngine *v4 = resource->engine();
- QV4::Scope scope(v4);
-
- // In V8 the JS global object would come _before_ the QML global object,
- // so simulate that here.
- bool hasProp;
- QV4::ScopedValue result(scope, v4->globalObject->get(name, &hasProp));
- if (hasProp) {
- if (hasProperty)
- *hasProperty = hasProp;
- return result->asReturnedValue();
- }
-
- if (resource->d()->isNullWrapper)
- return Object::get(m, name, hasProperty);
-
- if (v4->callingQmlContext() != *resource->d()->context)
- return Object::get(m, name, hasProperty);
-
- result = Object::get(m, name, &hasProp);
- if (hasProp) {
- if (hasProperty)
- *hasProperty = hasProp;
- return result->asReturnedValue();
- }
-
- // Its possible we could delay the calculation of the "actual" context (in the case
- // of sub contexts) until it is definately needed.
- QQmlContextData *context = resource->getContext();
- QQmlContextData *expressionContext = context;
-
- if (!context) {
- if (hasProperty)
- *hasProperty = true;
- return result->asReturnedValue();
- }
-
- // Search type (attached property/enum/imported scripts) names
- // while (context) {
- // Search context properties
- // Search scope object
- // Search context object
- // context = context->parent
- // }
-
- QObject *scopeObject = resource->getScopeObject();
-
- if (context->imports && name->startsWithUpper()) {
- // Search for attached properties, enums and imported scripts
- QQmlTypeNameCache::Result r = context->imports->query(name);
-
- if (r.isValid()) {
- if (hasProperty)
- *hasProperty = true;
- if (r.scriptIndex != -1) {
- QV4::ScopedObject scripts(scope, context->importedScripts.valueRef());
- return scripts->getIndexed(r.scriptIndex);
- } else if (r.type) {
- return QmlTypeWrapper::create(v4, scopeObject, r.type);
- } else if (r.importNamespace) {
- return QmlTypeWrapper::create(v4, scopeObject, context->imports, r.importNamespace);
- }
- Q_ASSERT(!"Unreachable");
- }
-
- // Fall through
- }
-
- QQmlEnginePrivate *ep = QQmlEnginePrivate::get(v4->qmlEngine());
-
- while (context) {
- // Search context properties
- const QV4::IdentifierHash<int> &properties = context->propertyNames();
- if (properties.count()) {
- int propertyIdx = properties.value(name);
-
- if (propertyIdx != -1) {
-
- if (propertyIdx < context->idValueCount) {
-
- if (ep->propertyCapture)
- ep->propertyCapture->captureProperty(&context->idValues[propertyIdx].bindings);
- if (hasProperty)
- *hasProperty = true;
- return QV4::QObjectWrapper::wrap(v4, context->idValues[propertyIdx]);
- } else {
-
- QQmlContextPrivate *cp = context->asQQmlContextPrivate();
-
- if (ep->propertyCapture)
- ep->propertyCapture->captureProperty(context->asQQmlContext(), -1, propertyIdx + cp->notifyIndex);
-
- const QVariant &value = cp->propertyValues.at(propertyIdx);
- if (hasProperty)
- *hasProperty = true;
- if (value.userType() == qMetaTypeId<QList<QObject*> >()) {
- QQmlListProperty<QObject> prop(context->asQQmlContext(), (void*) qintptr(propertyIdx),
- QQmlContextPrivate::context_count,
- QQmlContextPrivate::context_at);
- return QmlListWrapper::create(v4, prop, qMetaTypeId<QQmlListProperty<QObject> >());
- } else {
- return scope.engine->fromVariant(cp->propertyValues.at(propertyIdx));
- }
- }
- }
- }
-
- // Search scope object
- if (scopeObject) {
- bool hasProp = false;
- QV4::ScopedValue result(scope, QV4::QObjectWrapper::getQmlProperty(v4, context, scopeObject,
- name, QV4::QObjectWrapper::CheckRevision, &hasProp));
- if (hasProp) {
- if (hasProperty)
- *hasProperty = true;
- return result->asReturnedValue();
- }
- }
- scopeObject = 0;
-
-
- // Search context object
- if (context->contextObject) {
- bool hasProp = false;
- result = QV4::QObjectWrapper::getQmlProperty(v4, context, context->contextObject, name, QV4::QObjectWrapper::CheckRevision, &hasProp);
- if (hasProp) {
- if (hasProperty)
- *hasProperty = true;
- return result->asReturnedValue();
- }
- }
-
- context = context->parent;
- }
-
- expressionContext->unresolvedNames = true;
-
- return Encode::undefined();
-}
-
-void QmlContextWrapper::put(Managed *m, String *name, const Value &value)
-{
- Q_ASSERT(m->as<QmlContextWrapper>());
- QmlContextWrapper *resource = static_cast<QmlContextWrapper *>(m);
- ExecutionEngine *v4 = resource->engine();
- QV4::Scope scope(v4);
- if (scope.hasException())
- return;
- QV4::Scoped<QmlContextWrapper> wrapper(scope, resource);
-
- uint member = wrapper->internalClass()->find(name);
- if (member < UINT_MAX) {
- wrapper->putValue(member, value);
- return;
- }
-
- if (wrapper->d()->isNullWrapper) {
- if (wrapper && wrapper->d()->readOnly) {
- QString error = QLatin1String("Invalid write to global property \"") + name->toQString() +
- QLatin1Char('"');
- ScopedString e(scope, v4->newString(error));
- v4->throwError(e);
- return;
- }
-
- Object::put(m, name, value);
- return;
- }
-
- // Its possible we could delay the calculation of the "actual" context (in the case
- // of sub contexts) until it is definately needed.
- QQmlContextData *context = wrapper->getContext();
- QQmlContextData *expressionContext = context;
-
- if (!context)
- return;
-
- // See QV8ContextWrapper::Getter for resolution order
-
- QObject *scopeObject = wrapper->getScopeObject();
-
- while (context) {
- const QV4::IdentifierHash<int> &properties = context->propertyNames();
- // Search context properties
- if (properties.count() && properties.value(name) != -1)
- return;
-
- // Search scope object
- if (scopeObject &&
- QV4::QObjectWrapper::setQmlProperty(v4, context, scopeObject, name, QV4::QObjectWrapper::CheckRevision, value))
- return;
- scopeObject = 0;
-
- // Search context object
- if (context->contextObject &&
- QV4::QObjectWrapper::setQmlProperty(v4, context, context->contextObject, name, QV4::QObjectWrapper::CheckRevision, value))
- return;
-
- context = context->parent;
- }
-
- expressionContext->unresolvedNames = true;
-
- if (wrapper->d()->readOnly) {
- QString error = QLatin1String("Invalid write to global property \"") + name->toQString() +
- QLatin1Char('"');
- v4->throwError(error);
- return;
- }
-
- Object::put(m, name, value);
-}
-
-QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlcontextwrapper_p.h b/src/qml/qml/qqmlcontextwrapper_p.h
deleted file mode 100644
index 126ffecf0d..0000000000
--- a/src/qml/qml/qqmlcontextwrapper_p.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 QQMLCONTEXTWRAPPER_P_H
-#define QQMLCONTEXTWRAPPER_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 <QtCore/qglobal.h>
-#include <private/qtqmlglobal_p.h>
-
-#include <private/qv4object_p.h>
-#include <private/qqmlcontext_p.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace QV4 {
-
-namespace Heap {
-
-struct QmlContextWrapper : Object {
- void init(QQmlContextData *context, QObject *scopeObject, bool ownsContext = false);
- void destroy();
- bool readOnly;
- bool ownsContext;
- bool isNullWrapper;
-
- QQmlGuardedContextData *context;
- QQmlQPointer<QObject> scopeObject;
-};
-
-}
-
-struct Q_QML_EXPORT QmlContextWrapper : Object
-{
- V4_OBJECT2(QmlContextWrapper, Object)
- V4_NEEDS_DESTROY
-
- static ReturnedValue qmlScope(ExecutionEngine *e, QQmlContextData *ctxt, QObject *scope);
- static ReturnedValue urlScope(ExecutionEngine *v4, const QUrl &);
-
- void takeContextOwnership() {
- d()->ownsContext = true;
- }
-
- inline QObject *getScopeObject() const { return d()->scopeObject; }
- inline QQmlContextData *getContext() const { return *d()->context; }
-
- void setReadOnly(bool b) { d()->readOnly = b; }
-
- static ReturnedValue get(const Managed *m, String *name, bool *hasProperty);
- static void put(Managed *m, String *name, const Value &value);
-};
-
-}
-
-QT_END_NAMESPACE
-
-#endif // QV8CONTEXTWRAPPER_P_H
-
diff --git a/src/qml/qml/qqmldelayedcallqueue.cpp b/src/qml/qml/qqmldelayedcallqueue.cpp
index d10a8c7718..7552e1e82b 100644
--- a/src/qml/qml/qqmldelayedcallqueue.cpp
+++ b/src/qml/qml/qqmldelayedcallqueue.cpp
@@ -43,7 +43,6 @@
#include <private/qqmljavascriptexpression_p.h>
#include <private/qv4value_p.h>
#include <private/qv4qobjectwrapper_p.h>
-#include <private/qqmlcontextwrapper_p.h>
#include <QQmlError>
diff --git a/src/qml/qml/qqmlerror.cpp b/src/qml/qml/qqmlerror.cpp
index b309550ca8..0a6c7b4960 100644
--- a/src/qml/qml/qqmlerror.cpp
+++ b/src/qml/qml/qqmlerror.cpp
@@ -285,7 +285,7 @@ QDebug operator<<(QDebug debug, const QQmlError &error)
if (f.open(QIODevice::ReadOnly)) {
QByteArray data = f.readAll();
QTextStream stream(data, QIODevice::ReadOnly);
-#ifndef QT_NO_TEXTCODEC
+#if QT_CONFIG(textcodec)
stream.setCodec("UTF-8");
#endif
const QString code = stream.readAll();
diff --git a/src/qml/qml/qqmlexpression.cpp b/src/qml/qml/qqmlexpression.cpp
index 01d4722ca6..1e1fbcf448 100644
--- a/src/qml/qml/qqmlexpression.cpp
+++ b/src/qml/qml/qqmlexpression.cpp
@@ -75,7 +75,9 @@ void QQmlExpressionPrivate::init(QQmlContextData *ctxt, QV4::Function *runtimeFu
{
expressionFunctionValid = true;
QV4::ExecutionEngine *engine = QQmlEnginePrivate::getV4Engine(ctxt->engine);
- m_function.set(engine, QV4::FunctionObject::createQmlFunction(ctxt, me, runtimeFunction));
+ QV4::Scope scope(engine);
+ QV4::Scoped<QV4::QmlContext> qmlContext(scope, QV4::QmlContext::create(engine->rootContext(), ctxt, me));
+ setupFunction(qmlContext, runtimeFunction);
QQmlJavaScriptExpression::setContext(ctxt);
setScopeObject(me);
diff --git a/src/qml/qml/qqmlglobal.cpp b/src/qml/qml/qqmlglobal.cpp
index 722527a546..f967dacd34 100644
--- a/src/qml/qml/qqmlglobal.cpp
+++ b/src/qml/qml/qqmlglobal.cpp
@@ -326,7 +326,6 @@ QObject *QQmlGuiProvider::application(QObject *) { return new QQmlApplication();
QStringList QQmlGuiProvider::fontFamilies() { return QStringList(); }
bool QQmlGuiProvider::openUrlExternally(QUrl &) { return false; }
-#ifndef QT_NO_IM
QObject *QQmlGuiProvider::inputMethod()
{
// We don't have any input method code by default
@@ -335,7 +334,6 @@ QObject *QQmlGuiProvider::inputMethod()
QQmlEngine::setObjectOwnership(o, QQmlEngine::JavaScriptOwnership);
return o;
}
-#endif
QObject *QQmlGuiProvider::styleHints()
{
diff --git a/src/qml/qml/qqmlglobal_p.h b/src/qml/qml/qqmlglobal_p.h
index 0f5cf3a392..707814e781 100644
--- a/src/qml/qml/qqmlglobal_p.h
+++ b/src/qml/qml/qqmlglobal_p.h
@@ -307,9 +307,7 @@ class Q_QML_PRIVATE_EXPORT QQmlGuiProvider
public:
virtual ~QQmlGuiProvider();
virtual QObject *application(QObject *parent);
-#ifndef QT_NO_IM
virtual QObject *inputMethod();
-#endif
virtual QObject *styleHints();
virtual QStringList fontFamilies();
virtual bool openUrlExternally(QUrl &);
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index 4ded0f93bb..8712b638c5 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -177,7 +177,7 @@ QQmlType *getTypeForUrl(const QString &urlString, const QHashedStringRef& typeNa
} // namespace
-#ifndef QT_NO_LIBRARY
+#if QT_CONFIG(library)
struct RegisteredPlugin {
QString uri;
QPluginLoader* loader;
@@ -302,7 +302,7 @@ public:
const QString &uri, const QString &url,
int vmaj, int vmin, QV4::CompiledData::Import::ImportType type,
QList<QQmlError> *errors, bool lowPrecedence = false);
-#ifndef QT_NO_LIBRARY
+#if QT_CONFIG(library)
bool populatePluginPairVector(QVector<StaticPluginPair> &result, const QString &uri, const QStringList &versionUris,
const QString &qmldirPath, QList<QQmlError> *errors);
#endif
@@ -897,7 +897,7 @@ static QStringList versionUriList(const QString &uri, int vmaj, int vmin)
return result;
}
-#ifndef QT_NO_LIBRARY
+#if QT_CONFIG(library)
static QVector<QStaticPlugin> makePlugins()
{
QVector<QStaticPlugin> plugins;
@@ -966,7 +966,7 @@ bool QQmlImportsPrivate::importExtension(const QString &qmldirFilePath,
const QQmlTypeLoader::QmldirContent *qmldir,
QList<QQmlError> *errors)
{
-#if !defined(QT_NO_LIBRARY)
+#if QT_CONFIG(library)
Q_ASSERT(qmldir);
if (qmlImportTrace())
@@ -1094,7 +1094,7 @@ bool QQmlImportsPrivate::importExtension(const QString &qmldirFilePath,
}
return false;
-#endif // QT_NO_LIBRARY
+#endif // library
return true;
}
@@ -1950,7 +1950,7 @@ bool QQmlImportDatabase::registerPluginTypes(QObject *instance, const QString &b
bool QQmlImportDatabase::importStaticPlugin(QObject *instance, const QString &basePath,
const QString &uri, const QString &typeNamespace, int vmaj, QList<QQmlError> *errors)
{
-#ifndef QT_NO_LIBRARY
+#if QT_CONFIG(library)
// Dynamic plugins are differentiated by their filepath. For static plugins we
// don't have that information so we use their address as key instead.
const QString uniquePluginID = QString::asprintf("%p", instance);
@@ -2003,7 +2003,7 @@ bool QQmlImportDatabase::importStaticPlugin(QObject *instance, const QString &ba
bool QQmlImportDatabase::importDynamicPlugin(const QString &filePath, const QString &uri,
const QString &typeNamespace, int vmaj, QList<QQmlError> *errors)
{
-#ifndef QT_NO_LIBRARY
+#if QT_CONFIG(library)
QFileInfo fileInfo(filePath);
const QString absoluteFilePath = fileInfo.absoluteFilePath();
diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp
index 8020bdb2be..17cccc0bbd 100644
--- a/src/qml/qml/qqmljavascriptexpression.cpp
+++ b/src/qml/qml/qqmljavascriptexpression.cpp
@@ -48,6 +48,7 @@
#include <private/qv4scopedvalue_p.h>
#include <private/qqmlglobal_p.h>
#include <private/qv4qobjectwrapper_p.h>
+#include <private/qqmlbuiltinfunctions_p.h>
QT_BEGIN_NAMESPACE
@@ -94,7 +95,9 @@ QQmlJavaScriptExpression::QQmlJavaScriptExpression()
: m_error(0),
m_context(0),
m_prevExpression(0),
- m_nextExpression(0)
+ m_nextExpression(0),
+ m_v4Function(0),
+ m_sourceLocation(0)
{
}
@@ -110,6 +113,8 @@ QQmlJavaScriptExpression::~QQmlJavaScriptExpression()
clearPermanentGuards();
if (m_scopeObject.isT2()) // notify DeleteWatcher of our deletion.
m_scopeObject.asT2()->_s = 0;
+
+ delete m_sourceLocation;
}
void QQmlJavaScriptExpression::setNotifyOnValueChanged(bool v)
@@ -128,6 +133,22 @@ void QQmlJavaScriptExpression::resetNotifyOnValueChanged()
setNotifyOnValueChanged(false);
}
+QQmlSourceLocation QQmlJavaScriptExpression::sourceLocation() const
+{
+ if (m_sourceLocation)
+ return *m_sourceLocation;
+ if (m_v4Function)
+ return m_v4Function->sourceLocation();
+ return QQmlSourceLocation();
+}
+
+void QQmlJavaScriptExpression::setSourceLocation(const QQmlSourceLocation &location)
+{
+ if (m_sourceLocation)
+ delete m_sourceLocation;
+ m_sourceLocation = new QQmlSourceLocation(location);
+}
+
void QQmlJavaScriptExpression::setContext(QQmlContextData *context)
{
if (m_prevExpression) {
@@ -149,6 +170,11 @@ void QQmlJavaScriptExpression::setContext(QQmlContextData *context)
}
}
+QV4::Function *QQmlJavaScriptExpression::function() const
+{
+ return m_v4Function;
+}
+
void QQmlJavaScriptExpression::refresh()
{
}
@@ -159,8 +185,8 @@ void QQmlJavaScriptExpression::evaluate(QV4::CallData *callData, bool *isUndefin
{
Q_ASSERT(m_context && m_context->engine);
- QV4::Value *f = m_function.valueRef();
- if (!f || f->isUndefined()) {
+ QV4::Function *v4Function = function();
+ if (!v4Function) {
if (isUndefined)
*isUndefined = true;
return;
@@ -191,7 +217,13 @@ void QQmlJavaScriptExpression::evaluate(QV4::CallData *callData, bool *isUndefin
callData->thisObject = value;
}
- f->as<QV4::FunctionObject>()->call(scope, callData);
+ QV4::ExecutionContext *outer = static_cast<QV4::ExecutionContext *>(m_qmlScope.valueRef());
+ if (v4Function->canUseSimpleFunction()) {
+ outer->simpleCall(scope, callData, v4Function);
+ } else {
+ outer->call(scope, callData, v4Function);
+ }
+
if (scope.hasException()) {
if (watcher.wasDeleted())
scope.engine->catchException(); // ignore exception
@@ -374,7 +406,7 @@ QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scopeObje
QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine());
QV4::Scope scope(v4);
- QV4::Scoped<QV4::QmlContext> qmlContext(scope, v4->rootContext()->newQmlContext(ctxt, scopeObject));
+ QV4::Scoped<QV4::QmlContext> qmlContext(scope, QV4::QmlContext::create(v4->rootContext(), ctxt, scopeObject));
QV4::Script script(v4, qmlContext, code, filename, line);
QV4::ScopedValue result(scope);
script.parse();
@@ -404,12 +436,9 @@ void QQmlJavaScriptExpression::createQmlBinding(QQmlContextData *ctxt, QObject *
QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine());
QV4::Scope scope(v4);
- QV4::Scoped<QV4::QmlContext> qmlContext(scope, v4->rootContext()->newQmlContext(ctxt, qmlScope));
+ QV4::Scoped<QV4::QmlContext> qmlContext(scope, QV4::QmlContext::create(v4->rootContext(), ctxt, qmlScope));
QV4::Script script(v4, qmlContext, code, filename, line);
- QV4::ScopedValue result(scope);
script.parse();
- if (!v4->hasException)
- result = script.qmlBinding();
if (v4->hasException) {
QQmlError error = v4->catchExceptionAsQmlError();
if (error.description().isEmpty())
@@ -420,11 +449,19 @@ void QQmlJavaScriptExpression::createQmlBinding(QQmlContextData *ctxt, QObject *
error.setUrl(QUrl::fromLocalFile(filename));
error.setObject(qmlScope);
ep->warning(error);
- result = QV4::Encode::undefined();
+ return;
}
- m_function.set(v4, result);
+ setupFunction(qmlContext, script.vmFunction);
}
+void QQmlJavaScriptExpression::setupFunction(QV4::ExecutionContext *qmlContext, QV4::Function *f)
+{
+ if (!qmlContext || !f)
+ return;
+ m_qmlScope.set(qmlContext->engine(), *qmlContext);
+ m_v4Function = f;
+ m_compilationUnit = m_v4Function->compilationUnit;
+}
void QQmlJavaScriptExpression::clearActiveGuards()
{
diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h
index a0735d91de..646cc5ab3d 100644
--- a/src/qml/qml/qqmljavascriptexpression_p.h
+++ b/src/qml/qml/qqmljavascriptexpression_p.h
@@ -113,11 +113,16 @@ public:
inline QObject *scopeObject() const;
inline void setScopeObject(QObject *v);
+ QQmlSourceLocation sourceLocation() const;
+ void setSourceLocation(const QQmlSourceLocation &location);
+
bool isValid() const { return context() != 0; }
QQmlContextData *context() const { return m_context; }
void setContext(QQmlContextData *context);
+ QV4::Function *function() const;
+
virtual void refresh();
class DeleteWatcher {
@@ -154,6 +159,8 @@ protected:
}
}
+ void setupFunction(QV4::ExecutionContext *qmlContext, QV4::Function *f);
+
private:
friend class QQmlContextData;
friend class QQmlPropertyCapture;
@@ -173,8 +180,10 @@ private:
QQmlJavaScriptExpression *m_nextExpression;
bool m_permanentDependenciesRegistered = false;
-protected:
- QV4::PersistentValue m_function;
+ QV4::PersistentValue m_qmlScope;
+ QQmlRefPointer<QV4::CompiledData::CompilationUnit> m_compilationUnit;
+ QV4::Function *m_v4Function;
+ QQmlSourceLocation *m_sourceLocation; // used for Qt.binding() created functions
};
class QQmlPropertyCapture
diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp
index 6f66475aa5..3876e774c3 100644
--- a/src/qml/qml/qqmllocale.cpp
+++ b/src/qml/qml/qqmllocale.cpp
@@ -107,8 +107,8 @@ QV4::ReturnedValue QQmlDateExtension::method_toLocaleString(QV4::CallContext *ct
QLocale::FormatType enumFormat = QLocale::LongFormat;
QString formattedDt;
if (ctx->argc() == 2) {
- if (ctx->args()[1].isString()) {
- QString format = ctx->args()[1].stringValue()->toQString();
+ if (String *s = ctx->args()[1].stringValue()) {
+ QString format = s->toQString();
formattedDt = r->d()->locale->toString(dt, format);
} else if (ctx->args()[1].isNumber()) {
quint32 intFormat = ctx->args()[1].toNumber();
@@ -152,8 +152,8 @@ QV4::ReturnedValue QQmlDateExtension::method_toLocaleTimeString(QV4::CallContext
QLocale::FormatType enumFormat = QLocale::LongFormat;
QString formattedTime;
if (ctx->argc() == 2) {
- if (ctx->args()[1].isString()) {
- QString format = ctx->args()[1].stringValue()->toQString();
+ if (String *s = ctx->args()[1].stringValue()) {
+ QString format = s->toQString();
formattedTime = r->d()->locale->toString(time, format);
} else if (ctx->args()[1].isNumber()) {
quint32 intFormat = ctx->args()[1].toNumber();
@@ -197,8 +197,8 @@ QV4::ReturnedValue QQmlDateExtension::method_toLocaleDateString(QV4::CallContext
QLocale::FormatType enumFormat = QLocale::LongFormat;
QString formattedDate;
if (ctx->argc() == 2) {
- if (ctx->args()[1].isString()) {
- QString format = ctx->args()[1].stringValue()->toQString();
+ if (String *s = ctx->args()[1].stringValue()) {
+ QString format = s->toQString();
formattedDate = r->d()->locale->toString(date, format);
} else if (ctx->args()[1].isNumber()) {
quint32 intFormat = ctx->args()[1].toNumber();
@@ -217,11 +217,13 @@ QV4::ReturnedValue QQmlDateExtension::method_toLocaleDateString(QV4::CallContext
QV4::ReturnedValue QQmlDateExtension::method_fromLocaleString(QV4::CallContext *ctx)
{
QV4::ExecutionEngine * const engine = ctx->d()->engine;
- if (ctx->argc() == 1 && ctx->args()[0].isString()) {
- QLocale locale;
- QString dateString = ctx->args()[0].stringValue()->toQString();
- QDateTime dt = locale.toDateTime(dateString);
- return QV4::Encode(engine->newDateObject(dt));
+ if (ctx->argc() == 1) {
+ if (String *s = ctx->args()[0].stringValue()) {
+ QLocale locale;
+ QString dateString = s->toQString();
+ QDateTime dt = locale.toDateTime(dateString);
+ return QV4::Encode(engine->newDateObject(dt));
+ }
}
QV4::Scope scope(ctx);
@@ -235,8 +237,8 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleString(QV4::CallContext *
QDateTime dt;
QString dateString = ctx->args()[1].toQStringNoThrow();
if (ctx->argc() == 3) {
- if (ctx->args()[2].isString()) {
- QString format = ctx->args()[2].stringValue()->toQString();
+ if (String *s = ctx->args()[2].stringValue()) {
+ QString format = s->toQString();
dt = r->d()->locale->toDateTime(dateString, format);
} else if (ctx->args()[2].isNumber()) {
quint32 intFormat = ctx->args()[2].toNumber();
@@ -256,13 +258,15 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleTimeString(QV4::CallConte
{
QV4::ExecutionEngine * const engine = ctx->d()->engine;
- if (ctx->argc() == 1 && ctx->args()[0].isString()) {
- QLocale locale;
- QString timeString = ctx->args()[0].stringValue()->toQString();
- QTime time = locale.toTime(timeString);
- QDateTime dt = QDateTime::currentDateTime();
- dt.setTime(time);
- return QV4::Encode(engine->newDateObject(dt));
+ if (ctx->argc() == 1) {
+ if (String *s = ctx->args()[0].stringValue()) {
+ QLocale locale;
+ QString timeString = s->toQString();
+ QTime time = locale.toTime(timeString);
+ QDateTime dt = QDateTime::currentDateTime();
+ dt.setTime(time);
+ return QV4::Encode(engine->newDateObject(dt));
+ }
}
if (ctx->argc() < 1 || ctx->argc() > 3 || !isLocaleObject(ctx->args()[0]))
@@ -276,8 +280,8 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleTimeString(QV4::CallConte
QTime tm;
QString dateString = ctx->args()[1].toQStringNoThrow();
if (ctx->argc() == 3) {
- if (ctx->args()[2].isString()) {
- QString format = ctx->args()[2].stringValue()->toQString();
+ if (String *s = ctx->args()[2].stringValue()) {
+ QString format = s->toQString();
tm = r->d()->locale->toTime(dateString, format);
} else if (ctx->args()[2].isNumber()) {
quint32 intFormat = ctx->args()[2].toNumber();
@@ -303,11 +307,13 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleDateString(QV4::CallConte
{
QV4::ExecutionEngine * const engine = ctx->d()->engine;
- if (ctx->argc() == 1 && ctx->args()[0].isString()) {
- QLocale locale;
- QString dateString = ctx->args()[0].stringValue()->toQString();
- QDate date = locale.toDate(dateString);
- return QV4::Encode(engine->newDateObject(QDateTime(date)));
+ if (ctx->argc() == 1) {
+ if (String *s = ctx->args()[0].stringValue()) {
+ QLocale locale;
+ QString dateString = s->toQString();
+ QDate date = locale.toDate(dateString);
+ return QV4::Encode(engine->newDateObject(QDateTime(date)));
+ }
}
if (ctx->argc() < 1 || ctx->argc() > 3 || !isLocaleObject(ctx->args()[0]))
@@ -321,8 +327,8 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleDateString(QV4::CallConte
QDate dt;
QString dateString = ctx->args()[1].toQStringNoThrow();
if (ctx->argc() == 3) {
- if (ctx->args()[2].isString()) {
- QString format = ctx->args()[2].stringValue()->toQString();
+ if (String *s = ctx->args()[2].stringValue()) {
+ QString format = s->toQString();
dt = r->d()->locale->toDate(dateString, format);
} else if (ctx->args()[2].isNumber()) {
quint32 intFormat = ctx->args()[2].toNumber();
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index 6a1a90f031..520c44f4da 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -1158,7 +1158,7 @@ void qmlClearTypeRegistrations() // Declared in qqml.h
data->uriToModule.clear();
QQmlEnginePrivate::baseModulesUninitialized = true; //So the engine re-registers its types
-#ifndef QT_NO_LIBRARY
+#if QT_CONFIG(library)
qmlClearEnginePlugins();
#endif
}
diff --git a/src/qml/qml/qqmlnotifier.cpp b/src/qml/qml/qqmlnotifier.cpp
index 19f03eae80..185f9687fb 100644
--- a/src/qml/qml/qqmlnotifier.cpp
+++ b/src/qml/qml/qqmlnotifier.cpp
@@ -71,6 +71,12 @@ namespace {
};
}
+void QQmlNotifier::notify(QQmlData *ddata, int notifierIndex)
+{
+ if (QQmlNotifierEndpoint *ep = ddata->notify(notifierIndex))
+ emitNotify(ep, Q_NULLPTR);
+}
+
void QQmlNotifier::emitNotify(QQmlNotifierEndpoint *endpoint, void **a)
{
QVarLengthArray<NotifyListTraversalData> stack;
diff --git a/src/qml/qml/qqmlnotifier_p.h b/src/qml/qml/qqmlnotifier_p.h
index 4db0dd038a..dad79e0e55 100644
--- a/src/qml/qml/qqmlnotifier_p.h
+++ b/src/qml/qml/qqmlnotifier_p.h
@@ -65,6 +65,8 @@ public:
inline ~QQmlNotifier();
inline void notify();
+ static void notify(QQmlData *ddata, int notifierIndex);
+
private:
friend class QQmlData;
friend class QQmlNotifierEndpoint;
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index 2218f277d6..2e2a3fb303 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -44,7 +44,6 @@
#include <private/qv4function_p.h>
#include <private/qv4functionobject_p.h>
#include <private/qv4qobjectwrapper_p.h>
-#include <private/qqmlcontextwrapper_p.h>
#include <private/qqmlbinding_p.h>
#include <private/qqmlstringconverters_p.h>
#include <private/qqmlboundsignal_p.h>
@@ -402,7 +401,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
}
}
break;
-#ifndef QT_NO_DATESTRING
+#if QT_CONFIG(datestring)
case QVariant::Date: {
bool ok = false;
QDate value = QQmlStringConverters::dateFromString(binding->valueAsString(qmlUnit), &ok);
@@ -430,7 +429,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
-#endif // QT_NO_DATESTRING
+#endif // datestring
case QVariant::Point: {
bool ok = false;
QPoint value = QQmlStringConverters::pointFFromString(binding->valueAsString(qmlUnit), &ok).toPoint();
@@ -793,14 +792,13 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con
QV4::Function *runtimeFunction = compilationUnit->runtimeFunctions[binding->value.compiledScriptIndex];
QV4::Scope scope(v4);
- QV4::ScopedContext qmlContext(scope, currentQmlContext());
- QV4::ScopedFunctionObject function(scope, QV4::FunctionObject::createScriptFunction(qmlContext, runtimeFunction, /*createProto*/ false));
+ QV4::Scoped<QV4::QmlContext> qmlContext(scope, currentQmlContext());
if (binding->flags & QV4::CompiledData::Binding::IsSignalHandlerExpression) {
int signalIndex = _propertyCache->methodIndexToSignalIndex(property->coreIndex());
QQmlBoundSignal *bs = new QQmlBoundSignal(_bindingTarget, signalIndex, _scopeObject, engine);
QQmlBoundSignalExpression *expr = new QQmlBoundSignalExpression(_bindingTarget, signalIndex,
- context, _scopeObject, function);
+ context, _scopeObject, runtimeFunction, qmlContext);
bs->takeExpression(expr);
} else {
@@ -810,13 +808,14 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con
// the result is written to a value type virtual property, that contains the sub-index
// of the "x" property.
QQmlBinding *qmlBinding;
+ const QQmlPropertyData *prop = property;
+ const QQmlPropertyData *subprop = nullptr;
if (_valueTypeProperty) {
- qmlBinding = QQmlBinding::create(_valueTypeProperty, function, _scopeObject, context);
- qmlBinding->setTarget(_bindingTarget, *_valueTypeProperty, property);
- } else {
- qmlBinding = QQmlBinding::create(property, function, _scopeObject, context);
- qmlBinding->setTarget(_bindingTarget, *property, nullptr);
+ prop = _valueTypeProperty;
+ subprop = property;
}
+ qmlBinding = QQmlBinding::create(prop, runtimeFunction, _scopeObject, context, qmlContext);
+ qmlBinding->setTarget(_bindingTarget, *prop, subprop);
sharedState->allCreatedBindings.push(QQmlAbstractBinding::Ptr(qmlBinding));
@@ -1016,8 +1015,8 @@ void QQmlObjectCreator::registerObjectWithContextById(const QV4::CompiledData::O
QV4::Heap::QmlContext *QQmlObjectCreator::currentQmlContext()
{
- if (!_qmlContext->objectValue())
- _qmlContext->setM(v4->rootContext()->newQmlContext(context, _scopeObject));
+ if (!_qmlContext->isManaged())
+ _qmlContext->setM(QV4::QmlContext::create(v4->rootContext(), context, _scopeObject));
return _qmlContext->d();
}
diff --git a/src/qml/qml/qqmlproperty_p.h b/src/qml/qml/qqmlproperty_p.h
index 2565ec0ce6..53062a2f13 100644
--- a/src/qml/qml/qqmlproperty_p.h
+++ b/src/qml/qml/qqmlproperty_p.h
@@ -115,30 +115,26 @@ public:
};
Q_DECLARE_FLAGS(BindingFlags, BindingFlag)
- static void setBinding(QQmlAbstractBinding *binding, BindingFlags flags = None, QQmlPropertyData::WriteFlags writeFlags = QQmlPropertyData::DontRemoveBinding);
+ static void setBinding(QQmlAbstractBinding *binding, BindingFlags flags = None,
+ QQmlPropertyData::WriteFlags writeFlags = QQmlPropertyData::DontRemoveBinding);
static void removeBinding(const QQmlProperty &that);
static void removeBinding(QObject *o, QQmlPropertyIndex index);
static void removeBinding(QQmlAbstractBinding *b);
static QQmlAbstractBinding *binding(QObject *, QQmlPropertyIndex index);
- static QQmlProperty restore(QObject *, const QQmlPropertyData &, const QQmlPropertyData *,
- QQmlContextData *);
+ static QQmlProperty restore(QObject *, const QQmlPropertyData &, const QQmlPropertyData *, QQmlContextData *);
int signalIndex() const;
- static inline QQmlPropertyPrivate *get(const QQmlProperty &p) {
- return p.d;
- }
+ static inline QQmlPropertyPrivate *get(const QQmlProperty &p) { return p.d; }
// "Public" (to QML) methods
static QQmlAbstractBinding *binding(const QQmlProperty &that);
static void setBinding(const QQmlProperty &that, QQmlAbstractBinding *);
static QQmlBoundSignalExpression *signalExpression(const QQmlProperty &that);
- static void setSignalExpression(const QQmlProperty &that,
- QQmlBoundSignalExpression *);
- static void takeSignalExpression(const QQmlProperty &that,
- QQmlBoundSignalExpression *);
+ static void setSignalExpression(const QQmlProperty &that, QQmlBoundSignalExpression *);
+ static void takeSignalExpression(const QQmlProperty &that, QQmlBoundSignalExpression *);
static bool write(const QQmlProperty &that, const QVariant &, QQmlPropertyData::WriteFlags);
static QQmlPropertyIndex propertyIndex(const QQmlProperty &that);
static QMetaMethod findSignalByName(const QMetaObject *mo, const QByteArray &);
diff --git a/src/qml/qml/qqmlstringconverters.cpp b/src/qml/qml/qqmlstringconverters.cpp
index d2b3577a1f..e53f90b45b 100644
--- a/src/qml/qml/qqmlstringconverters.cpp
+++ b/src/qml/qml/qqmlstringconverters.cpp
@@ -71,14 +71,14 @@ QVariant QQmlStringConverters::variantFromString(const QString &s, int preferred
return QVariant(int(qRound(s.toDouble(ok))));
case QMetaType::UInt:
return QVariant(uint(qRound(s.toDouble(ok))));
-#ifndef QT_NO_DATESTRING
+#if QT_CONFIG(datestring)
case QMetaType::QDate:
return QVariant::fromValue(dateFromString(s, ok));
case QMetaType::QTime:
return QVariant::fromValue(timeFromString(s, ok));
case QMetaType::QDateTime:
return QVariant::fromValue(dateTimeFromString(s, ok));
-#endif // QT_NO_DATESTRING
+#endif // datestring
case QMetaType::QPointF:
return QVariant::fromValue(pointFFromString(s, ok));
case QMetaType::QPoint:
@@ -106,7 +106,7 @@ unsigned QQmlStringConverters::rgbaFromString(const QString &s, bool *ok)
return QQml_colorProvider()->rgbaFromString(s, ok);
}
-#ifndef QT_NO_DATESTRING
+#if QT_CONFIG(datestring)
QDate QQmlStringConverters::dateFromString(const QString &s, bool *ok)
{
QDate d = QDate::fromString(s, Qt::ISODate);
@@ -130,7 +130,7 @@ QDateTime QQmlStringConverters::dateTimeFromString(const QString &s, bool *ok)
d.setTimeSpec(Qt::UTC);
return d;
}
-#endif // QT_NO_DATESTRING
+#endif // datestring
//expects input of "x,y"
QPointF QQmlStringConverters::pointFFromString(const QString &s, bool *ok)
@@ -229,7 +229,7 @@ bool QQmlStringConverters::createFromString(int type, const QString &s, void *da
*p = uint(qRound(s.toDouble(&ok)));
return ok;
}
-#ifndef QT_NO_DATESTRING
+#if QT_CONFIG(datestring)
case QMetaType::QDate:
{
Q_ASSERT(n >= sizeof(QDate));
@@ -251,7 +251,7 @@ bool QQmlStringConverters::createFromString(int type, const QString &s, void *da
*p = dateTimeFromString(s, &ok);
return ok;
}
-#endif // QT_NO_DATESTRING
+#endif // datestring
case QMetaType::QPointF:
{
Q_ASSERT(n >= sizeof(QPointF));
diff --git a/src/qml/qml/qqmlstringconverters_p.h b/src/qml/qml/qqmlstringconverters_p.h
index b67cefaf35..af344e3344 100644
--- a/src/qml/qml/qqmlstringconverters_p.h
+++ b/src/qml/qml/qqmlstringconverters_p.h
@@ -72,7 +72,7 @@ namespace QQmlStringConverters
Q_QML_PRIVATE_EXPORT QVariant colorFromString(const QString &, bool *ok = 0);
Q_QML_PRIVATE_EXPORT unsigned rgbaFromString(const QString &, bool *ok = 0);
-#ifndef QT_NO_DATESTRING
+#if QT_CONFIG(datestring)
Q_QML_PRIVATE_EXPORT QDate dateFromString(const QString &, bool *ok = 0);
Q_QML_PRIVATE_EXPORT QTime timeFromString(const QString &, bool *ok = 0);
Q_QML_PRIVATE_EXPORT QDateTime dateTimeFromString(const QString &, bool *ok = 0);
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 3885e6ea0b..76ac15e2f1 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -39,7 +39,6 @@
#include "qqmltypeloader_p.h"
#include "qqmlabstracturlinterceptor.h"
-#include "qqmlcontextwrapper_p.h"
#include "qqmlexpression_p.h"
#include <private/qqmlengine_p.h>
@@ -2836,7 +2835,7 @@ QV4::ReturnedValue QQmlScriptData::scriptValueForContext(QQmlContextData *parent
return QV4::Encode::undefined();
}
- QV4::Scoped<QV4::QmlContext> qmlContext(scope, v4->rootContext()->newQmlContext(ctxt, 0));
+ QV4::Scoped<QV4::QmlContext> qmlContext(scope, QV4::QmlContext::create(v4->rootContext(), ctxt, 0));
qmlContext->takeContextOwnership();
m_program->qmlContext.set(scope.engine, qmlContext);
diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp
index 5c3ad6b2a6..fd1e9cc2be 100644
--- a/src/qml/qml/qqmltypewrapper.cpp
+++ b/src/qml/qml/qqmltypewrapper.cpp
@@ -38,7 +38,6 @@
****************************************************************************/
#include "qqmltypewrapper_p.h"
-#include <private/qqmlcontextwrapper_p.h>
#include <private/qv8engine_p.h>
#include <private/qqmlengine_p.h>
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index 43b9e4bd3b..6ce52bb9e5 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -43,7 +43,6 @@
#include <private/qqmlvaluetype_p.h>
#include <private/qqmlbinding_p.h>
#include <private/qqmlglobal_p.h>
-#include <private/qqmlcontextwrapper_p.h>
#include <private/qqmlbuiltinfunctions_p.h>
#include <private/qv4engine_p.h>
@@ -390,6 +389,7 @@ ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, String *name, bool *ha
// These four types are the most common used by the value type wrappers
VALUE_TYPE_LOAD(QMetaType::QReal, qreal, qreal);
+ VALUE_TYPE_LOAD(QMetaType::Int || result->isEnum(), int, int);
VALUE_TYPE_LOAD(QMetaType::Int, int, int);
VALUE_TYPE_LOAD(QMetaType::QString, QString, v4->newString);
VALUE_TYPE_LOAD(QMetaType::Bool, bool, bool);
@@ -453,9 +453,10 @@ void QQmlValueTypeWrapper::put(Managed *m, String *name, const Value &value)
cacheData.setCoreIndex(reference->d()->property);
QV4::Scoped<QQmlBindingFunction> bindingFunction(scope, (const Value &)f);
- bindingFunction->initBindingLocation();
- QQmlBinding *newBinding = QQmlBinding::create(&cacheData, value, reference->d()->object, context);
+ QV4::ScopedContext ctx(scope, bindingFunction->scope());
+ QQmlBinding *newBinding = QQmlBinding::create(&cacheData, bindingFunction->function(), reference->d()->object, context, ctx);
+ newBinding->setSourceLocation(bindingFunction->currentLocation());
newBinding->setTarget(reference->d()->object, cacheData, pd);
QQmlPropertyPrivate::setBinding(newBinding);
return;
diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp
index 01c4f476d6..72d4ab7e8f 100644
--- a/src/qml/qml/qqmlvme.cpp
+++ b/src/qml/qml/qqmlvme.cpp
@@ -62,7 +62,6 @@
#include "qqmlpropertyvalueinterceptor_p.h"
#include "qqmlvaluetypeproxybinding_p.h"
#include "qqmlexpression_p.h"
-#include "qqmlcontextwrapper_p.h"
#include <QStack>
#include <QPointF>
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index 791870b831..545daa96f8 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -489,9 +489,9 @@ QString QQmlVMEMetaObject::readPropertyAsString(int id) const
QV4::Scope scope(cache->engine);
QV4::ScopedValue sv(scope, *(md->data() + id));
- if (!sv->isString())
- return QString();
- return sv->stringValue()->toQString();
+ if (QV4::String *s = sv->stringValue())
+ return s->toQString();
+ return QString();
}
QUrl QQmlVMEMetaObject::readPropertyAsUrl(int id) const
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index b4be709b37..22c3c49c58 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -50,7 +50,6 @@
#include <private/qv4domerrors_p.h>
#include <private/qv4engine_p.h>
#include <private/qv4functionobject_p.h>
-#include <private/qqmlcontextwrapper_p.h>
#include <private/qv4scopedvalue_p.h>
#include <QtCore/qobject.h>
@@ -70,7 +69,7 @@
using namespace QV4;
-#if !defined(QT_NO_XMLSTREAMREADER) && QT_CONFIG(qml_network)
+#if QT_CONFIG(xmlstreamreader) && QT_CONFIG(qml_network)
#define V4THROW_REFERENCE(string) { \
ScopedObject error(scope, ctx->engine()->newReferenceErrorObject(QStringLiteral(string))); \
@@ -1069,7 +1068,7 @@ private:
QByteArray m_mime;
QByteArray m_charset;
QTextCodec *m_textCodec;
-#ifndef QT_NO_TEXTCODEC
+#if QT_CONFIG(textcodec)
QTextCodec* findTextCodec() const;
#endif
void readEncoding();
@@ -1511,7 +1510,7 @@ QV4::ReturnedValue QQmlXMLHttpRequest::xmlResponseBody(QV4::ExecutionEngine* eng
return m_parsedDocument.value();
}
-#ifndef QT_NO_TEXTCODEC
+#if QT_CONFIG(textcodec)
QTextCodec* QQmlXMLHttpRequest::findTextCodec() const
{
QTextCodec *codec = 0;
@@ -1540,7 +1539,7 @@ QTextCodec* QQmlXMLHttpRequest::findTextCodec() const
QString QQmlXMLHttpRequest::responseBody()
{
-#ifndef QT_NO_TEXTCODEC
+#if QT_CONFIG(textcodec)
if (!m_textCodec)
m_textCodec = findTextCodec();
if (m_textCodec)
@@ -2057,6 +2056,6 @@ void *qt_add_qmlxmlhttprequest(ExecutionEngine *v4)
QT_END_NAMESPACE
-#endif // QT_NO_XMLSTREAMREADER && qml_network
+#endif // xmlstreamreader && qml_network
#include <qqmlxmlhttprequest.moc>
diff --git a/src/qml/qml/qqmlxmlhttprequest_p.h b/src/qml/qml/qqmlxmlhttprequest_p.h
index fdb6194537..f2836d8301 100644
--- a/src/qml/qml/qqmlxmlhttprequest_p.h
+++ b/src/qml/qml/qqmlxmlhttprequest_p.h
@@ -55,7 +55,7 @@
#include <QtCore/qglobal.h>
#include <private/qqmlglobal_p.h>
-#if !defined(QT_NO_XMLSTREAMREADER) && QT_CONFIG(qml_network)
+#if QT_CONFIG(xmlstreamreader) && QT_CONFIG(qml_network)
QT_BEGIN_NAMESPACE
@@ -64,7 +64,7 @@ void qt_rem_qmlxmlhttprequest(QV4::ExecutionEngine *engine, void *);
QT_END_NAMESPACE
-#endif // QT_NO_XMLSTREAMREADER && qml_network
+#endif // xmlstreamreader && qml_network
#endif // QQMLXMLHTTPREQUEST_P_H
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index cf0fd57773..19dc100f40 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -148,9 +148,7 @@ void Heap::QtObject::init(QQmlEngine *qmlEngine)
o->defineAccessorProperty(QStringLiteral("platform"), QV4::QtObject::method_get_platform, 0);
o->defineAccessorProperty(QStringLiteral("application"), QV4::QtObject::method_get_application, 0);
-#ifndef QT_NO_IM
o->defineAccessorProperty(QStringLiteral("inputMethod"), QV4::QtObject::method_get_inputMethod, 0);
-#endif
o->defineAccessorProperty(QStringLiteral("styleHints"), QV4::QtObject::method_get_styleHints, 0);
o->defineDefaultProperty(QStringLiteral("callLater"), QV4::QtObject::method_callLater);
@@ -1031,7 +1029,7 @@ ReturnedValue QtObject::method_exit(CallContext *ctx)
/*!
\qmlmethod object Qt::createQmlObject(string qml, object parent, string filepath)
-Returns a new object created from the given \a string of QML which will have the specified \a parent,
+Returns a new object created from the given \a qml string which will have the specified \a parent,
or \c null if there was an error in creating the object.
If \a filepath is specified, it will be used for error reporting for the created object.
@@ -1305,30 +1303,15 @@ ReturnedValue QtObject::method_locale(CallContext *ctx)
void Heap::QQmlBindingFunction::init(const QV4::FunctionObject *originalFunction)
{
- QV4::Heap::FunctionObject::init(originalFunction->scope(), originalFunction->name());
- bindingLocation = new QQmlSourceLocation;
- this->originalFunction = originalFunction->d();
+ Scope scope(originalFunction->engine());
+ ScopedContext context(scope, originalFunction->scope());
+ FunctionObject::init(context, originalFunction->function());
}
-void QQmlBindingFunction::initBindingLocation()
+QQmlSourceLocation QQmlBindingFunction::currentLocation() const
{
QV4::StackFrame frame = engine()->currentStackFrame();
- d()->bindingLocation->sourceFile = frame.source;
- d()->bindingLocation->line = frame.line;
-}
-
-void QQmlBindingFunction::call(const Managed *that, Scope &scope, CallData *callData)
-{
- ScopedFunctionObject function(scope, static_cast<const QQmlBindingFunction*>(that)->d()->originalFunction);
- function->call(scope, callData);
-}
-
-void QQmlBindingFunction::markObjects(Heap::Base *that, ExecutionEngine *e)
-{
- QQmlBindingFunction::Data *This = static_cast<QQmlBindingFunction::Data *>(that);
- if (This->originalFunction)
- This->originalFunction->mark(e);
- QV4::FunctionObject::markObjects(that, e);
+ return QQmlSourceLocation(frame.source, frame.line, 0);
}
DEFINE_OBJECT_VTABLE(QQmlBindingFunction);
@@ -1423,13 +1406,11 @@ ReturnedValue QtObject::method_get_application(CallContext *ctx)
return QV4::QObjectWrapper::wrap(ctx->d()->engine, qt->d()->application);
}
-#ifndef QT_NO_IM
ReturnedValue QtObject::method_get_inputMethod(CallContext *ctx)
{
QObject *o = QQml_guiProvider()->inputMethod();
return QV4::QObjectWrapper::wrap(ctx->d()->engine, o);
}
-#endif
ReturnedValue QtObject::method_get_styleHints(CallContext *ctx)
{
@@ -1740,7 +1721,7 @@ void QV4::GlobalExtensions::init(Object *globalObject, QJSEngine::Extensions ext
Scope scope(v4);
if (extensions.testFlag(QJSEngine::TranslationExtension)) {
- #ifndef QT_NO_TRANSLATION
+ #if QT_CONFIG(translation)
globalObject->defineDefaultProperty(QStringLiteral("qsTranslate"), QV4::GlobalExtensions::method_qsTranslate);
globalObject->defineDefaultProperty(QStringLiteral("QT_TRANSLATE_NOOP"), QV4::GlobalExtensions::method_qsTranslateNoOp);
globalObject->defineDefaultProperty(QStringLiteral("qsTr"), QV4::GlobalExtensions::method_qsTr);
@@ -1767,7 +1748,7 @@ void QV4::GlobalExtensions::init(Object *globalObject, QJSEngine::Extensions ext
}
-#ifndef QT_NO_TRANSLATION
+#if QT_CONFIG(translation)
/*!
\qmlmethod string Qt::qsTranslate(string context, string sourceText, string disambiguation, int n)
@@ -2015,7 +1996,7 @@ ReturnedValue GlobalExtensions::method_qsTrIdNoOp(CallContext *ctx)
return QV4::Encode::undefined();
return ctx->args()[0].asReturnedValue();
}
-#endif // QT_NO_TRANSLATION
+#endif // translation
QV4::ReturnedValue GlobalExtensions::method_gc(CallContext *ctx)
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
index f428e377d7..fe43532647 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
@@ -82,13 +82,6 @@ struct ConsoleObject : Object {
struct QQmlBindingFunction : FunctionObject {
void init(const QV4::FunctionObject *originalFunction);
- void destroy() {
- delete bindingLocation;
- Object::destroy();
- }
- Pointer<FunctionObject> originalFunction;
- // Set when the binding is created later
- QQmlSourceLocation *bindingLocation;
};
}
@@ -135,9 +128,7 @@ struct QtObject : Object
static ReturnedValue method_get_platform(CallContext *ctx);
static ReturnedValue method_get_application(CallContext *ctx);
-#ifndef QT_NO_IM
static ReturnedValue method_get_inputMethod(CallContext *ctx);
-#endif
static ReturnedValue method_get_styleHints(CallContext *ctx);
static ReturnedValue method_callLater(CallContext *ctx);
@@ -169,7 +160,7 @@ struct ConsoleObject : Object
struct Q_QML_PRIVATE_EXPORT GlobalExtensions {
static void init(Object *globalObject, QJSEngine::Extensions extensions);
-#ifndef QT_NO_TRANSLATION
+#if QT_CONFIG(translation)
static ReturnedValue method_qsTranslate(CallContext *ctx);
static ReturnedValue method_qsTranslateNoOp(CallContext *ctx);
static ReturnedValue method_qsTr(CallContext *ctx);
@@ -187,13 +178,8 @@ struct Q_QML_PRIVATE_EXPORT GlobalExtensions {
struct QQmlBindingFunction : public QV4::FunctionObject
{
V4_OBJECT2(QQmlBindingFunction, FunctionObject)
- V4_NEEDS_DESTROY
-
- void initBindingLocation(); // from caller stack trace
-
- static void call(const Managed *that, Scope &scope, CallData *callData);
- static void markObjects(Heap::Base *that, ExecutionEngine *e);
+ QQmlSourceLocation currentLocation() const; // from caller stack trace
};
}
diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp
index b0599dd0a2..dadff819cf 100644
--- a/src/qml/qml/v8/qv8engine.cpp
+++ b/src/qml/qml/v8/qv8engine.cpp
@@ -52,7 +52,6 @@
#include <private/qqmlplatform_p.h>
#include <private/qjsvalue_p.h>
#include <private/qqmltypewrapper_p.h>
-#include <private/qqmlcontextwrapper_p.h>
#include <private/qqmlvaluetypewrapper_p.h>
#include <private/qqmllistwrapper_p.h>
#include <private/qv4scopedvalue_p.h>
@@ -160,7 +159,7 @@ QV8Engine::~QV8Engine()
qDeleteAll(m_extensionData);
m_extensionData.clear();
-#if !defined(QT_NO_XMLSTREAMREADER) && QT_CONFIG(qml_network)
+#if QT_CONFIG(xmlstreamreader) && QT_CONFIG(qml_network)
qt_rem_qmlxmlhttprequest(m_v4Engine, m_xmlHttpRequestData);
m_xmlHttpRequestData = 0;
#endif
@@ -195,7 +194,7 @@ void QV8Engine::initializeGlobal()
QQmlDateExtension::registerExtension(m_v4Engine);
QQmlNumberExtension::registerExtension(m_v4Engine);
-#if !defined(QT_NO_XMLSTREAMREADER) && QT_CONFIG(qml_network)
+#if QT_CONFIG(xmlstreamreader) && QT_CONFIG(qml_network)
qt_add_domexceptions(m_v4Engine);
m_xmlHttpRequestData = qt_add_qmlxmlhttprequest(m_v4Engine);
#endif