QmlDebugging: Revert the names of services
[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 sig = QLatin1String(scope->metaObject()->method(signal->index()).signature());
251                     int lparen = sig.indexOf(QLatin1Char('('));
252                     if (lparen >= 0) {
253                         QString methodName = sig.mid(0, lparen);
254                         prop.name = QLatin1String("on") + methodName[0].toUpper()
255                                 + methodName.mid(1);
256                     }
257                 }
258             }
259             fakeProperties << prop;
260         } else {
261             if (recur)
262                 buildObjectDump(message, child, recur, dumpProperties);
263             else
264                 message << objectData(child);
265         }
266     }
267
268     if (!dumpProperties) {
269         message << 0;
270         return;
271     }
272
273     QList<int> propertyIndexes;
274     for (int ii = 0; ii < object->metaObject()->propertyCount(); ++ii) {
275         if (object->metaObject()->property(ii).isScriptable())
276             propertyIndexes << ii;
277     }
278
279     message << propertyIndexes.size() + fakeProperties.count();
280
281     for (int ii = 0; ii < propertyIndexes.size(); ++ii)
282         message << propertyData(object, propertyIndexes.at(ii));
283
284     for (int ii = 0; ii < fakeProperties.count(); ++ii)
285         message << fakeProperties[ii];
286 }
287
288 void QQmlEngineDebugService::prepareDeferredObjects(QObject *obj)
289 {
290     qmlExecuteDeferred(obj);
291
292     QObjectList children = obj->children();
293     for (int ii = 0; ii < children.count(); ++ii) {
294         QObject *child = children.at(ii);
295         prepareDeferredObjects(child);
296     }
297
298 }
299
300 void QQmlEngineDebugService::buildObjectList(QDataStream &message, QQmlContext *ctxt)
301 {
302     QQmlContextData *p = QQmlContextData::get(ctxt);
303
304     QString ctxtName = ctxt->objectName();
305     int ctxtId = QQmlDebugService::idForObject(ctxt);
306
307     message << ctxtName << ctxtId;
308
309     int count = 0;
310
311     QQmlContextData *child = p->childContexts;
312     while (child) {
313         ++count;
314         child = child->nextChild;
315     }
316
317     message << count;
318
319     child = p->childContexts;
320     while (child) {
321         buildObjectList(message, child->asQQmlContext());
322         child = child->nextChild;
323     }
324
325     // Clean deleted objects
326     QQmlContextPrivate *ctxtPriv = QQmlContextPrivate::get(ctxt);
327     for (int ii = 0; ii < ctxtPriv->instances.count(); ++ii) {
328         if (!ctxtPriv->instances.at(ii)) {
329             ctxtPriv->instances.removeAt(ii);
330             --ii;
331         }
332     }
333
334     message << ctxtPriv->instances.count();
335     for (int ii = 0; ii < ctxtPriv->instances.count(); ++ii) {
336         message << objectData(ctxtPriv->instances.at(ii));
337     }
338 }
339
340 void QQmlEngineDebugService::buildStatesList(QQmlContext *ctxt, bool cleanList)
341 {
342     if (m_statesDelegate)
343         m_statesDelegate->buildStatesList(ctxt, cleanList);
344 }
345
346 QQmlEngineDebugService::QQmlObjectData
347 QQmlEngineDebugService::objectData(QObject *object)
348 {
349     QQmlData *ddata = QQmlData::get(object);
350     QQmlObjectData rv;
351     if (ddata && ddata->outerContext) {
352         rv.url = ddata->outerContext->url;
353         rv.lineNumber = ddata->lineNumber;
354         rv.columnNumber = ddata->columnNumber;
355     } else {
356         rv.lineNumber = -1;
357         rv.columnNumber = -1;
358     }
359
360     QQmlContext *context = qmlContext(object);
361     if (context) {
362         QQmlContextData *cdata = QQmlContextData::get(context);
363         if (cdata)
364             rv.idString = cdata->findObjectId(object);
365     }
366
367     rv.objectName = object->objectName();
368     rv.objectId = QQmlDebugService::idForObject(object);
369     rv.contextId = QQmlDebugService::idForObject(qmlContext(object));
370
371     QQmlType *type = QQmlMetaType::qmlType(object->metaObject());
372     if (type) {
373         QString typeName = type->qmlTypeName();
374         int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
375         rv.objectType = lastSlash < 0 ? typeName : typeName.mid(lastSlash+1);
376     } else {
377         rv.objectType = QString::fromUtf8(object->metaObject()->className());
378         int marker = rv.objectType.indexOf(QLatin1String("_QMLTYPE_"));
379         if (marker != -1)
380             rv.objectType = rv.objectType.left(marker);
381     }
382
383     return rv;
384 }
385
386 void QQmlEngineDebugService::messageReceived(const QByteArray &message)
387 {
388     QMetaObject::invokeMethod(this, "processMessage", Qt::QueuedConnection, Q_ARG(QByteArray, message));
389 }
390
391 void QQmlEngineDebugService::processMessage(const QByteArray &message)
392 {
393     QDataStream ds(message);
394
395     QByteArray type;
396     ds >> type;
397
398     if (type == "LIST_ENGINES") {
399         int queryId;
400         ds >> queryId;
401
402         QByteArray reply;
403         QDataStream rs(&reply, QIODevice::WriteOnly);
404         rs << QByteArray("LIST_ENGINES_R");
405         rs << queryId << m_engines.count();
406
407         for (int ii = 0; ii < m_engines.count(); ++ii) {
408             QQmlEngine *engine = m_engines.at(ii);
409
410             QString engineName = engine->objectName();
411             int engineId = QQmlDebugService::idForObject(engine);
412
413             rs << engineName << engineId;
414         }
415
416         sendMessage(reply);
417     } else if (type == "LIST_OBJECTS") {
418         int queryId;
419         int engineId = -1;
420         ds >> queryId >> engineId;
421
422         QQmlEngine *engine =
423                 qobject_cast<QQmlEngine *>(QQmlDebugService::objectForId(engineId));
424
425         QByteArray reply;
426         QDataStream rs(&reply, QIODevice::WriteOnly);
427         rs << QByteArray("LIST_OBJECTS_R") << queryId;
428
429         if (engine) {
430             buildObjectList(rs, engine->rootContext());
431             buildStatesList(engine->rootContext(), true);
432         }
433
434         sendMessage(reply);
435     } else if (type == "FETCH_OBJECT") {
436         int queryId;
437         int objectId;
438         bool recurse;
439         bool dumpProperties = true;
440
441         ds >> queryId >> objectId >> recurse >> dumpProperties;
442
443         QObject *object = QQmlDebugService::objectForId(objectId);
444
445         QByteArray reply;
446         QDataStream rs(&reply, QIODevice::WriteOnly);
447         rs << QByteArray("FETCH_OBJECT_R") << queryId;
448
449         if (object) {
450             if (recurse)
451                 prepareDeferredObjects(object);
452             buildObjectDump(rs, object, recurse, dumpProperties);
453         }
454
455         sendMessage(reply);
456     } else if (type == "WATCH_OBJECT") {
457         int queryId;
458         int objectId;
459
460         ds >> queryId >> objectId;
461         bool ok = m_watch->addWatch(queryId, objectId);
462
463         QByteArray reply;
464         QDataStream rs(&reply, QIODevice::WriteOnly);
465         rs << QByteArray("WATCH_OBJECT_R") << queryId << ok;
466
467         sendMessage(reply);
468     } else if (type == "WATCH_PROPERTY") {
469         int queryId;
470         int objectId;
471         QByteArray property;
472
473         ds >> queryId >> objectId >> property;
474         bool ok = m_watch->addWatch(queryId, objectId, property);
475
476         QByteArray reply;
477         QDataStream rs(&reply, QIODevice::WriteOnly);
478         rs << QByteArray("WATCH_PROPERTY_R") << queryId << ok;
479
480         sendMessage(reply);
481     } else if (type == "WATCH_EXPR_OBJECT") {
482         int queryId;
483         int debugId;
484         QString expr;
485
486         ds >> queryId >> debugId >> expr;
487         bool ok = m_watch->addWatch(queryId, debugId, expr);
488
489         QByteArray reply;
490         QDataStream rs(&reply, QIODevice::WriteOnly);
491         rs << QByteArray("WATCH_EXPR_OBJECT_R") << queryId << ok;
492         sendMessage(reply);
493     } else if (type == "NO_WATCH") {
494         int queryId;
495
496         ds >> queryId;
497         m_watch->removeWatch(queryId);
498     } else if (type == "EVAL_EXPRESSION") {
499         int queryId;
500         int objectId;
501         QString expr;
502
503         ds >> queryId >> objectId >> expr;
504
505         QObject *object = QQmlDebugService::objectForId(objectId);
506         QQmlContext *context = qmlContext(object);
507         QVariant result;
508         if (object && context) {
509             QQmlExpression exprObj(context, object, expr);
510             bool undefined = false;
511             QVariant value = exprObj.evaluate(&undefined);
512             if (undefined)
513                 result = QLatin1String("<undefined>");
514             else
515                 result = valueContents(value);
516         } else {
517             result = QLatin1String("<unknown context>");
518         }
519
520         QByteArray reply;
521         QDataStream rs(&reply, QIODevice::WriteOnly);
522         rs << QByteArray("EVAL_EXPRESSION_R") << queryId << result;
523
524         sendMessage(reply);
525     } else if (type == "SET_BINDING") {
526         int objectId;
527         QString propertyName;
528         QVariant expr;
529         bool isLiteralValue;
530         QString filename;
531         int line;
532         ds >> objectId >> propertyName >> expr >> isLiteralValue;
533         if (!ds.atEnd()) { // backward compatibility from 2.1, 2.2
534             ds >> filename >> line;
535         }
536         setBinding(objectId, propertyName, expr, isLiteralValue, filename, line);
537     } else if (type == "RESET_BINDING") {
538         int objectId;
539         QString propertyName;
540         ds >> objectId >> propertyName;
541         resetBinding(objectId, propertyName);
542     } else if (type == "SET_METHOD_BODY") {
543         int objectId;
544         QString methodName;
545         QString methodBody;
546         ds >> objectId >> methodName >> methodBody;
547         setMethodBody(objectId, methodName, methodBody);
548     }
549 }
550
551 void QQmlEngineDebugService::setBinding(int objectId,
552                                                 const QString &propertyName,
553                                                 const QVariant &expression,
554                                                 bool isLiteralValue,
555                                                 QString filename,
556                                                 int line,
557                                                 int column)
558 {
559     QObject *object = objectForId(objectId);
560     QQmlContext *context = qmlContext(object);
561
562     if (object && context) {
563         QQmlProperty property(object, propertyName, context);
564         if (property.isValid()) {
565
566             bool inBaseState = true;
567             if (m_statesDelegate) {
568                 m_statesDelegate->updateBinding(context, property, expression, isLiteralValue,
569                                                 filename, line, column, &inBaseState);
570             }
571
572             if (inBaseState) {
573                 if (isLiteralValue) {
574                     property.write(expression);
575                 } else if (hasValidSignal(object, propertyName)) {
576                     QQmlExpression *qmlExpression = new QQmlExpression(context, object, expression.toString());
577                     QQmlPropertyPrivate::setSignalExpression(property, qmlExpression);
578                     qmlExpression->setSourceLocation(filename, line, column);
579                 } else if (property.isProperty()) {
580                     QQmlBinding *binding = new QQmlBinding(expression.toString(), object, context);
581                     binding->setTarget(property);
582                     binding->setSourceLocation(filename, line, column);
583                     binding->setNotifyOnValueChanged(true);
584                     QQmlAbstractBinding *oldBinding = QQmlPropertyPrivate::setBinding(property, binding);
585                     if (oldBinding)
586                         oldBinding->destroy();
587                     binding->update();
588                 } else {
589                     qWarning() << "QQmlEngineDebugService::setBinding: unable to set property" << propertyName << "on object" << object;
590                 }
591             }
592
593         } else {
594             // not a valid property
595             bool ok = false;
596             if (m_statesDelegate)
597                 ok = m_statesDelegate->setBindingForInvalidProperty(object, propertyName, expression, isLiteralValue);
598             if (!ok)
599                 qWarning() << "QQmlEngineDebugService::setBinding: unable to set property" << propertyName << "on object" << object;
600         }
601     }
602 }
603
604 void QQmlEngineDebugService::resetBinding(int objectId, const QString &propertyName)
605 {
606     QObject *object = objectForId(objectId);
607     QQmlContext *context = qmlContext(object);
608
609     if (object && context) {
610         if (object->property(propertyName.toLatin1()).isValid()) {
611             QQmlProperty property(object, propertyName);
612             QQmlAbstractBinding *oldBinding = QQmlPropertyPrivate::binding(property);
613             if (oldBinding) {
614                 QQmlAbstractBinding *oldBinding = QQmlPropertyPrivate::setBinding(property, 0);
615                 if (oldBinding)
616                     oldBinding->destroy();
617             }
618             if (property.isResettable()) {
619                 // Note: this will reset the property in any case, without regard to states
620                 // Right now almost no QQuickItem has reset methods for its properties (with the
621                 // notable exception of QQuickAnchors), so this is not a big issue
622                 // later on, setBinding does take states into account
623                 property.reset();
624             } else {
625                 // overwrite with default value
626                 if (QQmlType *objType = QQmlMetaType::qmlType(object->metaObject())) {
627                     if (QObject *emptyObject = objType->create()) {
628                         if (emptyObject->property(propertyName.toLatin1()).isValid()) {
629                             QVariant defaultValue = QQmlProperty(emptyObject, propertyName).read();
630                             if (defaultValue.isValid()) {
631                                 setBinding(objectId, propertyName, defaultValue, true);
632                             }
633                         }
634                         delete emptyObject;
635                     }
636                 }
637             }
638         } else if (hasValidSignal(object, propertyName)) {
639             QQmlProperty property(object, propertyName, context);
640             QQmlPropertyPrivate::setSignalExpression(property, 0);
641         } else {
642             if (m_statesDelegate)
643                 m_statesDelegate->resetBindingForInvalidProperty(object, propertyName);
644         }
645     }
646 }
647
648 void QQmlEngineDebugService::setMethodBody(int objectId, const QString &method, const QString &body)
649 {
650     QObject *object = objectForId(objectId);
651     QQmlContext *context = qmlContext(object);
652     if (!object || !context || !context->engine())
653         return;
654     QQmlContextData *contextData = QQmlContextData::get(context);
655     if (!contextData)
656         return;
657
658     QQmlPropertyData dummy;
659     QQmlPropertyData *prop =
660             QQmlPropertyCache::property(context->engine(), object, method, dummy);
661
662     if (!prop || !prop->isVMEFunction())
663         return;
664
665     QMetaMethod metaMethod = object->metaObject()->method(prop->coreIndex);
666     QList<QByteArray> paramNames = metaMethod.parameterNames();
667
668     QString paramStr;
669     for (int ii = 0; ii < paramNames.count(); ++ii) {
670         if (ii != 0) paramStr.append(QLatin1String(","));
671         paramStr.append(QString::fromUtf8(paramNames.at(ii)));
672     }
673
674     QString jsfunction = QLatin1String("(function ") + method + QLatin1String("(") + paramStr +
675             QLatin1String(") {");
676     jsfunction += body;
677     jsfunction += QLatin1String("\n})");
678
679     QQmlVMEMetaObject *vmeMetaObject =
680             static_cast<QQmlVMEMetaObject*>(QObjectPrivate::get(object)->metaObject);
681     Q_ASSERT(vmeMetaObject); // the fact we found the property above should guarentee this
682
683     int lineNumber = vmeMetaObject->vmeMethodLineNumber(prop->coreIndex);
684     vmeMetaObject->setVmeMethod(prop->coreIndex, QQmlExpressionPrivate::evalFunction(contextData, object, jsfunction, contextData->url.toString(), lineNumber));
685 }
686
687 void QQmlEngineDebugService::propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value)
688 {
689     QByteArray reply;
690     QDataStream rs(&reply, QIODevice::WriteOnly);
691
692     rs << QByteArray("UPDATE_WATCH") << id << objectId << QByteArray(property.name()) << valueContents(value);
693
694     sendMessage(reply);
695 }
696
697 void QQmlEngineDebugService::addEngine(QQmlEngine *engine)
698 {
699     Q_ASSERT(engine);
700     Q_ASSERT(!m_engines.contains(engine));
701
702     m_engines.append(engine);
703 }
704
705 void QQmlEngineDebugService::remEngine(QQmlEngine *engine)
706 {
707     Q_ASSERT(engine);
708     Q_ASSERT(m_engines.contains(engine));
709
710     m_engines.removeAll(engine);
711 }
712
713 void QQmlEngineDebugService::objectCreated(QQmlEngine *engine, QObject *object)
714 {
715     Q_ASSERT(engine);
716     Q_ASSERT(m_engines.contains(engine));
717
718     int engineId = QQmlDebugService::idForObject(engine);
719     int objectId = QQmlDebugService::idForObject(object);
720
721     QByteArray reply;
722     QDataStream rs(&reply, QIODevice::WriteOnly);
723
724     rs << QByteArray("OBJECT_CREATED") << engineId << objectId;
725     sendMessage(reply);
726 }
727
728 void QQmlEngineDebugService::setStatesDelegate(QQmlDebugStatesDelegate *delegate)
729 {
730     m_statesDelegate = delegate;
731 }
732
733 QT_END_NAMESPACE