Adapt to Qt5 meta-object changes
[profile/ivi/qtdeclarative.git] / src / qml / debugger / qqmlenginedebugservice.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtQml module of the Qt Toolkit.
7 **
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.
16 **
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.
20 **
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.
28 **
29 ** Other Usage
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.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #include "qqmlenginedebugservice_p.h"
43
44 #include "qqmldebugstatesdelegate_p.h"
45 #include <private/qqmlboundsignal_p.h>
46 #include <qqmlengine.h>
47 #include <private/qqmlmetatype_p.h>
48 #include <qqmlproperty.h>
49 #include <private/qqmlproperty_p.h>
50 #include <private/qqmlbinding_p.h>
51 #include <private/qqmlcontext_p.h>
52 #include <private/qqmlwatcher_p.h>
53 #include <private/qqmlvaluetype_p.h>
54 #include <private/qqmlvmemetaobject_p.h>
55 #include <private/qqmlexpression_p.h>
56
57 #include <QtCore/qdebug.h>
58 #include <QtCore/qmetaobject.h>
59
60 QT_BEGIN_NAMESPACE
61
62 Q_GLOBAL_STATIC(QQmlEngineDebugService, qmlEngineDebugService)
63
64 QQmlEngineDebugService *QQmlEngineDebugService::instance()
65 {
66     return qmlEngineDebugService();
67 }
68
69 QQmlEngineDebugService::QQmlEngineDebugService(QObject *parent)
70     : QQmlDebugService(QLatin1String("QDeclarativeEngine"), 1, parent),
71       m_watch(new QQmlWatcher(this)),
72       m_statesDelegate(0)
73 {
74     QObject::connect(m_watch, SIGNAL(propertyChanged(int,int,QMetaProperty,QVariant)),
75                      this, SLOT(propertyChanged(int,int,QMetaProperty,QVariant)));
76
77     registerService();
78 }
79
80 QQmlEngineDebugService::~QQmlEngineDebugService()
81 {
82     delete m_statesDelegate;
83 }
84
85 QDataStream &operator<<(QDataStream &ds, 
86                         const QQmlEngineDebugService::QQmlObjectData &data)
87 {
88     ds << data.url << data.lineNumber << data.columnNumber << data.idString
89        << data.objectName << data.objectType << data.objectId << data.contextId;
90     return ds;
91 }
92
93 QDataStream &operator>>(QDataStream &ds, 
94                         QQmlEngineDebugService::QQmlObjectData &data)
95 {
96     ds >> data.url >> data.lineNumber >> data.columnNumber >> data.idString
97        >> data.objectName >> data.objectType >> data.objectId >> data.contextId;
98     return ds;
99 }
100
101 QDataStream &operator<<(QDataStream &ds, 
102                         const QQmlEngineDebugService::QQmlObjectProperty &data)
103 {
104     ds << (int)data.type << data.name << data.value << data.valueTypeName
105        << data.binding << data.hasNotifySignal;
106     return ds;
107 }
108
109 QDataStream &operator>>(QDataStream &ds,  
110                         QQmlEngineDebugService::QQmlObjectProperty &data)
111 {
112     int type;
113     ds >> type >> data.name >> data.value >> data.valueTypeName
114        >> data.binding >> data.hasNotifySignal;
115     data.type = (QQmlEngineDebugService::QQmlObjectProperty::Type)type;
116     return ds;
117 }
118
119 static inline bool isSignalPropertyName(const QString &signalName)
120 {
121     // see QmlCompiler::isSignalPropertyName
122     return signalName.length() >= 3 && signalName.startsWith(QLatin1String("on")) &&
123             signalName.at(2).isLetter() && signalName.at(2).isUpper();
124 }
125
126 static bool hasValidSignal(QObject *object, const QString &propertyName)
127 {
128     if (!isSignalPropertyName(propertyName))
129         return false;
130
131     QString signalName = propertyName.mid(2);
132     signalName[0] = signalName.at(0).toLower();
133
134     int sigIdx = QQmlPropertyPrivate::findSignalByName(object->metaObject(), signalName.toLatin1()).methodIndex();
135
136     if (sigIdx == -1)
137         return false;
138
139     return true;
140 }
141
142 QQmlEngineDebugService::QQmlObjectProperty
143 QQmlEngineDebugService::propertyData(QObject *obj, int propIdx)
144 {
145     QQmlObjectProperty rv;
146
147     QMetaProperty prop = obj->metaObject()->property(propIdx);
148
149     rv.type = QQmlObjectProperty::Unknown;
150     rv.valueTypeName = QString::fromUtf8(prop.typeName());
151     rv.name = QString::fromUtf8(prop.name());
152     rv.hasNotifySignal = prop.hasNotifySignal();
153     QQmlAbstractBinding *binding =
154             QQmlPropertyPrivate::binding(QQmlProperty(obj, rv.name));
155     if (binding)
156         rv.binding = binding->expression();
157
158     if (QQmlValueTypeFactory::isValueType(prop.userType())) {
159         rv.type = QQmlObjectProperty::Basic;
160     } else if (QQmlMetaType::isQObject(prop.userType()))  {
161         rv.type = QQmlObjectProperty::Object;
162     } else if (QQmlMetaType::isList(prop.userType())) {
163         rv.type = QQmlObjectProperty::List;
164     }
165
166     QVariant value;
167     if (rv.type != QQmlObjectProperty::Unknown && prop.userType() != 0) {
168         value = prop.read(obj);
169     }
170     rv.value = valueContents(value);
171
172     return rv;
173 }
174
175 QVariant QQmlEngineDebugService::valueContents(const QVariant &value) const
176 {
177     int userType = value.userType();
178
179     //QObject * is not streamable.
180     //Convert all such instances to a String value
181
182     if (value.type() == QVariant::List) {
183         QVariantList contents;
184         QVariantList list = value.toList();
185         int count = list.size();
186         for (int i = 0; i < count; i++)
187             contents << valueContents(list.at(i));
188         return contents;
189     }
190
191     if (value.type() == QVariant::Map) {
192         QVariantMap contents;
193         QMapIterator<QString, QVariant> i(value.toMap());
194          while (i.hasNext()) {
195              i.next();
196              contents.insert(i.key(), valueContents(i.value()));
197          }
198         return contents;
199     }
200
201     if (QQmlValueTypeFactory::isValueType(userType))
202         return value;
203
204     if (QQmlMetaType::isQObject(userType)) {
205         QObject *o = QQmlMetaType::toQObject(value);
206         if (o) {
207             QString name = o->objectName();
208             if (name.isEmpty())
209                 name = QLatin1String("<unnamed object>");
210             return name;
211         }
212     }
213
214     return QLatin1String("<unknown value>");
215 }
216
217 void QQmlEngineDebugService::buildObjectDump(QDataStream &message, 
218                                                      QObject *object, bool recur, bool dumpProperties)
219 {
220     message << objectData(object);
221
222     QObjectList children = object->children();
223     
224     int childrenCount = children.count();
225     for (int ii = 0; ii < children.count(); ++ii) {
226         if (qobject_cast<QQmlContext*>(children[ii]) || QQmlBoundSignal::cast(children[ii]))
227             --childrenCount;
228     }
229
230     message << childrenCount << recur;
231
232     QList<QQmlObjectProperty> fakeProperties;
233
234     for (int ii = 0; ii < children.count(); ++ii) {
235         QObject *child = children.at(ii);
236         if (qobject_cast<QQmlContext*>(child))
237             continue;
238         QQmlBoundSignal *signal = QQmlBoundSignal::cast(child);
239         if (signal) {
240             if (!dumpProperties)
241                 continue;
242             QQmlObjectProperty prop;
243             prop.type = QQmlObjectProperty::SignalProperty;
244             prop.hasNotifySignal = false;
245             QQmlExpression *expr = signal->expression();
246             if (expr) {
247                 prop.value = expr->expression();
248                 QObject *scope = expr->scopeObject();
249                 if (scope) {
250                     QString methodName = QLatin1String(scope->metaObject()->method(signal->index()).name().constData());
251                     if (!methodName.isEmpty()) {
252                         prop.name = QLatin1String("on") + methodName[0].toUpper()
253                                 + methodName.mid(1);
254                     }
255                 }
256             }
257             fakeProperties << prop;
258         } else {
259             if (recur)
260                 buildObjectDump(message, child, recur, dumpProperties);
261             else
262                 message << objectData(child);
263         }
264     }
265
266     if (!dumpProperties) {
267         message << 0;
268         return;
269     }
270
271     QList<int> propertyIndexes;
272     for (int ii = 0; ii < object->metaObject()->propertyCount(); ++ii) {
273         if (object->metaObject()->property(ii).isScriptable())
274             propertyIndexes << ii;
275     }
276
277     message << propertyIndexes.size() + fakeProperties.count();
278
279     for (int ii = 0; ii < propertyIndexes.size(); ++ii)
280         message << propertyData(object, propertyIndexes.at(ii));
281
282     for (int ii = 0; ii < fakeProperties.count(); ++ii)
283         message << fakeProperties[ii];
284 }
285
286 void QQmlEngineDebugService::prepareDeferredObjects(QObject *obj)
287 {
288     qmlExecuteDeferred(obj);
289
290     QObjectList children = obj->children();
291     for (int ii = 0; ii < children.count(); ++ii) {
292         QObject *child = children.at(ii);
293         prepareDeferredObjects(child);
294     }
295
296 }
297
298 void QQmlEngineDebugService::buildObjectList(QDataStream &message, QQmlContext *ctxt)
299 {
300     QQmlContextData *p = QQmlContextData::get(ctxt);
301
302     QString ctxtName = ctxt->objectName();
303     int ctxtId = QQmlDebugService::idForObject(ctxt);
304
305     message << ctxtName << ctxtId;
306
307     int count = 0;
308
309     QQmlContextData *child = p->childContexts;
310     while (child) {
311         ++count;
312         child = child->nextChild;
313     }
314
315     message << count;
316
317     child = p->childContexts;
318     while (child) {
319         buildObjectList(message, child->asQQmlContext());
320         child = child->nextChild;
321     }
322
323     // Clean deleted objects
324     QQmlContextPrivate *ctxtPriv = QQmlContextPrivate::get(ctxt);
325     for (int ii = 0; ii < ctxtPriv->instances.count(); ++ii) {
326         if (!ctxtPriv->instances.at(ii)) {
327             ctxtPriv->instances.removeAt(ii);
328             --ii;
329         }
330     }
331
332     message << ctxtPriv->instances.count();
333     for (int ii = 0; ii < ctxtPriv->instances.count(); ++ii) {
334         message << objectData(ctxtPriv->instances.at(ii));
335     }
336 }
337
338 void QQmlEngineDebugService::buildStatesList(QQmlContext *ctxt, bool cleanList)
339 {
340     if (m_statesDelegate)
341         m_statesDelegate->buildStatesList(ctxt, cleanList);
342 }
343
344 QQmlEngineDebugService::QQmlObjectData
345 QQmlEngineDebugService::objectData(QObject *object)
346 {
347     QQmlData *ddata = QQmlData::get(object);
348     QQmlObjectData rv;
349     if (ddata && ddata->outerContext) {
350         rv.url = ddata->outerContext->url;
351         rv.lineNumber = ddata->lineNumber;
352         rv.columnNumber = ddata->columnNumber;
353     } else {
354         rv.lineNumber = -1;
355         rv.columnNumber = -1;
356     }
357
358     QQmlContext *context = qmlContext(object);
359     if (context) {
360         QQmlContextData *cdata = QQmlContextData::get(context);
361         if (cdata)
362             rv.idString = cdata->findObjectId(object);
363     }
364
365     rv.objectName = object->objectName();
366     rv.objectId = QQmlDebugService::idForObject(object);
367     rv.contextId = QQmlDebugService::idForObject(qmlContext(object));
368
369     QQmlType *type = QQmlMetaType::qmlType(object->metaObject());
370     if (type) {
371         QString typeName = type->qmlTypeName();
372         int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
373         rv.objectType = lastSlash < 0 ? typeName : typeName.mid(lastSlash+1);
374     } else {
375         rv.objectType = QString::fromUtf8(object->metaObject()->className());
376         int marker = rv.objectType.indexOf(QLatin1String("_QMLTYPE_"));
377         if (marker != -1)
378             rv.objectType = rv.objectType.left(marker);
379     }
380
381     return rv;
382 }
383
384 void QQmlEngineDebugService::messageReceived(const QByteArray &message)
385 {
386     QMetaObject::invokeMethod(this, "processMessage", Qt::QueuedConnection, Q_ARG(QByteArray, message));
387 }
388
389 void QQmlEngineDebugService::processMessage(const QByteArray &message)
390 {
391     QDataStream ds(message);
392
393     QByteArray type;
394     ds >> type;
395
396     if (type == "LIST_ENGINES") {
397         int queryId;
398         ds >> queryId;
399
400         QByteArray reply;
401         QDataStream rs(&reply, QIODevice::WriteOnly);
402         rs << QByteArray("LIST_ENGINES_R");
403         rs << queryId << m_engines.count();
404
405         for (int ii = 0; ii < m_engines.count(); ++ii) {
406             QQmlEngine *engine = m_engines.at(ii);
407
408             QString engineName = engine->objectName();
409             int engineId = QQmlDebugService::idForObject(engine);
410
411             rs << engineName << engineId;
412         }
413
414         sendMessage(reply);
415     } else if (type == "LIST_OBJECTS") {
416         int queryId;
417         int engineId = -1;
418         ds >> queryId >> engineId;
419
420         QQmlEngine *engine =
421                 qobject_cast<QQmlEngine *>(QQmlDebugService::objectForId(engineId));
422
423         QByteArray reply;
424         QDataStream rs(&reply, QIODevice::WriteOnly);
425         rs << QByteArray("LIST_OBJECTS_R") << queryId;
426
427         if (engine) {
428             buildObjectList(rs, engine->rootContext());
429             buildStatesList(engine->rootContext(), true);
430         }
431
432         sendMessage(reply);
433     } else if (type == "FETCH_OBJECT") {
434         int queryId;
435         int objectId;
436         bool recurse;
437         bool dumpProperties = true;
438
439         ds >> queryId >> objectId >> recurse >> dumpProperties;
440
441         QObject *object = QQmlDebugService::objectForId(objectId);
442
443         QByteArray reply;
444         QDataStream rs(&reply, QIODevice::WriteOnly);
445         rs << QByteArray("FETCH_OBJECT_R") << queryId;
446
447         if (object) {
448             if (recurse)
449                 prepareDeferredObjects(object);
450             buildObjectDump(rs, object, recurse, dumpProperties);
451         }
452
453         sendMessage(reply);
454     } else if (type == "WATCH_OBJECT") {
455         int queryId;
456         int objectId;
457
458         ds >> queryId >> objectId;
459         bool ok = m_watch->addWatch(queryId, objectId);
460
461         QByteArray reply;
462         QDataStream rs(&reply, QIODevice::WriteOnly);
463         rs << QByteArray("WATCH_OBJECT_R") << queryId << ok;
464
465         sendMessage(reply);
466     } else if (type == "WATCH_PROPERTY") {
467         int queryId;
468         int objectId;
469         QByteArray property;
470
471         ds >> queryId >> objectId >> property;
472         bool ok = m_watch->addWatch(queryId, objectId, property);
473
474         QByteArray reply;
475         QDataStream rs(&reply, QIODevice::WriteOnly);
476         rs << QByteArray("WATCH_PROPERTY_R") << queryId << ok;
477
478         sendMessage(reply);
479     } else if (type == "WATCH_EXPR_OBJECT") {
480         int queryId;
481         int debugId;
482         QString expr;
483
484         ds >> queryId >> debugId >> expr;
485         bool ok = m_watch->addWatch(queryId, debugId, expr);
486
487         QByteArray reply;
488         QDataStream rs(&reply, QIODevice::WriteOnly);
489         rs << QByteArray("WATCH_EXPR_OBJECT_R") << queryId << ok;
490         sendMessage(reply);
491     } else if (type == "NO_WATCH") {
492         int queryId;
493
494         ds >> queryId;
495         m_watch->removeWatch(queryId);
496     } else if (type == "EVAL_EXPRESSION") {
497         int queryId;
498         int objectId;
499         QString expr;
500
501         ds >> queryId >> objectId >> expr;
502
503         QObject *object = QQmlDebugService::objectForId(objectId);
504         QQmlContext *context = qmlContext(object);
505         QVariant result;
506         if (object && context) {
507             QQmlExpression exprObj(context, object, expr);
508             bool undefined = false;
509             QVariant value = exprObj.evaluate(&undefined);
510             if (undefined)
511                 result = QLatin1String("<undefined>");
512             else
513                 result = valueContents(value);
514         } else {
515             result = QLatin1String("<unknown context>");
516         }
517
518         QByteArray reply;
519         QDataStream rs(&reply, QIODevice::WriteOnly);
520         rs << QByteArray("EVAL_EXPRESSION_R") << queryId << result;
521
522         sendMessage(reply);
523     } else if (type == "SET_BINDING") {
524         int objectId;
525         QString propertyName;
526         QVariant expr;
527         bool isLiteralValue;
528         QString filename;
529         int line;
530         ds >> objectId >> propertyName >> expr >> isLiteralValue;
531         if (!ds.atEnd()) { // backward compatibility from 2.1, 2.2
532             ds >> filename >> line;
533         }
534         setBinding(objectId, propertyName, expr, isLiteralValue, filename, line);
535     } else if (type == "RESET_BINDING") {
536         int objectId;
537         QString propertyName;
538         ds >> objectId >> propertyName;
539         resetBinding(objectId, propertyName);
540     } else if (type == "SET_METHOD_BODY") {
541         int objectId;
542         QString methodName;
543         QString methodBody;
544         ds >> objectId >> methodName >> methodBody;
545         setMethodBody(objectId, methodName, methodBody);
546     }
547 }
548
549 void QQmlEngineDebugService::setBinding(int objectId,
550                                                 const QString &propertyName,
551                                                 const QVariant &expression,
552                                                 bool isLiteralValue,
553                                                 QString filename,
554                                                 int line,
555                                                 int column)
556 {
557     QObject *object = objectForId(objectId);
558     QQmlContext *context = qmlContext(object);
559
560     if (object && context) {
561         QQmlProperty property(object, propertyName, context);
562         if (property.isValid()) {
563
564             bool inBaseState = true;
565             if (m_statesDelegate) {
566                 m_statesDelegate->updateBinding(context, property, expression, isLiteralValue,
567                                                 filename, line, column, &inBaseState);
568             }
569
570             if (inBaseState) {
571                 if (isLiteralValue) {
572                     property.write(expression);
573                 } else if (hasValidSignal(object, propertyName)) {
574                     QQmlExpression *qmlExpression = new QQmlExpression(context, object, expression.toString());
575                     QQmlPropertyPrivate::setSignalExpression(property, qmlExpression);
576                     qmlExpression->setSourceLocation(filename, line, column);
577                 } else if (property.isProperty()) {
578                     QQmlBinding *binding = new QQmlBinding(expression.toString(), object, context);
579                     binding->setTarget(property);
580                     binding->setSourceLocation(filename, line, column);
581                     binding->setNotifyOnValueChanged(true);
582                     QQmlAbstractBinding *oldBinding = QQmlPropertyPrivate::setBinding(property, binding);
583                     if (oldBinding)
584                         oldBinding->destroy();
585                     binding->update();
586                 } else {
587                     qWarning() << "QQmlEngineDebugService::setBinding: unable to set property" << propertyName << "on object" << object;
588                 }
589             }
590
591         } else {
592             // not a valid property
593             bool ok = false;
594             if (m_statesDelegate)
595                 ok = m_statesDelegate->setBindingForInvalidProperty(object, propertyName, expression, isLiteralValue);
596             if (!ok)
597                 qWarning() << "QQmlEngineDebugService::setBinding: unable to set property" << propertyName << "on object" << object;
598         }
599     }
600 }
601
602 void QQmlEngineDebugService::resetBinding(int objectId, const QString &propertyName)
603 {
604     QObject *object = objectForId(objectId);
605     QQmlContext *context = qmlContext(object);
606
607     if (object && context) {
608         if (object->property(propertyName.toLatin1()).isValid()) {
609             QQmlProperty property(object, propertyName);
610             QQmlAbstractBinding *oldBinding = QQmlPropertyPrivate::binding(property);
611             if (oldBinding) {
612                 QQmlAbstractBinding *oldBinding = QQmlPropertyPrivate::setBinding(property, 0);
613                 if (oldBinding)
614                     oldBinding->destroy();
615             }
616             if (property.isResettable()) {
617                 // Note: this will reset the property in any case, without regard to states
618                 // Right now almost no QQuickItem has reset methods for its properties (with the
619                 // notable exception of QQuickAnchors), so this is not a big issue
620                 // later on, setBinding does take states into account
621                 property.reset();
622             } else {
623                 // overwrite with default value
624                 if (QQmlType *objType = QQmlMetaType::qmlType(object->metaObject())) {
625                     if (QObject *emptyObject = objType->create()) {
626                         if (emptyObject->property(propertyName.toLatin1()).isValid()) {
627                             QVariant defaultValue = QQmlProperty(emptyObject, propertyName).read();
628                             if (defaultValue.isValid()) {
629                                 setBinding(objectId, propertyName, defaultValue, true);
630                             }
631                         }
632                         delete emptyObject;
633                     }
634                 }
635             }
636         } else if (hasValidSignal(object, propertyName)) {
637             QQmlProperty property(object, propertyName, context);
638             QQmlPropertyPrivate::setSignalExpression(property, 0);
639         } else {
640             if (m_statesDelegate)
641                 m_statesDelegate->resetBindingForInvalidProperty(object, propertyName);
642         }
643     }
644 }
645
646 void QQmlEngineDebugService::setMethodBody(int objectId, const QString &method, const QString &body)
647 {
648     QObject *object = objectForId(objectId);
649     QQmlContext *context = qmlContext(object);
650     if (!object || !context || !context->engine())
651         return;
652     QQmlContextData *contextData = QQmlContextData::get(context);
653     if (!contextData)
654         return;
655
656     QQmlPropertyData dummy;
657     QQmlPropertyData *prop =
658             QQmlPropertyCache::property(context->engine(), object, method, dummy);
659
660     if (!prop || !prop->isVMEFunction())
661         return;
662
663     QMetaMethod metaMethod = object->metaObject()->method(prop->coreIndex);
664     QList<QByteArray> paramNames = metaMethod.parameterNames();
665
666     QString paramStr;
667     for (int ii = 0; ii < paramNames.count(); ++ii) {
668         if (ii != 0) paramStr.append(QLatin1String(","));
669         paramStr.append(QString::fromUtf8(paramNames.at(ii)));
670     }
671
672     QString jsfunction = QLatin1String("(function ") + method + QLatin1String("(") + paramStr +
673             QLatin1String(") {");
674     jsfunction += body;
675     jsfunction += QLatin1String("\n})");
676
677     QQmlVMEMetaObject *vmeMetaObject =
678             static_cast<QQmlVMEMetaObject*>(QObjectPrivate::get(object)->metaObject);
679     Q_ASSERT(vmeMetaObject); // the fact we found the property above should guarentee this
680
681     int lineNumber = vmeMetaObject->vmeMethodLineNumber(prop->coreIndex);
682     vmeMetaObject->setVmeMethod(prop->coreIndex, QQmlExpressionPrivate::evalFunction(contextData, object, jsfunction, contextData->url.toString(), lineNumber));
683 }
684
685 void QQmlEngineDebugService::propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value)
686 {
687     QByteArray reply;
688     QDataStream rs(&reply, QIODevice::WriteOnly);
689
690     rs << QByteArray("UPDATE_WATCH") << id << objectId << QByteArray(property.name()) << valueContents(value);
691
692     sendMessage(reply);
693 }
694
695 void QQmlEngineDebugService::addEngine(QQmlEngine *engine)
696 {
697     Q_ASSERT(engine);
698     Q_ASSERT(!m_engines.contains(engine));
699
700     m_engines.append(engine);
701 }
702
703 void QQmlEngineDebugService::remEngine(QQmlEngine *engine)
704 {
705     Q_ASSERT(engine);
706     Q_ASSERT(m_engines.contains(engine));
707
708     m_engines.removeAll(engine);
709 }
710
711 void QQmlEngineDebugService::objectCreated(QQmlEngine *engine, QObject *object)
712 {
713     Q_ASSERT(engine);
714     Q_ASSERT(m_engines.contains(engine));
715
716     int engineId = QQmlDebugService::idForObject(engine);
717     int objectId = QQmlDebugService::idForObject(object);
718
719     QByteArray reply;
720     QDataStream rs(&reply, QIODevice::WriteOnly);
721
722     rs << QByteArray("OBJECT_CREATED") << engineId << objectId;
723     sendMessage(reply);
724 }
725
726 void QQmlEngineDebugService::setStatesDelegate(QQmlDebugStatesDelegate *delegate)
727 {
728     m_statesDelegate = delegate;
729 }
730
731 QT_END_NAMESPACE