Qt 4.8
qdeclarativeexpression.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qdeclarativeexpression.h"
43 #include "private/qdeclarativeexpression_p.h"
44 
45 #include "private/qdeclarativeengine_p.h"
46 #include "private/qdeclarativecontext_p.h"
47 #include "private/qdeclarativerewrite_p.h"
48 #include "private/qdeclarativecompiler_p.h"
49 #include "private/qdeclarativeglobalscriptclass_p.h"
50 
51 #include <QtCore/qdebug.h>
52 #include <QtScript/qscriptprogram.h>
53 
54 #include <private/qscriptdeclarativeclass_p.h>
55 
57 
59 {
60  if (!e) return false;
61 
62  if (e->inProgressCreations == 0) return false; // Not in construction
63 
64  if (prevError) return true; // Already in error chain
65 
68  e->erroredBindings = this;
70 
71  return true;
72 }
73 
75 : dataRef(0), expressionFunctionMode(ExplicitContext), scopeObject(0), trackChange(false),
76  guardList(0), guardListLength(0), guardObject(0), guardObjectNotifyIndex(-1), deleted(0)
77 {
78 }
79 
81 {
82  if (guardList) { delete [] guardList; guardList = 0; }
83  if (dataRef) dataRef->release();
84  if (deleted) *deleted = true;
85 }
86 
88 : expressionFunctionValid(true), line(-1)
89 {
90 }
91 
93 {
94 }
95 
97  QObject *me)
98 {
99  expression = expr;
100 
102  scopeObject = me;
103  expressionFunctionValid = false;
104 }
105 
107  QObject *me)
108 {
109  expression = func.toString();
110 
112  scopeObject = me;
113 
114  expressionFunction = func;
117 }
118 
121  QObject *me, const QString &srcUrl, int lineNumber)
122 {
123  url = srcUrl;
124  line = lineNumber;
125 
126  if (dataRef) dataRef->release();
127  dataRef = rc;
128  if (dataRef) dataRef->addref();
129 
130  quint32 *exprData = (quint32 *)expr;
132 
133  expression = QString::fromRawData((QChar *)(exprData + 2), exprData[1]);
134 
135  int progIdx = *(exprData);
136  bool isSharedProgram = progIdx & 0x80000000;
137  progIdx &= 0x7FFFFFFF;
138 
139  QDeclarativeEngine *engine = ctxt->engine;
142 
143  if (isSharedProgram) {
144 
145  if (!dd->cachedClosures.at(progIdx)) {
146  QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
147  scriptContext->pushScope(ep->contextClass->newSharedContext());
148  scriptContext->pushScope(ep->globalClass->staticGlobalObject());
149  dd->cachedClosures[progIdx] = new QScriptValue(scriptEngine->evaluate(expression, url, line));
150  scriptEngine->popContext();
151  }
152 
153  expressionFunction = *dd->cachedClosures.at(progIdx);
156 
157  } else {
158 
159  if (!dd->cachedPrograms.at(progIdx)) {
160  dd->cachedPrograms[progIdx] = new QScriptProgram(expression, url, line);
161  }
162 
163  expressionFunction = evalInObjectScope(ctxt, me, *dd->cachedPrograms.at(progIdx),
165 
168  }
169 
171  scopeObject = me;
172 }
173 
175  const QString &program, const QString &fileName,
176  int lineNumber, QScriptValue *contextObject)
177 {
180  if (contextObject) {
181  *contextObject = ep->contextClass->newContext(context, object);
182  scriptContext->pushScope(*contextObject);
183  } else {
184  scriptContext->pushScope(ep->contextClass->newContext(context, object));
185  }
186  scriptContext->pushScope(ep->globalClass->staticGlobalObject());
187  QScriptValue rv = ep->scriptEngine.evaluate(program, fileName, lineNumber);
188  ep->scriptEngine.popContext();
189  return rv;
190 }
191 
193  const QScriptProgram &program,
194  QScriptValue *contextObject)
195 {
198  if (contextObject) {
199  *contextObject = ep->contextClass->newContext(context, object);
200  scriptContext->pushScope(*contextObject);
201  } else {
202  scriptContext->pushScope(ep->contextClass->newContext(context, object));
203  }
204  scriptContext->pushScope(ep->globalClass->staticGlobalObject());
205  QScriptValue rv = ep->scriptEngine.evaluate(program);
206  ep->scriptEngine.popContext();
207  return rv;
208 }
209 
242 
251 {
253 
256  d->setNotifyObject(this, QDeclarativeExpression_notifyIdx);
257 }
258 
261  QDeclarativeRefCount *rc, QObject *me,
262  const QString &url, int lineNumber,
264 : QObject(dd, 0)
265 {
267  d->init(ctxt, expr, rc, me, url, lineNumber);
268 
271  d->setNotifyObject(this, QDeclarativeExpression_notifyIdx);
272 }
273 
282  QObject *scope,
283  const QString &expression,
284  QObject *parent)
286 {
288  d->init(QDeclarativeContextData::get(ctxt), expression, scope);
289 
292  d->setNotifyObject(this, QDeclarativeExpression_notifyIdx);
293 }
294 
299  const QString &expression)
301 {
303  d->init(ctxt, expression, scope);
304 
307  d->setNotifyObject(this, QDeclarativeExpression_notifyIdx);
308 }
309 
313 : QObject(dd, 0)
314 {
316  d->init(ctxt, expression, scope);
317 
320  d->setNotifyObject(this, QDeclarativeExpression_notifyIdx);
321 }
322 
326 : QObject(dd, 0)
327 {
329  d->init(ctxt, func, scope);
330 
333  d->setNotifyObject(this, QDeclarativeExpression_notifyIdx);
334 }
335 
340 {
341 }
342 
348 {
350  return d->context()?d->context()->engine:0;
351 }
352 
358 {
360  QDeclarativeContextData *data = d->context();
361  return data?data->asQDeclarativeContext():0;
362 }
363 
368 {
370  return d->expression;
371 }
372 
377 {
379 
380  d->resetNotifyOnChange();
381  d->expression = expression;
382  d->expressionFunctionValid = false;
383  d->expressionFunction = QScriptValue();
384 }
385 
388 {
389  if (scriptEngine->hasUncaughtException() &&
390  scriptEngine->uncaughtException().isError()) {
391 
393  int lineNumber = scriptEngine->uncaughtExceptionLineNumber();
394 
395  QScriptValue exception = scriptEngine->uncaughtException();
396  QLatin1String fileNameProp("fileName");
397 
398  if (!exception.property(fileNameProp).toString().isEmpty()){
399  fileName = exception.property(fileNameProp).toString();
400  } else {
401  fileName = QLatin1String("<Unknown File>");
402  }
403 
404  error.setUrl(QUrl(fileName));
405  error.setLine(lineNumber);
406  error.setColumn(-1);
407  error.setDescription(exception.toString());
408  } else {
409  error = QDeclarativeError();
410  }
411 }
412 
414 {
415  return trackChange;
416 }
417 
419 {
420  trackChange = notify;
421  if (!notify && guardList)
422  clearGuards();
423 }
424 
426 {
427  clearGuards();
428 }
429 
431 {
432  if (guardList) clearGuards();
433 
434  if (!object || notifyIndex == -1) {
435  guardObject = 0;
436  notifyIndex = -1;
437  } else {
438  guardObject = object;
439  guardObjectNotifyIndex = notifyIndex;
440 
441  }
442 }
443 
445 {
446  evalFlags = flags;
447 }
448 
449 QDeclarativeQtScriptExpression::EvaluateFlags QDeclarativeQtScriptExpression::evaluateFlags() const
450 {
451  return evalFlags;
452 }
453 
455 {
456  Q_ASSERT(context() && context()->engine);
457  Q_ASSERT(!trackChange || (guardObject && guardObjectNotifyIndex != -1));
458 
459  if (!expressionFunction.isValid()) {
460  if (isUndefined) *isUndefined = true;
461  return QScriptValue();
462  }
463 
464  DeleteWatcher watcher(this);
465 
467 
468  bool lastCaptureProperties = ep->captureProperties;
470  ep->captureProperties = trackChange;
471  ep->capturedProperties.copyAndClear(lastCapturedProperties);
472 
473  QScriptValue value = eval(secondaryScope, isUndefined);
474 
475  if (!watcher.wasDeleted() && trackChange) {
476  if (ep->capturedProperties.count() == 0) {
477 
478  if (guardList) clearGuards();
479 
480  } else {
481 
482  updateGuards(ep->capturedProperties);
483 
484  }
485  }
486 
487  lastCapturedProperties.copyAndClear(ep->capturedProperties);
488  ep->captureProperties = lastCaptureProperties;
489 
490  return value;
491 }
492 
493 QScriptValue QDeclarativeQtScriptExpression::eval(QObject *secondaryScope, bool *isUndefined)
494 {
495  Q_ASSERT(context() && context()->engine);
496 
497  DeleteWatcher watcher(this);
498 
501 
503 
504  QDeclarativeContextData *oldSharedContext = 0;
505  QObject *oldSharedScope = 0;
506  QObject *oldOverride = 0;
507  bool isShared = (expressionFunctionMode == SharedContext);
508 
509  if (isShared) {
510  oldSharedContext = ep->sharedContext;
511  oldSharedScope = ep->sharedScope;
512  ep->sharedContext = context();
513  ep->sharedScope = scopeObject;
514  } else {
515  oldOverride = ep->contextClass->setOverrideObject(expressionContext, secondaryScope);
516  }
517 
518  QScriptValue thisObject;
519  if (evalFlags & RequiresThisObject)
520  thisObject = ep->objectClass->newQObject(scopeObject);
521  QScriptValue svalue = expressionFunction.call(thisObject); // This could cause this c++ object to be deleted
522 
523  if (isShared) {
524  ep->sharedContext = oldSharedContext;
525  ep->sharedScope = oldSharedScope;
526  } else if (!watcher.wasDeleted()) {
527  ep->contextClass->setOverrideObject(expressionContext, oldOverride);
528  }
529 
530  if (isUndefined)
531  *isUndefined = svalue.isUndefined() || scriptEngine->hasUncaughtException();
532 
533  // Handle exception
534  if (scriptEngine->hasUncaughtException()) {
535  if (!watcher.wasDeleted())
537 
538  scriptEngine->clearExceptions();
539  return QScriptValue();
540  } else {
541  if (!watcher.wasDeleted())
543 
544  return svalue;
545  }
546 }
547 
549 {
550  Q_ASSERT(guardObject);
551  Q_ASSERT(guardObjectNotifyIndex != -1);
552 
553  if (properties.count() != guardListLength) {
554  QDeclarativeNotifierEndpoint *newGuardList = new QDeclarativeNotifierEndpoint[properties.count()];
555 
556  for (int ii = 0; ii < qMin(guardListLength, properties.count()); ++ii)
557  guardList[ii].copyAndClear(newGuardList[ii]);
558 
559  delete [] guardList;
560  guardList = newGuardList;
561  guardListLength = properties.count();
562  }
563 
564  bool outputWarningHeader = false;
565  bool noChanges = true;
566  for (int ii = 0; ii < properties.count(); ++ii) {
567  QDeclarativeNotifierEndpoint &guard = guardList[ii];
568  const QDeclarativeEnginePrivate::CapturedProperty &property = properties.at(ii);
569 
570  guard.target = guardObject;
571  guard.targetMethod = guardObjectNotifyIndex;
572 
573  if (property.notifier != 0) {
574 
575  if (!noChanges && guard.isConnected(property.notifier)) {
576  // Nothing to do
577 
578  } else {
579  noChanges = false;
580 
581  bool existing = false;
582  for (int jj = 0; !existing && jj < ii; ++jj)
583  if (guardList[jj].isConnected(property.notifier))
584  existing = true;
585 
586  if (existing) {
587  // duplicate
588  guard.disconnect();
589  } else {
590  guard.connect(property.notifier);
591  }
592  }
593 
594 
595  } else if (property.notifyIndex != -1) {
596 
597  if (!noChanges && guard.isConnected(property.object, property.notifyIndex)) {
598  // Nothing to do
599 
600  } else {
601  noChanges = false;
602 
603  bool existing = false;
604  for (int jj = 0; !existing && jj < ii; ++jj)
605  if (guardList[jj].isConnected(property.object, property.notifyIndex))
606  existing = true;
607 
608  if (existing) {
609  // duplicate
610  guard.disconnect();
611  } else {
612  guard.connect(property.object, property.notifyIndex);
613  }
614  }
615 
616  } else {
617  if (!outputWarningHeader) {
618  outputWarningHeader = true;
619  qWarning() << "QDeclarativeExpression: Expression" << expression
620  << "depends on non-NOTIFYable properties:";
621  }
622 
623  const QMetaObject *metaObj = property.object->metaObject();
624  QMetaProperty metaProp = metaObj->property(property.coreIndex);
625 
626  qWarning().nospace() << " " << metaObj->className() << "::" << metaProp.name();
627  }
628  }
629 }
630 
632 {
633  if (!expressionFunctionValid) {
636 
638 
639  QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
640  expressionContext = ep->contextClass->newContext(context(), scopeObject);
641  scriptContext->pushScope(expressionContext);
642  scriptContext->pushScope(ep->globalClass->staticGlobalObject());
643 
645  rewriteBinding.setName(name);
646  bool ok = true;
647  const QString code = rewriteBinding(expression, &ok);
648  if (ok)
649  expressionFunction = scriptEngine->evaluate(code, url, line);
650 
651  scriptEngine->popContext();
652  expressionFunctionMode = ExplicitContext;
653  expressionFunctionValid = true;
654  }
655 
656  return QDeclarativeQtScriptExpression::scriptValue(secondaryScope, isUndefined);
657 }
658 
659 QVariant QDeclarativeExpressionPrivate::value(QObject *secondaryScope, bool *isUndefined)
660 {
662 
663  if (!context() || !context()->isValid()) {
664  qWarning("QDeclarativeExpression: Attempted to evaluate an expression in an invalid context");
665  return QVariant();
666  }
667 
669 
670  return ep->scriptValueToVariant(scriptValue(secondaryScope, isUndefined), qMetaTypeId<QList<QObject*> >());
671 }
672 
683 {
685  return d->value(0, valueIsUndefined);
686 }
687 
693 {
695  return d->notifyOnValueChange();
696 }
697 
715 {
717  d->setNotifyOnValueChange(notifyOnChange);
718 }
719 
725 {
727  return d->url;
728 }
729 
735 {
737  return d->line;
738 }
739 
745 {
747  d->url = url;
748  d->line = line;
749 }
750 
758 {
760  return d->scopeObject;
761 }
762 
770 {
772  return d->error.isValid();
773 }
774 
782 {
784  d->error = QDeclarativeError();
785 }
786 
795 {
797  return d->error;
798 }
799 
802 {
803  emitValueChanged();
804 }
805 
807 {
808  delete [] guardList;
809  guardList = 0;
810  guardListLength = 0;
811 }
812 
825 {
827  emit q->valueChanged();
828 }
829 
831 : m_context(0), m_prevExpression(0), m_nextExpression(0)
832 {
833 }
834 
836 {
837  if (m_prevExpression) {
839  if (m_nextExpression)
841  }
842 }
843 
845 {
846  return m_context;
847 }
848 
850 {
851  if (m_prevExpression) {
853  if (m_nextExpression)
855  m_prevExpression = 0;
856  m_nextExpression = 0;
857  }
858 
859  m_context = context;
860 
861  if (m_context) {
863  if (m_nextExpression)
865  m_prevExpression = &context->expressions;
866  m_context->expressions = this;
867  }
868 }
869 
871 {
872 }
873 
875 {
876  return m_context != 0;
877 }
878 
880 
881 #include <moc_qdeclarativeexpression.cpp>
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
const T & at(int idx) const
Definition: qpodvector_p.h:69
static QScriptEngine * getScriptEngine(QDeclarativeEngine *e)
double d
Definition: qnumeric_p.h:62
The QScriptContext class represents a Qt Script function invocation.
bool isUndefined() const
Returns true if this QScriptValue is of the primitive type Undefined; otherwise returns false...
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
void setEvaluateFlags(EvaluateFlags flags)
QScriptValue evaluate(const QString &program, const QString &fileName=QString(), int lineNumber=1)
Evaluates program, using lineNumber as the base line number, and returns the result of the evaluation...
QScriptValue property(const QString &name, const ResolveFlags &mode=ResolvePrototype) const
Returns the value of this QScriptValue&#39;s property with the given name, using the given mode to resolv...
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
void setName(const QByteArray &name)
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
void setDescription(const QString &)
Sets the error description.
QObject * setOverrideObject(QScriptValue &, QObject *)
QDeclarativeEngine * engine
QDeclarativeEngine * engine() const
Returns the QDeclarativeEngine this expression is associated with, or 0 if there is no association or...
void setExpression(const QString &)
Set the expression to expression.
QDeclarativeAbstractExpression ** m_prevExpression
bool isError() const
Returns true if this QScriptValue is an object of the Error class; otherwise returns false...
static int QDeclarativeExpression_notifyIdx
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
QDeclarativeGlobalScriptClass * globalClass
void setColumn(int)
Sets the error column number.
QScriptValue scriptValue(QObject *secondaryScope=0, bool *isUndefined=0)
static const QMetaObject staticMetaObject
This variable stores the meta-object for the class.
Definition: qobject.h:128
int qMetaTypeId()
Definition: qmetatype.h:224
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QVariant evaluate(bool *valueIsUndefined=0)
Evaulates the expression, returning the result of the evaluation, or an invalid QVariant if the expre...
void popContext()
Pops the current execution context and restores the previous one.
void copyAndClear(QPODVector< T, Increment > &other)
Definition: qpodvector_p.h:152
QDeclarativeAbstractExpression * expressions
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
void connect(QObject *source, int sourceSignal)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QDeclarativeExpression()
Create an invalid QDeclarativeExpression.
#define Q_D(Class)
Definition: qglobal.h:2482
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
static QString fromRawData(const QChar *, int size)
Constructs a QString that uses the first size Unicode characters in the array unicode.
Definition: qstring.cpp:7673
void init(QDeclarativeContextData *, const QString &, QObject *)
void setNotifyOnValueChanged(bool)
Sets whether the valueChanged() signal is emitted when the expression&#39;s evaluated value changes...
QScriptValue newQObject(QObject *, int type=QMetaType::QObjectStar)
QVariant scriptValueToVariant(const QScriptValue &, int hint=QVariant::Invalid)
QDeclarativeDelayedError * nextError
#define Q_Q(Class)
Definition: qglobal.h:2483
const QScriptValue & staticGlobalObject() const
virtual ~QDeclarativeExpression()
Destroy the QDeclarativeExpression instance.
The QScriptEngine class provides an environment for evaluating Qt Script code.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QScriptValue scriptValue(QObject *secondaryScope, bool *isUndefined)
static QScriptValue evalInObjectScope(QDeclarativeContextData *, QObject *, const QString &, const QString &, int, QScriptValue *)
QDeclarativeScriptEngine scriptEngine
QDeclarativeAbstractExpression * m_nextExpression
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const char * name
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
#define emit
Definition: qobjectdefs.h:76
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
QList< QScriptProgram * > cachedPrograms
The QDeclarativeError class encapsulates a QML error.
QDeclarativeContext * context() const
Returns the QDeclarativeContext this expression is associated with, or 0 if there is no association o...
bool notifyOnValueChanged() const
Returns true if the valueChanged() signal is emitted when the expression&#39;s evaluated value changes...
QDeclarativeContextData * m_context
int uncaughtExceptionLineNumber() const
Returns the line number where the last uncaught exception occurred.
QScriptValue newContext(QDeclarativeContextData *, QObject *=0)
QList< QScriptValue * > cachedClosures
QDeclarativeContextData * sharedContext
QDeclarativeNotifierEndpoint * guardList
void clearError()
Clear any expression errors.
QDeclarativeObjectScriptClass * objectClass
QString expression() const
Returns the expression string.
void setLine(int)
Sets the error line number.
bool hasError() const
Returns true if the last call to evaluate() resulted in an error, otherwise false.
int lineNumber() const
Returns the source file line number for this expression.
QObject * scopeObject() const
Returns the expression&#39;s scope object, if provided, otherwise 0.
QDeclarativeDelayedError ** prevError
void setUrl(const QUrl &)
Sets the url for the file that caused this error.
const char * name() const
Returns this property&#39;s name.
The QDeclarativeEngine class provides an environment for instantiating QML components.
int indexOfMethod(const char *method) const
Finds method and returns its index; otherwise returns -1.
QDeclarativeContext * asQDeclarativeContext()
QDeclarativeDelayedError * erroredBindings
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
QString sourceFile() const
Returns the source file URL for this expression.
unsigned int quint32
Definition: qglobal.h:938
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
void setContext(QDeclarativeContextData *)
int count() const
Definition: qpodvector_p.h:148
QDeclarativeContextData * context() const
void clearExceptions()
Clears any uncaught exceptions in this engine.
The QDeclarativeContext class defines a context within a QML engine.
static const QCssKnownValue properties[NumProperties - 1]
Definition: qcssparser.cpp:67
void setSourceLocation(const QString &fileName, int line)
Set the location of this expression to line of url.
void updateGuards(const QPODVector< QDeclarativeEnginePrivate::CapturedProperty, 16 > &properties)
static void exceptionToError(QScriptEngine *, QDeclarativeError &)
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807
QDeclarativeEngine * engine() const
Return the context&#39;s QDeclarativeEngine, or 0 if the context has no QDeclarativeEngine or the QDeclar...
The QScriptProgram class encapsulates a Qt Script program.
The QMetaProperty class provides meta-data about a property.
Definition: qmetaobject.h:176
QScriptValue eval(QObject *secondaryScope, bool *isUndefined)
QVariant value(QObject *secondaryScope=0, bool *isUndefined=0)
QDeclarativeError error() const
Return any error from the last call to evaluate().
The QDeclarativeExpression class evaluates JavaScript in a QML context.
void pushScope(const QScriptValue &object)
Adds the given object to the front of this context&#39;s scope chain.
bool hasUncaughtException() const
Returns true if the last script evaluation resulted in an uncaught exception; otherwise returns false...
bool addError(QDeclarativeEnginePrivate *)
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
static QString fileName(const QString &fileUrl)
QScriptValue call(const QScriptValue &thisObject=QScriptValue(), const QScriptValueList &args=QScriptValueList())
Calls this QScriptValue as a function, using thisObject as the `this&#39; object in the function call...
QPODVector< CapturedProperty, 16 > capturedProperties
static QScriptContext * pushCleanContext(QScriptEngine *)
Enters a new execution context and returns the associated QScriptContext object.
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.
QScriptValue uncaughtException() const
Returns the current uncaught exception, or an invalid QScriptValue if there is no uncaught exception...
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
QDeclarativeContextScriptClass * contextClass
static QDeclarativeContextData * get(QDeclarativeContext *context)