5#ifndef QQMLJAVASCRIPTEXPRESSION_P_H
6#define QQMLJAVASCRIPTEXPRESSION_P_H
19#include <QtCore/qglobal.h>
20#include <QtCore/qtaggedpointer.h>
21#include <QtQml/qqmlerror.h>
22#include <private/qqmlengine_p.h>
23#include <QtQml/private/qbipointer_p.h>
27struct QQmlSourceLocation;
60 mutable QQmlError m_error;
68 Q_DISABLE_COPY_MOVE(QQmlJavaScriptExpression)
70 QQmlJavaScriptExpression();
71 virtual ~QQmlJavaScriptExpression();
78 bool evaluate(
void **a,
const QMetaType *types,
int argc);
95 void setContext(
const QQmlRefPointer<QQmlContextData> &context);
99 m_nextExpression = *listHead;
100 if (m_nextExpression)
101 m_nextExpression->m_prevExpression = &m_nextExpression;
102 m_prevExpression = listHead;
121 friend class QQmlJavaScriptExpression;
123 QQmlJavaScriptExpression **_w;
124 QQmlJavaScriptExpression *_s;
136 const QQmlRefPointer<QQmlContextData> &ctxt, QObject *scope,
const QString &code,
137 const QString &filename, quint16 line);
146 void createQmlBinding(
const QQmlRefPointer<QQmlContextData> &ctxt, QObject *scope,
147 const QString &code,
const QString &filename, quint16 line);
149 void setupFunction(QV4::ExecutionContext *qmlContext, QV4::Function *f);
150 void setCompilationUnit(
const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit);
172 friend class QQmlContextData;
180 QQmlContextData *m_context;
182 QQmlJavaScriptExpression **m_prevExpression;
183 QQmlJavaScriptExpression *m_nextExpression;
185 QV4::PersistentValue m_qmlScope;
186 QQmlRefPointer<QV4::ExecutableCompilationUnit> m_compilationUnit;
188 QV4::Function *m_v4Function;
191 TriggerList *qpropertyChangeTriggers =
nullptr;
197 QQmlPropertyCapture(QQmlEngine *engine, QQmlJavaScriptExpression *e, QQmlJavaScriptExpression::DeleteWatcher *w)
198 : engine(engine), expression(e), watcher(w), errorString(
nullptr) { }
200 ~QQmlPropertyCapture() {
201 Q_ASSERT(guards.isEmpty());
202 Q_ASSERT(errorString ==
nullptr);
205 void captureProperty(QQmlNotifier *);
206 void captureProperty(QObject *,
int,
int,
bool doNotify =
true);
207 void captureProperty(QObject *,
const QQmlPropertyCache *,
const QQmlPropertyData *,
bool doNotify =
true);
208 void captureTranslation();
211 QQmlJavaScriptExpression *expression;
212 QQmlJavaScriptExpression::DeleteWatcher *watcher;
213 QForwardFieldList<QQmlJavaScriptExpressionGuard, &QQmlJavaScriptExpressionGuard::next> guards;
214 QStringList *errorString;
217 void captureBindableProperty(QObject *o,
const QMetaObject *metaObjectForBindable,
int c);
218 void captureNonBindableProperty(QObject *o,
int n,
int c,
bool doNotify);
221QQmlJavaScriptExpression::DeleteWatcher::DeleteWatcher(QQmlJavaScriptExpression *e)
222: _c(
nullptr), _w(
nullptr), _s(e)
224 if (e->m_scopeObject.isT1()) {
226 _c = e->m_scopeObject.asT1();
227 e->m_scopeObject =
this;
230 _w = &e->m_scopeObject.asT2()->_s;
234QQmlJavaScriptExpression::DeleteWatcher::~DeleteWatcher()
236 Q_ASSERT(*_w ==
nullptr || (*_w == _s && _s->m_scopeObject.isT2()));
237 if (*_w && _s->m_scopeObject.asT2() ==
this)
238 _s->m_scopeObject = _c;
241bool QQmlJavaScriptExpression::DeleteWatcher::wasDeleted()
const
243 return *_w ==
nullptr;
246bool QQmlJavaScriptExpression::notifyOnValueChanged()
const
248 return activeGuards.tag() == NotifyOnValueChanged;
251QObject *QQmlJavaScriptExpression::scopeObject()
const
253 if (m_scopeObject.isT1())
return m_scopeObject.asT1();
254 else return m_scopeObject.asT2()->_c;
257void QQmlJavaScriptExpression::setScopeObject(QObject *v)
259 if (m_scopeObject.isT1()) m_scopeObject = v;
260 else m_scopeObject.asT2()->_c = v;
263bool QQmlJavaScriptExpression::hasError()
const
265 return !m_error.isNull() && m_error->isValid();
268bool QQmlJavaScriptExpression::hasDelayedError()
const
270 return !m_error.isNull();
273inline void QQmlJavaScriptExpression::clearError()
275 delete m_error.data();
279QQmlJavaScriptExpressionGuard::QQmlJavaScriptExpressionGuard(QQmlJavaScriptExpression *e)
280 : QQmlNotifierEndpoint(QQmlNotifierEndpoint::QQmlJavaScriptExpressionGuard),
281 expression(e), next(
nullptr)
285QQmlJavaScriptExpressionGuard *
286QQmlJavaScriptExpressionGuard::New(QQmlJavaScriptExpression *e,
290 return QQmlEnginePrivate::get(engine)->jsExpressionGuardPool.New(e);
293void QQmlJavaScriptExpressionGuard::Delete()
295 QRecyclePool<QQmlJavaScriptExpressionGuard>::Delete(
this);
QOpenGLContext * context() const
bool addError(QQmlEnginePrivate *)
void setErrorObject(QObject *object)
void catchJavaScriptException(QV4::ExecutionEngine *engine)
void setErrorDescription(const QString &description)
QQmlEngine * engine() const
Return the QQmlEngine this incubation controller is set on, or 0 if it has not been set on any engine...
DeleteWatcher(QQmlJavaScriptExpression *)
void insertIntoList(QQmlJavaScriptExpression **listHead)
void setNotifyOnValueChanged(bool v)
void setupFunction(QV4::ExecutionContext *qmlContext, QV4::Function *f)
QV4::Function * function() const
void setCompilationUnit(const QQmlRefPointer< QV4::ExecutableCompilationUnit > &compilationUnit)
bool evaluate(void **a, const QMetaType *types, int argc)
QV4::ExecutableCompilationUnit * compilationUnit() const
QQmlDelayedError * delayedError()
QObject * scopeObject() const
bool needsPropertyChangeTrigger(QObject *target, int propertyIndex)
QV4::ReturnedValue evaluate(bool *isUndefined)
virtual QString expressionIdentifier() const
bool hasUnresolvedNames() const
QForwardFieldList< QQmlJavaScriptExpressionGuard, &QQmlJavaScriptExpressionGuard::next, GuardTag > activeGuards
void setContext(const QQmlRefPointer< QQmlContextData > &context)
bool hasDelayedError() const
friend class QQmlPropertyCapture
QQmlJavaScriptExpression * nextExpression() const
bool hasValidContext() const
static QV4::ReturnedValue evalFunction(const QQmlRefPointer< QQmlContextData > &ctxt, QObject *scope, const QString &code, const QString &filename, quint16 line)
void setFunction(QV4::Function *f)
QQmlError error(QQmlEngine *) const
void resetNotifyOnValueChanged()
QV4::ReturnedValue evaluate(QV4::CallData *callData, bool *isUndefined)
virtual QQmlSourceLocation sourceLocation() const
void setScopeObject(QObject *v)
QBiPointer< QObject, DeleteWatcher > m_scopeObject
virtual void expressionChanged()=0
QQmlContext * publicContext() const
QPropertyChangeTrigger * allocatePropertyChangeTrigger(QObject *target, int propertyIndex)
bool notifyOnValueChanged() const
virtual bool mustCaptureBindableProperty() const
QTaggedPointer< QQmlDelayedError, Tag > m_error
Combined button and popup list for selecting options.
void QQmlJavaScriptExpressionGuard_callback(QQmlNotifierEndpoint *e, void **)