1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #include "qdeclarativevme_p.h"
44 #include "qdeclarativecompiler_p.h"
45 #include "qdeclarativeboundsignal_p.h"
46 #include "qdeclarativestringconverters_p.h"
47 #include <private/qmetaobjectbuilder_p.h>
48 #include <private/qfastmetabuilder_p.h>
49 #include "qdeclarativedata_p.h"
50 #include "qdeclarative.h"
51 #include "qdeclarativecustomparser_p.h"
52 #include "qdeclarativeengine.h"
53 #include "qdeclarativecontext.h"
54 #include "qdeclarativecomponent.h"
55 #include "qdeclarativecomponentattached_p.h"
56 #include "qdeclarativebinding_p.h"
57 #include "qdeclarativeengine_p.h"
58 #include "qdeclarativecomponent_p.h"
59 #include "qdeclarativevmemetaobject_p.h"
60 #include "qdeclarativebinding_p_p.h"
61 #include "qdeclarativecontext_p.h"
62 #include <private/qv4bindings_p.h>
63 #include <private/qv8bindings_p.h>
64 #include "qdeclarativeglobal_p.h"
65 #include <private/qfinitestack_p.h>
66 #include "qdeclarativescriptstring.h"
67 #include "qdeclarativescriptstring_p.h"
68 #include "qdeclarativepropertyvalueinterceptor_p.h"
75 #include <QtCore/qdebug.h>
76 #include <QtCore/qvarlengtharray.h>
77 #include <QtCore/qcoreapplication.h>
78 #include <QtCore/qdatetime.h>
79 #include <QtCore/qvarlengtharray.h>
80 #include <QtDeclarative/qjsvalue.h>
84 using namespace QDeclarativeVMETypes;
86 #define VME_EXCEPTION(desc, line) \
88 QDeclarativeError error; \
89 error.setDescription(desc.trimmed()); \
90 error.setLine(line); \
91 error.setUrl(COMP->url); \
96 void QDeclarativeVME::init(QDeclarativeContextData *ctxt, QDeclarativeCompiledData *comp, int start,
97 QDeclarativeContextData *creation)
105 creationContext = creation;
109 initState.context = ctxt;
110 initState.compiledData = comp;
111 initState.instructionStream = comp->bytecode.constData() + start;
112 states.push(initState);
114 typedef QDeclarativeInstruction I;
115 I *i = (I *)initState.instructionStream;
117 Q_ASSERT(comp->instructionType(i) == I::Init);
119 objects.allocate(i->init.objectStackSize);
120 lists.allocate(i->init.listStackSize);
121 bindValues.allocate(i->init.bindingsSize);
122 parserStatus.allocate(i->init.parserStatusSize);
124 #ifdef QML_ENABLE_TRACE
125 parserStatusData.allocate(i->init.parserStatusSize);
126 rootComponent = comp;
130 engine = ctxt->engine;
133 bool QDeclarativeVME::initDeferred(QObject *object)
135 QDeclarativeData *data = QDeclarativeData::get(object);
137 if (!data || !data->context || !data->deferredComponent)
140 QDeclarativeContextData *ctxt = data->context;
141 QDeclarativeCompiledData *comp = data->deferredComponent;
142 int start = data->deferredIdx;
145 initState.flags = State::Deferred;
146 initState.context = ctxt;
147 initState.compiledData = comp;
148 initState.instructionStream = comp->bytecode.constData() + start;
149 states.push(initState);
151 typedef QDeclarativeInstruction I;
152 I *i = (I *)initState.instructionStream;
154 Q_ASSERT(comp->instructionType(i) == I::DeferInit);
156 objects.allocate(i->deferInit.objectStackSize);
157 lists.allocate(i->deferInit.listStackSize);
158 bindValues.allocate(i->deferInit.bindingsSize);
159 parserStatus.allocate(i->deferInit.parserStatusSize);
161 objects.push(object);
163 #ifdef QML_ENABLE_TRACE
164 parserStatusData.allocate(i->deferInit.parserStatusSize);
165 rootComponent = comp;
169 engine = ctxt->engine;
175 struct ActiveVMERestorer
177 ActiveVMERestorer(QDeclarativeVME *me, QDeclarativeEnginePrivate *ep)
178 : ep(ep), oldVME(ep->activeVME) { ep->activeVME = me; }
179 ~ActiveVMERestorer() { ep->activeVME = oldVME; }
181 QDeclarativeEnginePrivate *ep;
182 QDeclarativeVME *oldVME;
186 QObject *QDeclarativeVME::execute(QList<QDeclarativeError> *errors, const Interrupt &interrupt)
188 Q_ASSERT(states.count() >= 1);
190 #ifdef QML_ENABLE_TRACE
191 QDeclarativeTrace trace("VME Execute");
192 trace.addDetail("URL", rootComponent->url);
195 QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(states.at(0).context->engine);
197 ActiveVMERestorer restore(this, ep);
199 QObject *rv = run(errors, interrupt);
204 inline bool fastHasBinding(QObject *o, int index)
206 QDeclarativeData *ddata = static_cast<QDeclarativeData *>(QObjectPrivate::get(o)->declarativeData);
208 return ddata && (ddata->bindingBitsSize > index) &&
209 (ddata->bindingBits[index / 32] & (1 << (index % 32)));
212 static void removeBindingOnProperty(QObject *o, int index)
214 QDeclarativeAbstractBinding *binding = QDeclarativePropertyPrivate::setBinding(o, index, -1, 0);
215 if (binding) binding->destroy();
218 static QVariant variantFromString(const QString &string)
220 return QDeclarativeStringConverters::variantFromString(string);
223 // XXX we probably need some form of "work count" here to prevent us checking this
224 // for every instruction.
225 #define QML_BEGIN_INSTR_COMMON(I) { \
226 const QDeclarativeInstructionMeta<(int)QDeclarativeInstruction::I>::DataType &instr = QDeclarativeInstructionMeta<(int)QDeclarativeInstruction::I>::data(*genericInstr); \
227 INSTRUCTIONSTREAM += QDeclarativeInstructionMeta<(int)QDeclarativeInstruction::I>::Size; \
230 #ifdef QML_THREADED_VME_INTERPRETER
231 # define QML_BEGIN_INSTR(I) op_##I: \
232 QML_BEGIN_INSTR_COMMON(I)
234 # define QML_NEXT_INSTR(I) { \
235 if (watcher.hasRecursed()) return 0; \
236 genericInstr = reinterpret_cast<const QDeclarativeInstruction *>(INSTRUCTIONSTREAM); \
237 goto *genericInstr->common.code; \
240 # define QML_END_INSTR(I) } \
241 if (watcher.hasRecursed()) return 0; \
242 genericInstr = reinterpret_cast<const QDeclarativeInstruction *>(INSTRUCTIONSTREAM); \
243 if (interrupt.shouldInterrupt()) return 0; \
244 goto *genericInstr->common.code;
247 # define QML_BEGIN_INSTR(I) \
248 case QDeclarativeInstruction::I: \
249 QML_BEGIN_INSTR_COMMON(I)
251 # define QML_NEXT_INSTR(I) { \
252 if (watcher.hasRecursed()) return 0; \
256 # define QML_END_INSTR(I) \
257 if (watcher.hasRecursed() || interrupt.shouldInterrupt()) return 0; \
261 #define QML_STORE_VALUE(name, cpptype, value) \
262 QML_BEGIN_INSTR(name) \
264 void *a[] = { (void *)&v, 0, &status, &flags }; \
265 QObject *target = objects.top(); \
266 CLEAN_PROPERTY(target, instr.propertyIndex); \
267 QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.propertyIndex, a); \
270 #define QML_STORE_LIST(name, cpptype, value) \
271 QML_BEGIN_INSTR(name) \
274 void *a[] = { (void *)&v, 0, &status, &flags }; \
275 QObject *target = objects.top(); \
276 CLEAN_PROPERTY(target, instr.propertyIndex); \
277 QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.propertyIndex, a); \
280 #define QML_STORE_VAR(name, value) \
281 QML_BEGIN_INSTR(name) \
282 v8::Handle<v8::Value> v8value = value; \
283 QObject *target = objects.top(); \
284 CLEAN_PROPERTY(target, instr.propertyIndex); \
285 QMetaObject *mo = const_cast<QMetaObject *>(target->metaObject()); \
286 QDeclarativeVMEMetaObject *vmemo = static_cast<QDeclarativeVMEMetaObject *>(mo); \
287 vmemo->setVMEProperty(instr.propertyIndex, v8value); \
290 #define QML_STORE_POINTER(name, value) \
291 QML_BEGIN_INSTR(name) \
292 void *a[] = { (void *)value, 0, &status, &flags }; \
293 QObject *target = objects.top(); \
294 CLEAN_PROPERTY(target, instr.propertyIndex); \
295 QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.propertyIndex, a); \
298 #define CLEAN_PROPERTY(o, index) \
299 if (fastHasBinding(o, index)) \
300 removeBindingOnProperty(o, index)
302 QObject *QDeclarativeVME::run(QList<QDeclarativeError> *errors,
303 const Interrupt &interrupt
304 #ifdef QML_THREADED_VME_INTERPRETER
305 , void ***storeJumpTable
309 #ifdef QML_THREADED_VME_INTERPRETER
310 if (storeJumpTable) {
311 #define QML_INSTR_ADDR(I, FMT) &&op_##I,
312 static void *jumpTable[] = {
313 FOR_EACH_QML_INSTR(QML_INSTR_ADDR)
315 #undef QML_INSTR_ADDR
316 *storeJumpTable = jumpTable;
320 Q_ASSERT(errors->isEmpty());
321 Q_ASSERT(states.count() >= 1);
323 QDeclarativeEngine *engine = states.at(0).context->engine;
324 QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
326 // Need a v8 handle scope and execution context for StoreVar instructions.
327 v8::HandleScope handleScope;
328 v8::Context::Scope contextScope(ep->v8engine()->context());
330 int status = -1; // needed for dbus
331 QDeclarativePropertyPrivate::WriteFlags flags = QDeclarativePropertyPrivate::BypassInterceptor |
332 QDeclarativePropertyPrivate::RemoveBindingOnAliasWrite;
334 QRecursionWatcher<QDeclarativeVME, &QDeclarativeVME::recursion> watcher(this);
336 #define COMP states.top().compiledData
337 #define CTXT states.top().context
338 #define INSTRUCTIONSTREAM states.top().instructionStream
339 #define BINDINGSKIPLIST states.top().bindingSkipList
341 #define TYPES COMP->types
342 #define PRIMITIVES COMP->primitives
343 #define DATAS COMP->datas
344 #define PROGRAMS COMP->programs
345 #define PROPERTYCACHES COMP->propertyCaches
346 #define SCRIPTS COMP->scripts
347 #define URLS COMP->urls
349 #ifdef QML_THREADED_VME_INTERPRETER
350 const QDeclarativeInstruction *genericInstr = reinterpret_cast<const QDeclarativeInstruction *>(INSTRUCTIONSTREAM);
351 goto *genericInstr->common.code;
354 const QDeclarativeInstruction *genericInstr = reinterpret_cast<const QDeclarativeInstruction *>(INSTRUCTIONSTREAM);
356 switch (genericInstr->common.instructionType) {
359 // Store a created object in a property. These all pop from the objects stack.
360 QML_STORE_VALUE(StoreObject, QObject *, objects.pop());
361 QML_STORE_VALUE(StoreVariantObject, QVariant, QVariant::fromValue(objects.pop()));
362 QML_STORE_VAR(StoreVarObject, ep->v8engine()->newQObject(objects.pop()));
364 // Store a literal value in a corresponding property
365 QML_STORE_VALUE(StoreFloat, float, instr.value);
366 QML_STORE_VALUE(StoreDouble, double, instr.value);
367 QML_STORE_VALUE(StoreBool, bool, instr.value);
368 QML_STORE_VALUE(StoreInteger, int, instr.value);
369 QML_STORE_VALUE(StoreColor, QColor, QColor::fromRgba(instr.value));
370 QML_STORE_VALUE(StoreDate, QDate, QDate::fromJulianDay(instr.value));
371 QML_STORE_VALUE(StoreDateTime, QDateTime,
372 QDateTime(QDate::fromJulianDay(instr.date), *(QTime *)&instr.time));
373 QML_STORE_POINTER(StoreTime, (QTime *)&instr.time);
374 QML_STORE_POINTER(StorePoint, (QPoint *)&instr.point);
375 QML_STORE_POINTER(StorePointF, (QPointF *)&instr.point);
376 QML_STORE_POINTER(StoreSize, (QSize *)&instr.size);
377 QML_STORE_POINTER(StoreSizeF, (QSizeF *)&instr.size);
378 QML_STORE_POINTER(StoreRect, (QRect *)&instr.rect);
379 QML_STORE_POINTER(StoreRectF, (QRectF *)&instr.rect);
380 QML_STORE_POINTER(StoreVector3D, (QVector3D *)&instr.vector);
381 QML_STORE_POINTER(StoreVector4D, (QVector4D *)&instr.vector);
382 QML_STORE_POINTER(StoreString, &PRIMITIVES.at(instr.value));
383 QML_STORE_POINTER(StoreByteArray, &DATAS.at(instr.value));
384 QML_STORE_POINTER(StoreUrl, &URLS.at(instr.value));
385 QML_STORE_VALUE(StoreTrString, QString,
386 QCoreApplication::translate(DATAS.at(instr.context).constData(),
387 DATAS.at(instr.text).constData(),
388 DATAS.at(instr.comment).constData(),
389 QCoreApplication::UnicodeUTF8,
391 QML_STORE_VALUE(StoreTrIdString, QString, qtTrId(DATAS.at(instr.text).constData(), instr.n));
393 // Store a literal value in a QList
394 QML_STORE_LIST(StoreStringList, QStringList, PRIMITIVES.at(instr.value));
395 QML_STORE_LIST(StoreStringQList, QList<QString>, PRIMITIVES.at(instr.value));
396 QML_STORE_LIST(StoreUrlQList, QList<QUrl>, URLS.at(instr.value));
397 QML_STORE_LIST(StoreDoubleQList, QList<double>, instr.value);
398 QML_STORE_LIST(StoreBoolQList, QList<bool>, instr.value);
399 QML_STORE_LIST(StoreIntegerQList, QList<int>, instr.value);
401 // Store a literal value in a QVariant property
402 QML_STORE_VALUE(StoreVariant, QVariant, variantFromString(PRIMITIVES.at(instr.value)));
403 QML_STORE_VALUE(StoreVariantInteger, QVariant, QVariant(instr.value));
404 QML_STORE_VALUE(StoreVariantDouble, QVariant, QVariant(instr.value));
405 QML_STORE_VALUE(StoreVariantBool, QVariant, QVariant(instr.value));
407 // Store a literal value in a var property.
408 // We deliberately do not use string converters here
409 QML_STORE_VAR(StoreVar, ep->v8engine()->fromVariant(PRIMITIVES.at(instr.value)));
410 QML_STORE_VAR(StoreVarInteger, v8::Integer::New(instr.value));
411 QML_STORE_VAR(StoreVarDouble, v8::Number::New(instr.value));
412 QML_STORE_VAR(StoreVarBool, v8::Boolean::New(instr.value));
415 QML_BEGIN_INSTR(Init)
416 // Ensure that the compiled data has been initialized
417 if (!COMP->isInitialized()) COMP->initialize(engine);
419 QDeclarativeContextData *parentCtxt = CTXT;
420 CTXT = new QDeclarativeContextData;
421 CTXT->isInternal = true;
422 CTXT->url = COMP->url;
423 CTXT->urlString = COMP->name;
424 CTXT->imports = COMP->importCache;
425 CTXT->imports->addref();
426 CTXT->setParent(parentCtxt);
427 if (instr.contextCache != -1)
428 CTXT->setIdPropertyData(COMP->contextCaches.at(instr.contextCache));
429 if (instr.compiledBinding != -1) {
430 const char *v4data = DATAS.at(instr.compiledBinding).constData();
431 CTXT->v4bindings = new QV4Bindings(v4data, CTXT, COMP);
433 if (states.count() == 1) {
435 rootContext->activeVMEData = data;
437 if (states.count() == 1 && !creationContext.isNull()) {
438 // A component that is logically created within another component instance shares the
439 // same instances of script imports. For example:
441 // import QtQuick 2.0
442 // import "test.js" as Test
444 // model: Test.getModel()
445 // delegate: Component {
446 // Text { text: Test.getValue(index); }
450 // Has the same "Test" instance. To implement this, we simply copy the v8 handles into
451 // the inner context. We have to create a fresh persistent handle for each to prevent
452 // double dispose. It is possible we could do this more efficiently using some form of
453 // referencing instead.
454 CTXT->importedScripts = creationContext->importedScripts;
455 for (int ii = 0; ii < CTXT->importedScripts.count(); ++ii)
456 CTXT->importedScripts[ii] = qPersistentNew<v8::Object>(CTXT->importedScripts[ii]);
460 QML_BEGIN_INSTR(DeferInit)
461 QML_END_INSTR(DeferInit)
463 QML_BEGIN_INSTR(Done)
466 if (states.isEmpty())
470 QML_BEGIN_INSTR(CreateQMLObject)
471 const QDeclarativeCompiledData::TypeReference &type = TYPES.at(instr.type);
472 Q_ASSERT(type.component);
474 states.push(State());
476 State *cState = &states[states.count() - 2];
477 State *nState = &states[states.count() - 1];
479 nState->context = cState->context;
480 nState->compiledData = type.component;
481 nState->instructionStream = type.component->bytecode.constData();
483 if (instr.bindingBits != -1) {
484 const QByteArray &bits = cState->compiledData->datas.at(instr.bindingBits);
485 nState->bindingSkipList = QBitField((const quint32*)bits.constData(),
489 nState->bindingSkipList = nState->bindingSkipList.united(cState->bindingSkipList);
491 // As the state in the state stack changed, execution will continue in the new program.
492 QML_END_INSTR(CreateQMLObject)
494 QML_BEGIN_INSTR(CompleteQMLObject)
495 QObject *o = objects.top();
497 QDeclarativeData *ddata = QDeclarativeData::get(o);
501 if (ddata->context) {
502 Q_ASSERT(ddata->context != CTXT);
503 Q_ASSERT(ddata->outerContext);
504 Q_ASSERT(ddata->outerContext != CTXT);
505 QDeclarativeContextData *c = ddata->context;
506 while (c->linkedContext) c = c->linkedContext;
507 c->linkedContext = CTXT;
512 ddata->ownContext = true;
513 } else if (!ddata->context) {
517 ddata->setImplicitDestructible();
518 ddata->outerContext = CTXT;
519 ddata->lineNumber = instr.line;
520 ddata->columnNumber = instr.column;
521 QML_END_INSTR(CompleteQMLObject)
523 QML_BEGIN_INSTR(CreateCppObject)
524 const QDeclarativeCompiledData::TypeReference &type = TYPES.at(instr.type);
529 type.type->create(&o, &memory, sizeof(QDeclarativeData));
530 QDeclarativeData *ddata = new (memory) QDeclarativeData;
531 ddata->ownMemory = false;
532 QObjectPrivate::get(o)->declarativeData = ddata;
534 if (type.typePropertyCache && !ddata->propertyCache) {
535 ddata->propertyCache = type.typePropertyCache;
536 ddata->propertyCache->addref();
540 VME_EXCEPTION(tr("Unable to create object of type %1").arg(type.className), instr.line);
543 if (ddata->context) {
544 Q_ASSERT(ddata->context != CTXT);
545 Q_ASSERT(ddata->outerContext);
546 Q_ASSERT(ddata->outerContext != CTXT);
547 QDeclarativeContextData *c = ddata->context;
548 while (c->linkedContext) c = c->linkedContext;
549 c->linkedContext = CTXT;
554 ddata->ownContext = true;
555 } else if (!ddata->context) {
559 ddata->setImplicitDestructible();
560 ddata->outerContext = CTXT;
561 ddata->lineNumber = instr.line;
562 ddata->columnNumber = instr.column;
564 if (instr.data != -1) {
565 QDeclarativeCustomParser *customParser =
566 TYPES.at(instr.type).type->customParser();
567 customParser->setCustomData(o, DATAS.at(instr.data));
569 if (!objects.isEmpty()) {
570 QObject *parent = objects.top();
571 #if 0 // ### refactor
572 if (o->isWidgetType() && parent->isWidgetType())
573 static_cast<QWidget*>(o)->setParent(static_cast<QWidget*>(parent));
576 QDeclarative_setParent_noEvent(o, parent);
579 QML_END_INSTR(CreateCppObject)
581 QML_BEGIN_INSTR(CreateSimpleObject)
582 QObject *o = (QObject *)operator new(instr.typeSize + sizeof(QDeclarativeData));
583 ::memset(o, 0, instr.typeSize + sizeof(QDeclarativeData));
586 QDeclarativeData *ddata = (QDeclarativeData *)(((const char *)o) + instr.typeSize);
587 const QDeclarativeCompiledData::TypeReference &ref = TYPES.at(instr.type);
588 if (!ddata->propertyCache && ref.typePropertyCache) {
589 ddata->propertyCache = ref.typePropertyCache;
590 ddata->propertyCache->addref();
592 ddata->lineNumber = instr.line;
593 ddata->columnNumber = instr.column;
595 QObjectPrivate::get(o)->declarativeData = ddata;
596 ddata->context = ddata->outerContext = CTXT;
597 ddata->nextContextObject = CTXT->contextObjects;
598 if (ddata->nextContextObject)
599 ddata->nextContextObject->prevContextObject = &ddata->nextContextObject;
600 ddata->prevContextObject = &CTXT->contextObjects;
601 CTXT->contextObjects = ddata;
603 QObject *parent = objects.top();
604 QDeclarative_setParent_noEvent(o, parent);
607 QML_END_INSTR(CreateSimpleObject)
609 QML_BEGIN_INSTR(SetId)
610 QObject *target = objects.top();
611 CTXT->setIdProperty(instr.index, target);
614 QML_BEGIN_INSTR(SetDefault)
615 CTXT->contextObject = objects.top();
616 QML_END_INSTR(SetDefault)
618 QML_BEGIN_INSTR(CreateComponent)
619 QDeclarativeComponent *qcomp =
620 new QDeclarativeComponent(CTXT->engine, COMP, INSTRUCTIONSTREAM - COMP->bytecode.constData(),
621 objects.isEmpty() ? 0 : objects.top());
623 QDeclarativeData *ddata = QDeclarativeData::get(qcomp, true);
626 CTXT->addObject(qcomp);
629 ddata->ownContext = true;
631 ddata->setImplicitDestructible();
632 ddata->outerContext = CTXT;
633 ddata->lineNumber = instr.line;
634 ddata->columnNumber = instr.column;
636 QDeclarativeComponentPrivate::get(qcomp)->creationContext = CTXT;
639 INSTRUCTIONSTREAM += instr.count;
640 QML_END_INSTR(CreateComponent)
642 QML_BEGIN_INSTR(StoreMetaObject)
643 QObject *target = objects.top();
646 const QByteArray &metadata = DATAS.at(instr.data);
647 QFastMetaBuilder::fromData(&mo, 0, metadata);
649 const QDeclarativeVMEMetaData *data =
650 (const QDeclarativeVMEMetaData *)DATAS.at(instr.aliasData).constData();
652 (void)new QDeclarativeVMEMetaObject(target, &mo, data, COMP);
654 if (instr.propertyCache != -1) {
655 QDeclarativeData *ddata = QDeclarativeData::get(target, true);
656 if (ddata->propertyCache) ddata->propertyCache->release();
657 ddata->propertyCache = PROPERTYCACHES.at(instr.propertyCache);
658 ddata->propertyCache->addref();
660 QML_END_INSTR(StoreMetaObject)
662 QML_BEGIN_INSTR(AssignCustomType)
663 QObject *target = objects.top();
664 CLEAN_PROPERTY(target, instr.propertyIndex);
666 const QString &primitive = PRIMITIVES.at(instr.primitive);
667 int type = instr.type;
668 QDeclarativeMetaType::StringConverter converter = QDeclarativeMetaType::customStringConverter(type);
669 QVariant v = (*converter)(primitive);
672 target->metaObject()->property(instr.propertyIndex);
673 if (v.isNull() || ((int)prop.type() != type && prop.userType() != type))
674 VME_EXCEPTION(tr("Cannot assign value %1 to property %2").arg(primitive).arg(QString::fromUtf8(prop.name())), instr.line);
676 void *a[] = { (void *)v.data(), 0, &status, &flags };
677 QMetaObject::metacall(target, QMetaObject::WriteProperty,
678 instr.propertyIndex, a);
679 QML_END_INSTR(AssignCustomType)
681 QML_BEGIN_INSTR(AssignSignalObject)
684 QObject *assign = objects.pop();
685 QObject *target = objects.top();
686 int sigIdx = instr.signal;
687 const QString &pr = PRIMITIVES.at(sigIdx);
689 QDeclarativeProperty prop(target, pr);
690 if (prop.type() & QDeclarativeProperty::SignalProperty) {
692 QMetaMethod method = QDeclarativeMetaType::defaultMethod(assign);
693 if (method.signature() == 0)
694 VME_EXCEPTION(tr("Cannot assign object type %1 with no default method").arg(QString::fromLatin1(assign->metaObject()->className())), instr.line);
696 if (!QMetaObject::checkConnectArgs(prop.method().signature(), method.signature()))
697 VME_EXCEPTION(tr("Cannot connect mismatched signal/slot %1 %vs. %2").arg(QString::fromLatin1(method.signature())).arg(QString::fromLatin1(prop.method().signature())), instr.line);
699 QDeclarativePropertyPrivate::connect(target, prop.index(), assign, method.methodIndex());
702 VME_EXCEPTION(tr("Cannot assign an object to signal property %1").arg(pr), instr.line);
706 QML_END_INSTR(AssignSignalObject)
708 QML_BEGIN_INSTR(StoreSignal)
709 QObject *target = objects.top();
710 QObject *context = objects.at(objects.count() - 1 - instr.context);
712 QMetaMethod signal = target->metaObject()->method(instr.signalIndex);
714 QDeclarativeBoundSignal *bs = new QDeclarativeBoundSignal(target, signal, target);
715 QDeclarativeExpression *expr =
716 new QDeclarativeExpression(CTXT, context, DATAS.at(instr.value), true, COMP->name, instr.line, instr.column, *new QDeclarativeExpressionPrivate);
717 bs->setExpression(expr);
718 QML_END_INSTR(StoreSignal)
720 QML_BEGIN_INSTR(StoreImportedScript)
721 CTXT->importedScripts << run(CTXT, SCRIPTS.at(instr.value));
722 QML_END_INSTR(StoreImportedScript)
724 QML_BEGIN_INSTR(StoreScriptString)
725 QObject *target = objects.top();
726 QObject *scope = objects.at(objects.count() - 1 - instr.scope);
727 QDeclarativeScriptString ss;
728 ss.setContext(CTXT->asQDeclarativeContext());
729 ss.setScopeObject(scope);
730 ss.setScript(PRIMITIVES.at(instr.value));
731 ss.d.data()->bindingId = instr.bindingId;
732 ss.d.data()->lineNumber = instr.line;
733 ss.d.data()->columnNumber = instr.column;
735 void *a[] = { &ss, 0, &status, &flags };
736 QMetaObject::metacall(target, QMetaObject::WriteProperty,
737 instr.propertyIndex, a);
738 QML_END_INSTR(StoreScriptString)
740 QML_BEGIN_INSTR(BeginObject)
741 QObject *target = objects.top();
742 QDeclarativeParserStatus *status = reinterpret_cast<QDeclarativeParserStatus *>(reinterpret_cast<char *>(target) + instr.castValue);
743 parserStatus.push(status);
744 #ifdef QML_ENABLE_TRACE
745 Q_ASSERT(QObjectPrivate::get(target)->declarativeData);
746 parserStatusData.push(static_cast<QDeclarativeData *>(QObjectPrivate::get(target)->declarativeData));
748 status->d = &parserStatus.top();
750 status->classBegin();
751 QML_END_INSTR(BeginObject)
753 QML_BEGIN_INSTR(InitV8Bindings)
754 CTXT->v8bindings = new QV8Bindings(&PROGRAMS[instr.programIndex], instr.line, CTXT);
755 QML_END_INSTR(InitV8Bindings)
757 QML_BEGIN_INSTR(StoreBinding)
759 objects.at(objects.count() - 1 - instr.owner);
761 objects.at(objects.count() - 1 - instr.context);
763 if (instr.isRoot && BINDINGSKIPLIST.testBit(instr.property.coreIndex))
764 QML_NEXT_INSTR(StoreBinding);
766 QDeclarativeBinding *bind = new QDeclarativeBinding(PRIMITIVES.at(instr.value), true,
767 context, CTXT, COMP->name, instr.line,
769 bindValues.push(bind);
770 bind->m_mePtr = &bindValues.top();
771 bind->setTarget(target, instr.property, CTXT);
773 typedef QDeclarativePropertyPrivate QDPP;
774 Q_ASSERT(bind->propertyIndex() == QDPP::bindingIndex(instr.property));
775 Q_ASSERT(bind->object() == target);
778 QML_END_INSTR(StoreBinding)
780 QML_BEGIN_INSTR(StoreBindingOnAlias)
782 objects.at(objects.count() - 1 - instr.owner);
784 objects.at(objects.count() - 1 - instr.context);
786 if (instr.isRoot && BINDINGSKIPLIST.testBit(instr.property.coreIndex))
787 QML_NEXT_INSTR(StoreBindingOnAlias);
789 QDeclarativeBinding *bind = new QDeclarativeBinding(PRIMITIVES.at(instr.value), true,
790 context, CTXT, COMP->name, instr.line,
792 bindValues.push(bind);
793 bind->m_mePtr = &bindValues.top();
794 bind->setTarget(target, instr.property, CTXT);
796 QDeclarativeAbstractBinding *old =
797 QDeclarativePropertyPrivate::setBindingNoEnable(target, instr.property.coreIndex,
798 instr.property.getValueTypeCoreIndex(),
800 if (old) { old->destroy(); }
801 QML_END_INSTR(StoreBindingOnAlias)
803 QML_BEGIN_INSTR(StoreV4Binding)
805 objects.at(objects.count() - 1 - instr.owner);
807 objects.at(objects.count() - 1 - instr.context);
809 int property = instr.property;
810 if (instr.isRoot && BINDINGSKIPLIST.testBit(property & 0xFFFF))
811 QML_NEXT_INSTR(StoreV4Binding);
813 QDeclarativeAbstractBinding *binding =
814 CTXT->v4bindings->configBinding(instr.value, target, scope, property,
815 instr.line, instr.column);
816 bindValues.push(binding);
817 binding->m_mePtr = &bindValues.top();
819 Q_ASSERT(binding->propertyIndex() == property);
820 Q_ASSERT(binding->object() == target);
822 binding->addToObject();
823 QML_END_INSTR(StoreV4Binding)
825 QML_BEGIN_INSTR(StoreV8Binding)
827 objects.at(objects.count() - 1 - instr.owner);
829 objects.at(objects.count() - 1 - instr.context);
831 if (instr.isRoot && BINDINGSKIPLIST.testBit(instr.property.coreIndex))
832 QML_NEXT_INSTR(StoreV8Binding);
834 QDeclarativeAbstractBinding *binding = CTXT->v8bindings->configBinding(target, scope,
837 bindValues.push(binding);
838 binding->m_mePtr = &bindValues.top();
840 typedef QDeclarativePropertyPrivate QDPP;
841 Q_ASSERT(binding->propertyIndex() == QDPP::bindingIndex(instr.property));
842 Q_ASSERT(binding->object() == target);
844 binding->addToObject();
846 QML_END_INSTR(StoreV8Binding)
848 QML_BEGIN_INSTR(StoreValueSource)
849 QObject *obj = objects.pop();
850 QDeclarativePropertyValueSource *vs = reinterpret_cast<QDeclarativePropertyValueSource *>(reinterpret_cast<char *>(obj) + instr.castValue);
851 QObject *target = objects.at(objects.count() - 1 - instr.owner);
853 obj->setParent(target);
854 vs->setTarget(QDeclarativePropertyPrivate::restore(target, instr.property, CTXT));
855 QML_END_INSTR(StoreValueSource)
857 QML_BEGIN_INSTR(StoreValueInterceptor)
858 QObject *obj = objects.pop();
859 QDeclarativePropertyValueInterceptor *vi = reinterpret_cast<QDeclarativePropertyValueInterceptor *>(reinterpret_cast<char *>(obj) + instr.castValue);
860 QObject *target = objects.at(objects.count() - 1 - instr.owner);
861 QDeclarativeProperty prop =
862 QDeclarativePropertyPrivate::restore(target, instr.property, CTXT);
863 obj->setParent(target);
865 QDeclarativeVMEMetaObject *mo = static_cast<QDeclarativeVMEMetaObject *>((QMetaObject*)target->metaObject());
866 mo->registerInterceptor(prop.index(), QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), vi);
867 QML_END_INSTR(StoreValueInterceptor)
869 QML_BEGIN_INSTR(StoreObjectQList)
870 QObject *assign = objects.pop();
872 const List &list = lists.top();
873 list.qListProperty.append((QDeclarativeListProperty<void>*)&list.qListProperty, assign);
874 QML_END_INSTR(StoreObjectQList)
876 QML_BEGIN_INSTR(AssignObjectList)
877 // This is only used for assigning interfaces
878 QObject *assign = objects.pop();
879 const List &list = lists.top();
881 int type = list.type;
885 const char *iid = QDeclarativeMetaType::interfaceIId(type);
887 ptr = assign->qt_metacast(iid);
889 VME_EXCEPTION(tr("Cannot assign object to list"), instr.line);
892 list.qListProperty.append((QDeclarativeListProperty<void>*)&list.qListProperty, ptr);
893 QML_END_INSTR(AssignObjectList)
895 QML_BEGIN_INSTR(StoreInterface)
896 QObject *assign = objects.pop();
897 QObject *target = objects.top();
898 CLEAN_PROPERTY(target, instr.propertyIndex);
900 int coreIdx = instr.propertyIndex;
901 QMetaProperty prop = target->metaObject()->property(coreIdx);
902 int t = prop.userType();
903 const char *iid = QDeclarativeMetaType::interfaceIId(t);
906 void *ptr = assign->qt_metacast(iid);
908 void *a[] = { &ptr, 0, &status, &flags };
909 QMetaObject::metacall(target,
910 QMetaObject::WriteProperty,
917 VME_EXCEPTION(tr("Cannot assign object to interface property"), instr.line);
918 QML_END_INSTR(StoreInterface)
920 QML_BEGIN_INSTR(FetchAttached)
921 QObject *target = objects.top();
923 QObject *qmlObject = qmlAttachedPropertiesObjectById(instr.id, target);
926 VME_EXCEPTION(tr("Unable to create attached object"), instr.line);
928 objects.push(qmlObject);
929 QML_END_INSTR(FetchAttached)
931 QML_BEGIN_INSTR(FetchQList)
932 QObject *target = objects.top();
934 lists.push(List(instr.type));
937 a[0] = (void *)&(lists.top().qListProperty);
938 QMetaObject::metacall(target, QMetaObject::ReadProperty,
940 QML_END_INSTR(FetchQList)
942 QML_BEGIN_INSTR(FetchObject)
943 QObject *target = objects.top();
946 // NOTE: This assumes a cast to QObject does not alter the
950 QMetaObject::metacall(target, QMetaObject::ReadProperty,
954 VME_EXCEPTION(tr("Cannot set properties on %1 as it is null").arg(QString::fromUtf8(target->metaObject()->property(instr.property).name())), instr.line);
957 QML_END_INSTR(FetchObject)
959 QML_BEGIN_INSTR(PopQList)
961 QML_END_INSTR(PopQList)
963 QML_BEGIN_INSTR(Defer)
964 if (instr.deferCount) {
965 QObject *target = objects.top();
966 QDeclarativeData *data =
967 QDeclarativeData::get(target, true);
969 data->deferredComponent = COMP;
970 data->deferredIdx = INSTRUCTIONSTREAM - COMP->bytecode.constData();
971 INSTRUCTIONSTREAM += instr.deferCount;
975 QML_BEGIN_INSTR(PopFetchedObject)
977 QML_END_INSTR(PopFetchedObject)
979 QML_BEGIN_INSTR(FetchValueType)
980 QObject *target = objects.top();
982 if (instr.bindingSkipList != 0) {
983 // Possibly need to clear bindings
984 QDeclarativeData *targetData = QDeclarativeData::get(target);
986 QDeclarativeAbstractBinding *binding =
987 QDeclarativePropertyPrivate::binding(target, instr.property, -1);
989 if (binding && binding->bindingType() != QDeclarativeAbstractBinding::ValueTypeProxy) {
990 QDeclarativePropertyPrivate::setBinding(target, instr.property, -1, 0);
992 } else if (binding) {
993 QDeclarativeValueTypeProxyBinding *proxy =
994 static_cast<QDeclarativeValueTypeProxyBinding *>(binding);
995 proxy->removeBindings(instr.bindingSkipList);
1000 QDeclarativeValueType *valueHandler = ep->valueTypes[instr.type];
1001 valueHandler->read(target, instr.property);
1002 objects.push(valueHandler);
1003 QML_END_INSTR(FetchValueType)
1005 QML_BEGIN_INSTR(PopValueType)
1006 QDeclarativeValueType *valueHandler =
1007 static_cast<QDeclarativeValueType *>(objects.pop());
1008 QObject *target = objects.top();
1009 valueHandler->write(target, instr.property, QDeclarativePropertyPrivate::BypassInterceptor);
1010 QML_END_INSTR(PopValueType)
1012 #ifdef QML_THREADED_VME_INTERPRETER
1016 qFatal("QDeclarativeCompiledData: Internal error - unknown instruction %d", genericInstr->common.instructionType);
1023 Q_ASSERT(!states.isEmpty());
1024 Q_ASSERT(!errors->isEmpty());
1031 Q_ASSERT(objects.count() == 1);
1033 QObject *rv = objects.top();
1035 objects.deallocate();
1042 void QDeclarativeVME::reset()
1044 Q_ASSERT(!states.isEmpty() || objects.isEmpty());
1046 QRecursionWatcher<QDeclarativeVME, &QDeclarativeVME::recursion> watcher(this);
1048 if (!objects.isEmpty() && !(states.at(0).flags & State::Deferred))
1049 delete objects.at(0);
1051 if (!rootContext.isNull())
1052 rootContext->activeVMEData = 0;
1054 // Remove the QDeclarativeParserStatus and QDeclarativeAbstractBinding back pointers
1055 blank(parserStatus);
1058 while (componentAttached) {
1059 QDeclarativeComponentAttached *a = componentAttached;
1064 objects.deallocate();
1066 bindValues.deallocate();
1067 parserStatus.deallocate();
1068 #ifdef QML_ENABLE_TRACE
1069 parserStatusData.deallocate();
1071 finalizeCallbacks.clear();
1074 creationContext = 0;
1077 // Must be called with a handle scope and context
1078 void QDeclarativeScriptData::initialize(QDeclarativeEngine *engine)
1080 Q_ASSERT(m_program.IsEmpty());
1082 Q_ASSERT(!hasEngine());
1084 QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
1085 QV8Engine *v8engine = ep->v8engine();
1087 // If compilation throws an error, a surrounding v8::TryCatch will record it.
1088 v8::Local<v8::Script> program = v8engine->qmlModeCompile(m_programSource.constData(),
1089 m_programSource.length(), urlString, 1);
1090 if (program.IsEmpty())
1093 m_program = qPersistentNew<v8::Script>(program);
1094 m_programSource.clear(); // We don't need this anymore
1096 addToEngine(engine);
1101 v8::Persistent<v8::Object> QDeclarativeVME::run(QDeclarativeContextData *parentCtxt, QDeclarativeScriptData *script)
1103 if (script->m_loaded)
1104 return qPersistentNew<v8::Object>(script->m_value);
1106 Q_ASSERT(parentCtxt && parentCtxt->engine);
1107 QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(parentCtxt->engine);
1108 QV8Engine *v8engine = ep->v8engine();
1110 bool shared = script->pragmas & QDeclarativeScript::Object::ScriptBlock::Shared;
1112 QDeclarativeContextData *effectiveCtxt = parentCtxt;
1116 // Create the script context if required
1117 QDeclarativeContextData *ctxt = new QDeclarativeContextData;
1118 ctxt->isInternal = true;
1119 ctxt->isJSContext = true;
1121 ctxt->isPragmaLibraryContext = true;
1123 ctxt->isPragmaLibraryContext = parentCtxt->isPragmaLibraryContext;
1124 ctxt->url = script->url;
1125 ctxt->urlString = script->urlString;
1127 // For backward compatibility, if there are no imports, we need to use the
1128 // imports from the parent context. See QTBUG-17518.
1129 if (!script->importCache->isEmpty()) {
1130 ctxt->imports = script->importCache;
1131 } else if (effectiveCtxt) {
1132 ctxt->imports = effectiveCtxt->imports;
1133 ctxt->importedScripts = effectiveCtxt->importedScripts;
1134 for (int ii = 0; ii < ctxt->importedScripts.count(); ++ii)
1135 ctxt->importedScripts[ii] = qPersistentNew<v8::Object>(ctxt->importedScripts[ii]);
1138 if (ctxt->imports) {
1139 ctxt->imports->addref();
1142 if (effectiveCtxt) {
1143 ctxt->setParent(effectiveCtxt, true);
1145 ctxt->engine = parentCtxt->engine; // Fix for QTBUG-21620
1148 for (int ii = 0; ii < script->scripts.count(); ++ii) {
1149 ctxt->importedScripts << run(ctxt, script->scripts.at(ii)->scriptData());
1152 v8::HandleScope handle_scope;
1153 v8::Context::Scope scope(v8engine->context());
1155 v8::TryCatch try_catch;
1156 if (!script->isInitialized())
1157 script->initialize(parentCtxt->engine);
1159 v8::Local<v8::Object> qmlglobal = v8engine->qmlScope(ctxt, 0);
1161 if (!script->m_program.IsEmpty()) {
1162 script->m_program->Run(qmlglobal);
1164 // Compilation failed.
1165 Q_ASSERT(try_catch.HasCaught());
1168 v8::Persistent<v8::Object> rv;
1170 if (try_catch.HasCaught()) {
1171 v8::Local<v8::Message> message = try_catch.Message();
1172 if (!message.IsEmpty()) {
1173 QDeclarativeError error;
1174 QDeclarativeExpressionPrivate::exceptionToError(message, error);
1179 rv = qPersistentNew<v8::Object>(qmlglobal);
1181 script->m_value = qPersistentNew<v8::Object>(qmlglobal);
1182 script->m_loaded = true;
1188 #ifdef QML_THREADED_VME_INTERPRETER
1189 void **QDeclarativeVME::instructionJumpTable()
1191 static void **jumpTable = 0;
1193 QDeclarativeVME dummy;
1194 QDeclarativeVME::Interrupt i;
1195 dummy.run(0, i, &jumpTable);
1201 QDeclarativeContextData *QDeclarativeVME::complete(const Interrupt &interrupt)
1204 (bindValues.isEmpty() &&
1205 parserStatus.isEmpty() &&
1206 componentAttached == 0 &&
1207 rootContext.isNull() &&
1208 finalizeCallbacks.isEmpty()));
1213 QDeclarativeTrace trace("VME Complete");
1214 #ifdef QML_ENABLE_TRACE
1215 trace.addDetail("URL", rootComponent->url);
1218 ActiveVMERestorer restore(this, QDeclarativeEnginePrivate::get(engine));
1219 QRecursionWatcher<QDeclarativeVME, &QDeclarativeVME::recursion> watcher(this);
1222 QDeclarativeTrace trace("VME Binding Enable");
1223 trace.event("begin binding eval");
1224 while (!bindValues.isEmpty()) {
1225 QDeclarativeAbstractBinding *b = bindValues.pop();
1229 b->setEnabled(true, QDeclarativePropertyPrivate::BypassInterceptor |
1230 QDeclarativePropertyPrivate::DontRemoveBinding);
1233 if (watcher.hasRecursed() || interrupt.shouldInterrupt())
1236 bindValues.deallocate();
1240 QDeclarativeTrace trace("VME Component Complete");
1241 while (!parserStatus.isEmpty()) {
1242 QDeclarativeParserStatus *status = parserStatus.pop();
1243 #ifdef QML_ENABLE_TRACE
1244 QDeclarativeData *data = parserStatusData.pop();
1247 if (status && status->d) {
1249 #ifdef QML_ENABLE_TRACE
1250 QDeclarativeTrace trace("Component complete");
1251 trace.addDetail("URL", data->outerContext->url);
1252 trace.addDetail("Line", data->lineNumber);
1254 status->componentComplete();
1257 if (watcher.hasRecursed() || interrupt.shouldInterrupt())
1260 parserStatus.deallocate();
1264 QDeclarativeTrace trace("VME Finalize Callbacks");
1265 for (int ii = 0; ii < finalizeCallbacks.count(); ++ii) {
1266 QDeclarativeEnginePrivate::FinalizeCallback callback = finalizeCallbacks.at(ii);
1267 QObject *obj = callback.first;
1269 void *args[] = { 0 };
1270 QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod, callback.second, args);
1272 if (watcher.hasRecursed())
1275 finalizeCallbacks.clear();
1279 QDeclarativeTrace trace("VME Component.onCompleted Callbacks");
1280 while (componentAttached) {
1281 QDeclarativeComponentAttached *a = componentAttached;
1283 QDeclarativeData *d = QDeclarativeData::get(a->parent());
1285 Q_ASSERT(d->context);
1286 a->add(&d->context->componentAttached);
1287 emit a->completed();
1289 if (watcher.hasRecursed() || interrupt.shouldInterrupt())
1294 QDeclarativeContextData *rv = rootContext;
1298 if (rv) rv->activeVMEData = data;
1303 void QDeclarativeVME::blank(QFiniteStack<QDeclarativeAbstractBinding *> &bs)
1305 for (int ii = 0; ii < bs.count(); ++ii) {
1306 QDeclarativeAbstractBinding *b = bs.at(ii);
1307 if (b) b->m_mePtr = 0;
1311 void QDeclarativeVME::blank(QFiniteStack<QDeclarativeParserStatus *> &pss)
1313 for (int ii = 0; ii < pss.count(); ++ii) {
1314 QDeclarativeParserStatus *ps = pss.at(ii);
1319 QDeclarativeVMEGuard::QDeclarativeVMEGuard()
1320 : m_objectCount(0), m_objects(0), m_contextCount(0), m_contexts(0)
1324 QDeclarativeVMEGuard::~QDeclarativeVMEGuard()
1329 void QDeclarativeVMEGuard::guard(QDeclarativeVME *vme)
1333 m_objectCount = vme->objects.count();
1334 m_objects = new QDeclarativeGuard<QObject>[m_objectCount];
1335 for (int ii = 0; ii < m_objectCount; ++ii)
1336 m_objects[ii] = vme->objects[ii];
1338 m_contextCount = (vme->rootContext.isNull()?0:1) + vme->states.count();
1339 m_contexts = new QDeclarativeGuardedContextData[m_contextCount];
1340 for (int ii = 0; ii < vme->states.count(); ++ii)
1341 m_contexts[ii] = vme->states.at(ii).context;
1342 if (!vme->rootContext.isNull())
1343 m_contexts[m_contextCount - 1] = vme->rootContext.contextData();
1346 void QDeclarativeVMEGuard::clear()
1348 delete [] m_objects;
1349 delete [] m_contexts;
1357 bool QDeclarativeVMEGuard::isOK() const
1359 for (int ii = 0; ii < m_objectCount; ++ii)
1360 if (m_objects[ii].isNull())
1363 for (int ii = 0; ii < m_contextCount; ++ii)
1364 if (m_contexts[ii].isNull())