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;
117 friend class QQmlJavaScriptExpression;
119 QQmlJavaScriptExpression **_w;
120 QQmlJavaScriptExpression *_s;
132 const QQmlRefPointer<QQmlContextData> &ctxt, QObject *scope,
const QString &code,
133 const QString &filename, quint16 line);
142 void createQmlBinding(
const QQmlRefPointer<QQmlContextData> &ctxt, QObject *scope,
143 const QString &code,
const QString &filename, quint16 line);
145 void setupFunction(QV4::ExecutionContext *qmlContext, QV4::Function *f);
146 void setCompilationUnit(
const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit);
168 friend class QQmlContextData;
176 QQmlContextData *m_context;
178 QQmlJavaScriptExpression **m_prevExpression;
179 QQmlJavaScriptExpression *m_nextExpression;
181 QV4::PersistentValue m_qmlScope;
182 QQmlRefPointer<QV4::ExecutableCompilationUnit> m_compilationUnit;
184 QV4::Function *m_v4Function;
187 TriggerList *qpropertyChangeTriggers =
nullptr;
193 QQmlPropertyCapture(QQmlEngine *engine, QQmlJavaScriptExpression *e, QQmlJavaScriptExpression::DeleteWatcher *w)
194 : engine(engine), expression(e), watcher(w), errorString(
nullptr) { }
196 ~QQmlPropertyCapture() {
197 Q_ASSERT(guards.isEmpty());
198 Q_ASSERT(errorString ==
nullptr);
201 void captureProperty(QQmlNotifier *);
202 void captureProperty(QObject *,
int,
int,
bool doNotify =
true);
203 void captureProperty(QObject *,
const QQmlPropertyCache *,
const QQmlPropertyData *,
bool doNotify =
true);
204 void captureTranslation();
207 QQmlJavaScriptExpression *expression;
208 QQmlJavaScriptExpression::DeleteWatcher *watcher;
209 QForwardFieldList<QQmlJavaScriptExpressionGuard, &QQmlJavaScriptExpressionGuard::next> guards;
210 QStringList *errorString;
213 void captureBindableProperty(QObject *o,
const QMetaObject *metaObjectForBindable,
int c);
214 void captureNonBindableProperty(QObject *o,
int n,
int c,
bool doNotify);
217QQmlJavaScriptExpression::DeleteWatcher::DeleteWatcher(QQmlJavaScriptExpression *e)
218: _c(
nullptr), _w(
nullptr), _s(e)
220 if (e->m_scopeObject.isT1()) {
222 _c = e->m_scopeObject.asT1();
223 e->m_scopeObject =
this;
226 _w = &e->m_scopeObject.asT2()->_s;
230QQmlJavaScriptExpression::DeleteWatcher::~DeleteWatcher()
232 Q_ASSERT(*_w ==
nullptr || (*_w == _s && _s->m_scopeObject.isT2()));
233 if (*_w && _s->m_scopeObject.asT2() ==
this)
234 _s->m_scopeObject = _c;
237bool QQmlJavaScriptExpression::DeleteWatcher::wasDeleted()
const
239 return *_w ==
nullptr;
242bool QQmlJavaScriptExpression::notifyOnValueChanged()
const
244 return activeGuards.tag() == NotifyOnValueChanged;
247QObject *QQmlJavaScriptExpression::scopeObject()
const
249 if (m_scopeObject.isT1())
return m_scopeObject.asT1();
250 else return m_scopeObject.asT2()->_c;
253void QQmlJavaScriptExpression::setScopeObject(QObject *v)
255 if (m_scopeObject.isT1()) m_scopeObject = v;
256 else m_scopeObject.asT2()->_c = v;
259bool QQmlJavaScriptExpression::hasError()
const
261 return !m_error.isNull() && m_error->isValid();
264bool QQmlJavaScriptExpression::hasDelayedError()
const
266 return !m_error.isNull();
269inline void QQmlJavaScriptExpression::clearError()
271 delete m_error.data();
275QQmlJavaScriptExpressionGuard::QQmlJavaScriptExpressionGuard(QQmlJavaScriptExpression *e)
276 : QQmlNotifierEndpoint(QQmlNotifierEndpoint::QQmlJavaScriptExpressionGuard),
277 expression(e), next(
nullptr)
281QQmlJavaScriptExpressionGuard *
282QQmlJavaScriptExpressionGuard::New(QQmlJavaScriptExpression *e,
286 return QQmlEnginePrivate::get(engine)->jsExpressionGuardPool.New(e);
289void QQmlJavaScriptExpressionGuard::Delete()
291 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)
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
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 **)