/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtDeclarative module of the Qt Toolkit.
**
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "private/qdeclarativevme_p.h"
+#include "qdeclarativevme_p.h"
-#include "private/qdeclarativecompiler_p.h"
-#include "private/qdeclarativeboundsignal_p.h"
-#include "private/qdeclarativestringconverters_p.h"
-#include "private/qmetaobjectbuilder_p.h"
-#include "private/qfastmetabuilder_p.h"
-#include "private/qdeclarativedata_p.h"
+#include "qdeclarativecompiler_p.h"
+#include "qdeclarativeboundsignal_p.h"
+#include "qdeclarativestringconverters_p.h"
+#include <private/qmetaobjectbuilder_p.h>
+#include <private/qfastmetabuilder_p.h>
+#include "qdeclarativedata_p.h"
#include "qdeclarative.h"
-#include "private/qdeclarativecustomparser_p.h"
+#include "qdeclarativecustomparser_p.h"
#include "qdeclarativeengine.h"
#include "qdeclarativecontext.h"
#include "qdeclarativecomponent.h"
-#include "private/qdeclarativebinding_p.h"
-#include "private/qdeclarativeengine_p.h"
-#include "private/qdeclarativecomponent_p.h"
-#include "private/qdeclarativevmemetaobject_p.h"
-#include "private/qdeclarativebinding_p_p.h"
-#include "private/qdeclarativecontext_p.h"
-#include "private/qdeclarativev4bindings_p.h"
-#include "private/qv8bindings_p.h"
-#include "private/qdeclarativeglobal_p.h"
-#include "private/qfinitestack_p.h"
+#include "qdeclarativecomponentattached_p.h"
+#include "qdeclarativebinding_p.h"
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativecomponent_p.h"
+#include "qdeclarativevmemetaobject_p.h"
+#include "qdeclarativebinding_p_p.h"
+#include "qdeclarativecontext_p.h"
+#include <private/qv4bindings_p.h>
+#include <private/qv8bindings_p.h>
+#include "qdeclarativeglobal_p.h"
+#include <private/qfinitestack_p.h>
#include "qdeclarativescriptstring.h"
#include "qdeclarativescriptstring_p.h"
+#include "qdeclarativepropertyvalueinterceptor_p.h"
#include <QStack>
#include <QColor>
bindValues.allocate(i->init.bindingsSize);
parserStatus.allocate(i->init.parserStatusSize);
+#ifdef QML_ENABLE_TRACE
+ parserStatusData.allocate(i->init.parserStatusSize);
+ rootComponent = comp;
+#endif
+
rootContext = 0;
engine = ctxt->engine;
}
objects.push(object);
+#ifdef QML_ENABLE_TRACE
+ parserStatusData.allocate(i->deferInit.parserStatusSize);
+ rootComponent = comp;
+#endif
+
rootContext = 0;
engine = ctxt->engine;
{
Q_ASSERT(states.count() >= 1);
+#ifdef QML_ENABLE_TRACE
+ QDeclarativeTrace trace("VME Execute");
+ trace.addDetail("URL", rootComponent->url);
+#endif
+
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(states.at(0).context->engine);
ActiveVMERestorer restore(this, ep);
if (binding) binding->destroy();
}
+static QVariant variantFromString(const QString &string)
+{
+ return QDeclarativeStringConverters::variantFromString(string);
+}
+
// XXX we probably need some form of "work count" here to prevent us checking this
// for every instruction.
#define QML_BEGIN_INSTR_COMMON(I) { \
case QDeclarativeInstruction::I: \
QML_BEGIN_INSTR_COMMON(I)
-# define QML_NEXT_INSTR(I) \
+# define QML_NEXT_INSTR(I) { \
if (watcher.hasRecursed()) return 0; \
- break;
+ break; \
+ }
+
# define QML_END_INSTR(I) \
if (watcher.hasRecursed() || interrupt.shouldInterrupt()) return 0; \
} break;
#endif
-#define CLEAN_PROPERTY(o, index) if (fastHasBinding(o, index)) removeBindingOnProperty(o, index)
+#define QML_STORE_VALUE(name, cpptype, value) \
+ QML_BEGIN_INSTR(name) \
+ cpptype v = value; \
+ void *a[] = { (void *)&v, 0, &status, &flags }; \
+ QObject *target = objects.top(); \
+ CLEAN_PROPERTY(target, instr.propertyIndex); \
+ QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.propertyIndex, a); \
+ QML_END_INSTR(name)
+
+#define QML_STORE_LIST(name, cpptype, value) \
+ QML_BEGIN_INSTR(name) \
+ cpptype v; \
+ v.append(value); \
+ void *a[] = { (void *)&v, 0, &status, &flags }; \
+ QObject *target = objects.top(); \
+ CLEAN_PROPERTY(target, instr.propertyIndex); \
+ QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.propertyIndex, a); \
+ QML_END_INSTR(name)
+
+#define QML_STORE_VAR(name, value) \
+ QML_BEGIN_INSTR(name) \
+ v8::Handle<v8::Value> v8value = value; \
+ QObject *target = objects.top(); \
+ CLEAN_PROPERTY(target, instr.propertyIndex); \
+ QMetaObject *mo = const_cast<QMetaObject *>(target->metaObject()); \
+ QDeclarativeVMEMetaObject *vmemo = static_cast<QDeclarativeVMEMetaObject *>(mo); \
+ vmemo->setVMEProperty(instr.propertyIndex, v8value); \
+ QML_END_INSTR(name)
+
+#define QML_STORE_POINTER(name, value) \
+ QML_BEGIN_INSTR(name) \
+ void *a[] = { (void *)value, 0, &status, &flags }; \
+ QObject *target = objects.top(); \
+ CLEAN_PROPERTY(target, instr.propertyIndex); \
+ QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.propertyIndex, a); \
+ QML_END_INSTR(name)
+
+#define CLEAN_PROPERTY(o, index) \
+ if (fastHasBinding(o, index)) \
+ removeBindingOnProperty(o, index)
QObject *QDeclarativeVME::run(QList<QDeclarativeError> *errors,
const Interrupt &interrupt
switch (genericInstr->common.instructionType) {
#endif
+
+ // Store a created object in a property. These all pop from the objects stack.
+ QML_STORE_VALUE(StoreObject, QObject *, objects.pop());
+ QML_STORE_VALUE(StoreVariantObject, QVariant, QVariant::fromValue(objects.pop()));
+ QML_STORE_VAR(StoreVarObject, ep->v8engine()->newQObject(objects.pop()));
+
+ // Store a literal value in a corresponding property
+ QML_STORE_VALUE(StoreFloat, float, instr.value);
+ QML_STORE_VALUE(StoreDouble, double, instr.value);
+ QML_STORE_VALUE(StoreBool, bool, instr.value);
+ QML_STORE_VALUE(StoreInteger, int, instr.value);
+ QML_STORE_VALUE(StoreColor, QColor, QColor::fromRgba(instr.value));
+ QML_STORE_VALUE(StoreDate, QDate, QDate::fromJulianDay(instr.value));
+ QML_STORE_VALUE(StoreDateTime, QDateTime,
+ QDateTime(QDate::fromJulianDay(instr.date), *(QTime *)&instr.time));
+ QML_STORE_POINTER(StoreTime, (QTime *)&instr.time);
+ QML_STORE_POINTER(StorePoint, (QPoint *)&instr.point);
+ QML_STORE_POINTER(StorePointF, (QPointF *)&instr.point);
+ QML_STORE_POINTER(StoreSize, (QSize *)&instr.size);
+ QML_STORE_POINTER(StoreSizeF, (QSizeF *)&instr.size);
+ QML_STORE_POINTER(StoreRect, (QRect *)&instr.rect);
+ QML_STORE_POINTER(StoreRectF, (QRectF *)&instr.rect);
+ QML_STORE_POINTER(StoreVector3D, (QVector3D *)&instr.vector);
+ QML_STORE_POINTER(StoreVector4D, (QVector4D *)&instr.vector);
+ QML_STORE_POINTER(StoreString, &PRIMITIVES.at(instr.value));
+ QML_STORE_POINTER(StoreByteArray, &DATAS.at(instr.value));
+ QML_STORE_POINTER(StoreUrl, &URLS.at(instr.value));
+ QML_STORE_VALUE(StoreTrString, QString,
+ QCoreApplication::translate(DATAS.at(instr.context).constData(),
+ DATAS.at(instr.text).constData(),
+ DATAS.at(instr.comment).constData(),
+ QCoreApplication::UnicodeUTF8,
+ instr.n));
+ QML_STORE_VALUE(StoreTrIdString, QString, qtTrId(DATAS.at(instr.text).constData(), instr.n));
+
+ // Store a literal value in a QList
+ QML_STORE_LIST(StoreStringList, QStringList, PRIMITIVES.at(instr.value));
+ QML_STORE_LIST(StoreStringQList, QList<QString>, PRIMITIVES.at(instr.value));
+ QML_STORE_LIST(StoreUrlQList, QList<QUrl>, URLS.at(instr.value));
+ QML_STORE_LIST(StoreDoubleQList, QList<double>, instr.value);
+ QML_STORE_LIST(StoreBoolQList, QList<bool>, instr.value);
+ QML_STORE_LIST(StoreIntegerQList, QList<int>, instr.value);
+
+ // Store a literal value in a QVariant property
+ QML_STORE_VALUE(StoreVariant, QVariant, variantFromString(PRIMITIVES.at(instr.value)));
+ QML_STORE_VALUE(StoreVariantInteger, QVariant, QVariant(instr.value));
+ QML_STORE_VALUE(StoreVariantDouble, QVariant, QVariant(instr.value));
+ QML_STORE_VALUE(StoreVariantBool, QVariant, QVariant(instr.value));
+
+ // Store a literal value in a var property.
+ // We deliberately do not use string converters here
+ QML_STORE_VAR(StoreVar, ep->v8engine()->fromVariant(PRIMITIVES.at(instr.value)));
+ QML_STORE_VAR(StoreVarInteger, v8::Integer::New(instr.value));
+ QML_STORE_VAR(StoreVarDouble, v8::Number::New(instr.value));
+ QML_STORE_VAR(StoreVarBool, v8::Boolean::New(instr.value));
+
+
QML_BEGIN_INSTR(Init)
// Ensure that the compiled data has been initialized
if (!COMP->isInitialized()) COMP->initialize(engine);
CTXT->setIdPropertyData(COMP->contextCaches.at(instr.contextCache));
if (instr.compiledBinding != -1) {
const char *v4data = DATAS.at(instr.compiledBinding).constData();
- CTXT->v4bindings = new QDeclarativeV4Bindings(v4data, CTXT, COMP);
+ CTXT->v4bindings = new QV4Bindings(v4data, CTXT, COMP);
}
if (states.count() == 1) {
rootContext = CTXT;
- rootContext->activeVME = this;
+ rootContext->activeVMEData = data;
}
if (states.count() == 1 && !creationContext.isNull()) {
// A component that is logically created within another component instance shares the
}
QML_END_INSTR(StoreMetaObject)
- QML_BEGIN_INSTR(StoreVariant)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- // XXX - can be more efficient
- QVariant v = QDeclarativeStringConverters::variantFromString(PRIMITIVES.at(instr.value));
- void *a[] = { &v, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StoreVariant)
-
- QML_BEGIN_INSTR(StoreVariantInteger)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- QVariant v(instr.value);
- void *a[] = { &v, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StoreVariantInteger)
-
- QML_BEGIN_INSTR(StoreVariantDouble)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- QVariant v(instr.value);
- void *a[] = { &v, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StoreVariantDouble)
-
- QML_BEGIN_INSTR(StoreVariantBool)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- QVariant v(instr.value);
- void *a[] = { &v, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StoreVariantBool)
-
- QML_BEGIN_INSTR(StoreVar)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- // Note that we don't use QDeclarativeStringConverters::variantFromString() here, which
- // means that automatic generation of value types from strings doesn't occur.
- // This is a deliberate behaviour difference to variant properties.
- v8::Handle<v8::Value> v8Value = ep->v8engine()->fromVariant(PRIMITIVES.at(instr.value));
- static_cast<QDeclarativeVMEMetaObject *>(const_cast<QMetaObject *>(target->metaObject()))->setVMEProperty(instr.propertyIndex, v8Value);
- QML_END_INSTR(StoreVar)
-
- QML_BEGIN_INSTR(StoreVarInteger)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- v8::Handle<v8::Value> v8Value = v8::Integer::New(instr.value);
- static_cast<QDeclarativeVMEMetaObject *>(const_cast<QMetaObject *>(target->metaObject()))->setVMEProperty(instr.propertyIndex, v8Value);
- QML_END_INSTR(StoreVarInteger)
-
- QML_BEGIN_INSTR(StoreVarDouble)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- v8::Handle<v8::Value> v8Value = v8::Number::New(instr.value);
- static_cast<QDeclarativeVMEMetaObject *>(const_cast<QMetaObject *>(target->metaObject()))->setVMEProperty(instr.propertyIndex, v8Value);
- QML_END_INSTR(StoreVarDouble)
-
- QML_BEGIN_INSTR(StoreVarBool)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- v8::Handle<v8::Value> v8Value = v8::Boolean::New(instr.value);
- static_cast<QDeclarativeVMEMetaObject *>(const_cast<QMetaObject *>(target->metaObject()))->setVMEProperty(instr.propertyIndex, v8Value);
- QML_END_INSTR(StoreVarBool)
-
- QML_BEGIN_INSTR(StoreString)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- void *a[] = { (void *)&PRIMITIVES.at(instr.value), 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StoreString)
-
- QML_BEGIN_INSTR(StoreByteArray)
- QObject *target = objects.top();
- void *a[] = { (void *)&DATAS.at(instr.value), 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StoreByteArray)
-
- QML_BEGIN_INSTR(StoreUrl)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- void *a[] = { (void *)&URLS.at(instr.value), 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StoreUrl)
-
- QML_BEGIN_INSTR(StoreFloat)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- float f = instr.value;
- void *a[] = { &f, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StoreFloat)
-
- QML_BEGIN_INSTR(StoreDouble)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- double d = instr.value;
- void *a[] = { &d, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StoreDouble)
-
- QML_BEGIN_INSTR(StoreBool)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- void *a[] = { (void *)&instr.value, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StoreBool)
-
- QML_BEGIN_INSTR(StoreInteger)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- void *a[] = { (void *)&instr.value, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StoreInteger)
-
- QML_BEGIN_INSTR(StoreColor)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- QColor c = QColor::fromRgba(instr.value);
- void *a[] = { &c, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StoreColor)
-
- QML_BEGIN_INSTR(StoreDate)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- QDate d = QDate::fromJulianDay(instr.value);
- void *a[] = { &d, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StoreDate)
-
- QML_BEGIN_INSTR(StoreTime)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- QTime *t = (QTime *)&instr.time;
- void *a[] = { t, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StoreTime)
-
- QML_BEGIN_INSTR(StoreDateTime)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- QTime *t = (QTime *)&instr.time;
- QDateTime dt(QDate::fromJulianDay(instr.date), *t);
- void *a[] = { &dt, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StoreDateTime)
-
- QML_BEGIN_INSTR(StorePoint)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- QPoint *p = (QPoint *)&instr.point;
- void *a[] = { p, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StorePoint)
-
- QML_BEGIN_INSTR(StorePointF)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- QPointF *p = (QPointF *)&instr.point;
- void *a[] = { p, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StorePointF)
-
- QML_BEGIN_INSTR(StoreSize)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- QSize *s = (QSize *)&instr.size;
- void *a[] = { s, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StoreSize)
-
- QML_BEGIN_INSTR(StoreSizeF)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- QSizeF *s = (QSizeF *)&instr.size;
- void *a[] = { s, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StoreSizeF)
-
- QML_BEGIN_INSTR(StoreRect)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- QRect *r = (QRect *)&instr.rect;
- void *a[] = { r, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StoreRect)
-
- QML_BEGIN_INSTR(StoreRectF)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- QRectF *r = (QRectF *)&instr.rect;
- void *a[] = { r, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StoreRectF)
-
- QML_BEGIN_INSTR(StoreVector3D)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- QVector3D *v = (QVector3D *)&instr.vector;
- void *a[] = { v, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StoreVector3D)
-
- QML_BEGIN_INSTR(StoreVector4D)
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- QVector4D *v = (QVector4D *)&instr.vector;
- void *a[] = { v, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StoreVector4D)
-
- QML_BEGIN_INSTR(StoreObject)
- QObject *assignObj = objects.pop();
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- void *a[] = { (void *)&assignObj, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StoreObject)
-
QML_BEGIN_INSTR(AssignCustomType)
QObject *target = objects.top();
CLEAN_PROPERTY(target, instr.propertyIndex);
QDeclarativeBoundSignal *bs = new QDeclarativeBoundSignal(target, signal, target);
QDeclarativeExpression *expr =
- new QDeclarativeExpression(CTXT, context, PRIMITIVES.at(instr.value));
- expr->setSourceLocation(COMP->name, instr.line);
- static_cast<QDeclarativeExpressionPrivate *>(QObjectPrivate::get(expr))->name = QString::fromUtf8(DATAS.at(instr.name));
+ new QDeclarativeExpression(CTXT, context, PRIMITIVES.at(instr.value), true, COMP->name, instr.line, instr.column, *new QDeclarativeExpressionPrivate);
bs->setExpression(expr);
QML_END_INSTR(StoreSignal)
ss.setScript(PRIMITIVES.at(instr.value));
ss.d.data()->bindingId = instr.bindingId;
ss.d.data()->lineNumber = instr.line;
+ ss.d.data()->columnNumber = instr.column;
void *a[] = { &ss, 0, &status, &flags };
QMetaObject::metacall(target, QMetaObject::WriteProperty,
QObject *target = objects.top();
QDeclarativeParserStatus *status = reinterpret_cast<QDeclarativeParserStatus *>(reinterpret_cast<char *>(target) + instr.castValue);
parserStatus.push(status);
+#ifdef QML_ENABLE_TRACE
+ Q_ASSERT(QObjectPrivate::get(target)->declarativeData);
+ parserStatusData.push(static_cast<QDeclarativeData *>(QObjectPrivate::get(target)->declarativeData));
+#endif
status->d = &parserStatus.top();
status->classBegin();
QObject *context =
objects.at(objects.count() - 1 - instr.context);
- QDeclarativeProperty mp =
- QDeclarativePropertyPrivate::restore(DATAS.at(instr.property), target, CTXT);
-
- int coreIndex = mp.index();
-
- if (instr.isRoot && BINDINGSKIPLIST.testBit(coreIndex))
+ if (instr.isRoot && BINDINGSKIPLIST.testBit(instr.property.coreIndex))
QML_NEXT_INSTR(StoreBinding);
QDeclarativeBinding *bind = new QDeclarativeBinding(PRIMITIVES.at(instr.value), true,
- context, CTXT, COMP->name, instr.line);
+ context, CTXT, COMP->name, instr.line,
+ instr.column);
bindValues.push(bind);
bind->m_mePtr = &bindValues.top();
- bind->setTarget(mp);
+ bind->setTarget(target, instr.property, CTXT);
- bind->addToObject(target, QDeclarativePropertyPrivate::bindingIndex(mp));
+ bind->addToObject(target, QDeclarativePropertyPrivate::bindingIndex(instr.property));
QML_END_INSTR(StoreBinding)
QML_BEGIN_INSTR(StoreBindingOnAlias)
QObject *context =
objects.at(objects.count() - 1 - instr.context);
- QDeclarativeProperty mp =
- QDeclarativePropertyPrivate::restore(DATAS.at(instr.property), target, CTXT);
-
- int coreIndex = mp.index();
-
- if (instr.isRoot && BINDINGSKIPLIST.testBit(coreIndex))
+ if (instr.isRoot && BINDINGSKIPLIST.testBit(instr.property.coreIndex))
QML_NEXT_INSTR(StoreBindingOnAlias);
QDeclarativeBinding *bind = new QDeclarativeBinding(PRIMITIVES.at(instr.value), true,
- context, CTXT, COMP->name, instr.line);
+ context, CTXT, COMP->name, instr.line,
+ instr.column);
bindValues.push(bind);
bind->m_mePtr = &bindValues.top();
- bind->setTarget(mp);
+ bind->setTarget(target, instr.property, CTXT);
- QDeclarativeAbstractBinding *old = QDeclarativePropertyPrivate::setBindingNoEnable(target, coreIndex, QDeclarativePropertyPrivate::valueTypeCoreIndex(mp), bind);
+ QDeclarativeAbstractBinding *old =
+ QDeclarativePropertyPrivate::setBindingNoEnable(target, instr.property.coreIndex,
+ instr.property.getValueTypeCoreIndex(),
+ bind);
if (old) { old->destroy(); }
QML_END_INSTR(StoreBindingOnAlias)
QML_NEXT_INSTR(StoreV4Binding);
QDeclarativeAbstractBinding *binding =
- CTXT->v4bindings->configBinding(instr.value, target, scope, property);
+ CTXT->v4bindings->configBinding(instr.value, target, scope, property,
+ instr.line, instr.column);
bindValues.push(binding);
binding->m_mePtr = &bindValues.top();
binding->addToObject(target, property);
QObject *scope =
objects.at(objects.count() - 1 - instr.context);
- QDeclarativeProperty mp =
- QDeclarativePropertyPrivate::restore(DATAS.at(instr.property), target, CTXT);
-
- int coreIndex = mp.index();
-
- if (instr.isRoot && BINDINGSKIPLIST.testBit(coreIndex))
+ if (instr.isRoot && BINDINGSKIPLIST.testBit(instr.property.coreIndex))
QML_NEXT_INSTR(StoreV8Binding);
QDeclarativeAbstractBinding *binding =
- CTXT->v8bindings->configBinding(instr.value, target, scope, mp, instr.line);
+ CTXT->v8bindings->configBinding(instr.value, target, scope,
+ instr.property, instr.line,
+ instr.column);
bindValues.push(binding);
binding->m_mePtr = &bindValues.top();
- binding->addToObject(target, QDeclarativePropertyPrivate::bindingIndex(mp));
+ binding->addToObject(target, QDeclarativePropertyPrivate::bindingIndex(instr.property));
QML_END_INSTR(StoreV8Binding)
QML_BEGIN_INSTR(StoreValueSource)
QDeclarativePropertyValueSource *vs = reinterpret_cast<QDeclarativePropertyValueSource *>(reinterpret_cast<char *>(obj) + instr.castValue);
QObject *target = objects.at(objects.count() - 1 - instr.owner);
- QDeclarativeProperty prop =
- QDeclarativePropertyPrivate::restore(DATAS.at(instr.property), target, CTXT);
obj->setParent(target);
- vs->setTarget(prop);
+ vs->setTarget(QDeclarativePropertyPrivate::restore(target, instr.property, CTXT));
QML_END_INSTR(StoreValueSource)
QML_BEGIN_INSTR(StoreValueInterceptor)
QDeclarativePropertyValueInterceptor *vi = reinterpret_cast<QDeclarativePropertyValueInterceptor *>(reinterpret_cast<char *>(obj) + instr.castValue);
QObject *target = objects.at(objects.count() - 1 - instr.owner);
QDeclarativeProperty prop =
- QDeclarativePropertyPrivate::restore(DATAS.at(instr.property), target, CTXT);
+ QDeclarativePropertyPrivate::restore(target, instr.property, CTXT);
obj->setParent(target);
vi->setTarget(prop);
QDeclarativeVMEMetaObject *mo = static_cast<QDeclarativeVMEMetaObject *>((QMetaObject*)target->metaObject());
list.qListProperty.append((QDeclarativeListProperty<void>*)&list.qListProperty, ptr);
QML_END_INSTR(AssignObjectList)
- QML_BEGIN_INSTR(StoreVariantObject)
- QObject *assign = objects.pop();
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- QVariant v = QVariant::fromValue(assign);
- void *a[] = { &v, 0, &status, &flags };
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.propertyIndex, a);
- QML_END_INSTR(StoreVariantObject)
-
- QML_BEGIN_INSTR(StoreVarObject)
- QObject *assign = objects.pop();
- QObject *target = objects.top();
- CLEAN_PROPERTY(target, instr.propertyIndex);
-
- v8::Handle<v8::Value> v8Value = ep->v8engine()->newQObject(assign);
- static_cast<QDeclarativeVMEMetaObject *>(const_cast<QMetaObject *>(target->metaObject()))->setVMEProperty(instr.propertyIndex, v8Value);
- QML_END_INSTR(StoreVarObject)
-
QML_BEGIN_INSTR(StoreInterface)
QObject *assign = objects.pop();
QObject *target = objects.top();
delete objects.at(0);
if (!rootContext.isNull())
- rootContext->activeVME = 0;
+ rootContext->activeVMEData = 0;
// Remove the QDeclarativeParserStatus and QDeclarativeAbstractBinding back pointers
blank(parserStatus);
lists.deallocate();
bindValues.deallocate();
parserStatus.deallocate();
+#ifdef QML_ENABLE_TRACE
+ parserStatusData.deallocate();
+#endif
finalizeCallbacks.clear();
states.clear();
rootContext = 0;
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
QV8Engine *v8engine = ep->v8engine();
- // XXX Handle errors during the script compile!
+ // If compilation throws an error, a surrounding v8::TryCatch will record it.
v8::Local<v8::Script> program = v8engine->qmlModeCompile(m_programSource, url.toString(), 1);
+ if (program.IsEmpty())
+ return;
+
m_program = qPersistentNew<v8::Script>(program);
addToEngine(engine);
v8::HandleScope handle_scope;
v8::Context::Scope scope(v8engine->context());
- if (!script->isInitialized())
+ v8::TryCatch try_catch;
+ if (!script->isInitialized())
script->initialize(parentCtxt->engine);
v8::Local<v8::Object> qmlglobal = v8engine->qmlScope(ctxt, 0);
- v8::TryCatch try_catch;
- script->m_program->Run(qmlglobal);
+ if (!script->m_program.IsEmpty()) {
+ script->m_program->Run(qmlglobal);
+ } else {
+ // Compilation failed.
+ Q_ASSERT(try_catch.HasCaught());
+ }
v8::Persistent<v8::Object> rv;
}
#endif
-bool QDeclarativeVME::complete(const Interrupt &interrupt)
+QDeclarativeContextData *QDeclarativeVME::complete(const Interrupt &interrupt)
{
Q_ASSERT(engine ||
(bindValues.isEmpty() &&
finalizeCallbacks.isEmpty()));
if (!engine)
- return true;
+ return 0;
+
+ QDeclarativeTrace trace("VME Complete");
+#ifdef QML_ENABLE_TRACE
+ trace.addDetail("URL", rootComponent->url);
+#endif
ActiveVMERestorer restore(this, QDeclarativeEnginePrivate::get(engine));
QRecursionWatcher<QDeclarativeVME, &QDeclarativeVME::recursion> watcher(this);
+ {
+ QDeclarativeTrace trace("VME Binding Enable");
+ trace.event("begin binding eval");
while (!bindValues.isEmpty()) {
QDeclarativeAbstractBinding *b = bindValues.pop();
}
if (watcher.hasRecursed() || interrupt.shouldInterrupt())
- return false;
+ return 0;
}
bindValues.deallocate();
+ }
+ {
+ QDeclarativeTrace trace("VME Component Complete");
while (!parserStatus.isEmpty()) {
QDeclarativeParserStatus *status = parserStatus.pop();
+#ifdef QML_ENABLE_TRACE
+ QDeclarativeData *data = parserStatusData.pop();
+#endif
if (status && status->d) {
status->d = 0;
+#ifdef QML_ENABLE_TRACE
+ QDeclarativeTrace trace("Component complete");
+ trace.addDetail("URL", data->outerContext->url);
+ trace.addDetail("Line", data->lineNumber);
+#endif
status->componentComplete();
}
if (watcher.hasRecursed() || interrupt.shouldInterrupt())
- return false;
+ return 0;
}
parserStatus.deallocate();
+ }
+
+ {
+ QDeclarativeTrace trace("VME Finalize Callbacks");
+ for (int ii = 0; ii < finalizeCallbacks.count(); ++ii) {
+ QDeclarativeEnginePrivate::FinalizeCallback callback = finalizeCallbacks.at(ii);
+ QObject *obj = callback.first;
+ if (obj) {
+ void *args[] = { 0 };
+ QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod, callback.second, args);
+ }
+ if (watcher.hasRecursed())
+ return 0;
+ }
+ finalizeCallbacks.clear();
+ }
+ {
+ QDeclarativeTrace trace("VME Component.onCompleted Callbacks");
while (componentAttached) {
QDeclarativeComponentAttached *a = componentAttached;
a->rem();
emit a->completed();
if (watcher.hasRecursed() || interrupt.shouldInterrupt())
- return false;
+ return 0;
}
-
- if (!rootContext.isNull())
- rootContext->activeVME = 0;
-
- for (int ii = 0; ii < finalizeCallbacks.count(); ++ii) {
- QDeclarativeEnginePrivate::FinalizeCallback callback = finalizeCallbacks.at(ii);
- QObject *obj = callback.first;
- if (obj) {
- void *args[] = { 0 };
- QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod, callback.second, args);
- }
- if (watcher.hasRecursed())
- return false;
}
- finalizeCallbacks.clear();
+
+ QDeclarativeContextData *rv = rootContext;
reset();
- return true;
+ if (rv) rv->activeVMEData = data;
+
+ return rv;
}
void QDeclarativeVME::blank(QFiniteStack<QDeclarativeAbstractBinding *> &bs)
for (int ii = 0; ii < m_objectCount; ++ii)
m_objects[ii] = vme->objects[ii];
- m_contextCount = (vme->rootContext.isNull())?0:1 + vme->states.count();
+ m_contextCount = (vme->rootContext.isNull()?0:1) + vme->states.count();
m_contexts = new QDeclarativeGuardedContextData[m_contextCount];
for (int ii = 0; ii < vme->states.count(); ++ii)
m_contexts[ii] = vme->states.at(ii).context;