diff options
Diffstat (limited to 'src/qml/qml/qqmljavascriptexpression_p.h')
-rw-r--r-- | src/qml/qml/qqmljavascriptexpression_p.h | 77 |
1 files changed, 22 insertions, 55 deletions
diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h index 499d4d430f..80e2033627 100644 --- a/src/qml/qml/qqmljavascriptexpression_p.h +++ b/src/qml/qml/qqmljavascriptexpression_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QQMLJAVASCRIPTEXPRESSION_P_H #define QQMLJAVASCRIPTEXPRESSION_P_H @@ -55,6 +19,7 @@ #include <QtCore/qtaggedpointer.h> #include <QtQml/qqmlerror.h> #include <private/qqmlengine_p.h> +#include <QtQml/private/qbipointer_p.h> QT_BEGIN_NAMESPACE @@ -97,8 +62,9 @@ private: QQmlDelayedError **prevError; }; -class Q_QML_PRIVATE_EXPORT QQmlJavaScriptExpression +class Q_QML_EXPORT QQmlJavaScriptExpression { + Q_DISABLE_COPY_MOVE(QQmlJavaScriptExpression) public: QQmlJavaScriptExpression(); virtual ~QQmlJavaScriptExpression(); @@ -108,6 +74,7 @@ public: QV4::ReturnedValue evaluate(bool *isUndefined); QV4::ReturnedValue evaluate(QV4::CallData *callData, bool *isUndefined); + bool evaluate(void **a, const QMetaType *types, int argc); inline bool notifyOnValueChanged() const; @@ -135,7 +102,7 @@ public: *listHead = this; } - QV4::Function *function() const; + QV4::Function *function() const { return m_v4Function; } virtual void refresh(); @@ -157,6 +124,7 @@ public: void clearError(); void clearActiveGuards(); QQmlDelayedError *delayedError(); + virtual bool mustCaptureBindableProperty() const {return true;} static QV4::ReturnedValue evalFunction( const QQmlRefPointer<QQmlContextData> &ctxt, QObject *scope, const QString &code, @@ -164,6 +132,8 @@ public: QQmlEngine *engine() const { return m_context ? m_context->engine() : nullptr; } bool hasUnresolvedNames() const { return m_context && m_context->hasUnresolvedNames(); } + + bool needsPropertyChangeTrigger(QObject *target, int propertyIndex); QPropertyChangeTrigger *allocatePropertyChangeTrigger(QObject *target, int propertyIndex); protected: @@ -185,28 +155,20 @@ protected: QForwardFieldList<QQmlJavaScriptExpressionGuard, &QQmlJavaScriptExpressionGuard::next, GuardTag> activeGuards; - void setTranslationsCaptured(bool captured) { - Tag newTag = captured ? TranslationsCaptured : NoTag; - if (m_error.tag() & InEvaluationLoop) - newTag = Tag(newTag | InEvaluationLoop); - m_error.setTag(newTag); - } - bool translationsCaptured() const { return m_error.tag() & TranslationsCaptured; } - enum Tag { NoTag, - TranslationsCaptured, InEvaluationLoop }; - // m_error:flag1 translationsCapturedDuringEvaluation - QTaggedPointer<QQmlDelayedError> m_error; + QTaggedPointer<QQmlDelayedError, Tag> m_error; private: friend class QQmlContextData; friend class QQmlPropertyCapture; friend void QQmlJavaScriptExpressionGuard_callback(QQmlNotifierEndpoint *, void **); - friend class QQmlTranslationBinding; + friend class QQmlTranslationBindingFromBinding; + friend class QQmlTranslationBindingFromTranslationInfo; + friend class QQmlJavaScriptExpressionCapture; // Not refcounted as the context will clear the expressions when destructed. QQmlContextData *m_context; @@ -216,13 +178,14 @@ private: QV4::PersistentValue m_qmlScope; QQmlRefPointer<QV4::ExecutableCompilationUnit> m_compilationUnit; + QV4::Function *m_v4Function; protected: TriggerList *qpropertyChangeTriggers = nullptr; }; -class Q_QML_PRIVATE_EXPORT QQmlPropertyCapture +class Q_QML_EXPORT QQmlPropertyCapture { public: QQmlPropertyCapture(QQmlEngine *engine, QQmlJavaScriptExpression *e, QQmlJavaScriptExpression::DeleteWatcher *w) @@ -235,14 +198,18 @@ public: void captureProperty(QQmlNotifier *); void captureProperty(QObject *, int, int, bool doNotify = true); - void captureTranslation() { translationCaptured = true; } + void captureProperty(QObject *, const QQmlPropertyCache *, const QQmlPropertyData *, bool doNotify = true); + void captureTranslation(); QQmlEngine *engine; QQmlJavaScriptExpression *expression; QQmlJavaScriptExpression::DeleteWatcher *watcher; QForwardFieldList<QQmlJavaScriptExpressionGuard, &QQmlJavaScriptExpressionGuard::next> guards; QStringList *errorString; - bool translationCaptured = false; + +private: + void captureBindableProperty(QObject *o, const QMetaObject *metaObjectForBindable, int c); + void captureNonBindableProperty(QObject *o, int n, int c, bool doNotify); }; QQmlJavaScriptExpression::DeleteWatcher::DeleteWatcher(QQmlJavaScriptExpression *e) |