Allow methods to be changed by debugger
authorAaron Kennedy <aaron.kennedy@nokia.com>
Wed, 8 Jun 2011 00:56:00 +0000 (10:56 +1000)
committerAaron Kennedy <aaron.kennedy@nokia.com>
Wed, 8 Jun 2011 00:56:00 +0000 (10:56 +1000)
src/declarative/qml/qdeclarativeenginedebug.cpp
src/declarative/qml/qdeclarativeexpression.cpp
src/declarative/qml/qdeclarativeexpression_p.h
src/declarative/qml/qdeclarativevmemetaobject.cpp
src/declarative/qml/qdeclarativevmemetaobject_p.h
tests/auto/declarative/declarative.pro

index 8f22314..7844d30 100644 (file)
@@ -700,7 +700,7 @@ void QDeclarativeEngineDebugServer::setMethodBody(int objectId, const QString &m
     Q_ASSERT(vmeMetaObject); // the fact we found the property above should guarentee this
 
     int lineNumber = vmeMetaObject->vmeMethodLineNumber(prop->coreIndex);
-    vmeMetaObject->setVmeMethod(prop->coreIndex, QDeclarativeExpressionPrivate::evalInObjectScope(contextData, object, jsfunction, contextData->url.toString(), lineNumber, 0));
+    vmeMetaObject->setVmeMethod(prop->coreIndex, QDeclarativeExpressionPrivate::evalFunction(contextData, object, jsfunction, contextData->url.toString(), lineNumber));
 }
 
 void QDeclarativeEngineDebugServer::propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value)
index 24b3d0b..557bb04 100644 (file)
@@ -173,50 +173,6 @@ QDeclarativeExpressionPrivate::evalFunction(QDeclarativeContextData *ctxt, QObje
     return v8::Persistent<v8::Function>::New(v8::Local<v8::Function>::Cast(result));
 }
 
-QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContextData *context, QObject *object, 
-                                                              const QString &program, const QString &fileName,
-                                                              int lineNumber, QScriptValue *contextObject)
-{
-#if 0
-    QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context->engine);
-    QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(&ep->scriptEngine);
-    if (contextObject) {
-        *contextObject = ep->contextClass->newContext(context, object);
-        scriptContext->pushScope(*contextObject);
-    } else {
-        scriptContext->pushScope(ep->contextClass->newContext(context, object));
-    }
-    scriptContext->pushScope(ep->globalClass->staticGlobalObject());
-    QScriptValue rv = ep->scriptEngine.evaluate(program, fileName, lineNumber);
-    ep->scriptEngine.popContext();
-    return rv;
-#else
-    qFatal("Not impl");
-#endif
-}
-
-QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContextData *context, QObject *object, 
-                                                              const QScriptProgram &program, 
-                                                              QScriptValue *contextObject)
-{
-#if 0
-    QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context->engine);
-    QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(&ep->scriptEngine);
-    if (contextObject) {
-        *contextObject = ep->contextClass->newContext(context, object);
-        scriptContext->pushScope(*contextObject);
-    } else {
-        scriptContext->pushScope(ep->contextClass->newContext(context, object));
-    }
-    scriptContext->pushScope(ep->globalClass->staticGlobalObject());
-    QScriptValue rv = ep->scriptEngine.evaluate(program);
-    ep->scriptEngine.popContext();
-    return rv;
-#else
-    qFatal("Not impl");
-#endif
-}
-
 /*!
     \class QDeclarativeExpression
     \since 4.7
index c4c4f86..c87b6b4 100644 (file)
@@ -202,11 +202,6 @@ public:
 
     static void exceptionToError(QScriptEngine *, QDeclarativeError &);
     static void exceptionToError(v8::Handle<v8::Message>, QDeclarativeError &);
-    static QScriptValue evalInObjectScope(QDeclarativeContextData *, QObject *, const QString &, const QString &,
-                                          int, QScriptValue *);
-    static QScriptValue evalInObjectScope(QDeclarativeContextData *, QObject *, const QScriptProgram &, 
-                                          QScriptValue *);
-
     static v8::Persistent<v8::Function> evalFunction(QDeclarativeContextData *ctxt, QObject *scope, 
                                                      const QString &code, const QString &filename, int line,
                                                      v8::Persistent<v8::Object> *qmlscope = 0);
index 8c5956c..97c7754 100644 (file)
@@ -831,7 +831,7 @@ v8::Handle<v8::Function> QDeclarativeVMEMetaObject::vmeMethod(int index)
 }
 
 // Used by debugger
-void QDeclarativeVMEMetaObject::setVmeMethod(int index, const QScriptValue &value)
+void QDeclarativeVMEMetaObject::setVmeMethod(int index, v8::Persistent<v8::Function> value)
 {
     if (index < methodOffset) {
         Q_ASSERT(parent);
@@ -840,11 +840,13 @@ void QDeclarativeVMEMetaObject::setVmeMethod(int index, const QScriptValue &valu
     int plainSignals = metaData->signalCount + metaData->propertyCount + metaData->aliasCount;
     Q_ASSERT(index >= (methodOffset + plainSignals) && index < (methodOffset + plainSignals + metaData->methodCount));
 
-#if 0
-    if (!methods) 
-        methods = new QScriptValue[metaData->methodCount];
-    methods[index - methodOffset - plainSignals] = value;
-#endif
+    if (!v8methods) 
+        v8methods = new v8::Persistent<v8::Function>[metaData->methodCount];
+
+    int methodIndex = index - methodOffset - plainSignals;
+    if (!v8methods[methodIndex].IsEmpty()) 
+        v8methods[methodIndex].Dispose();
+    v8methods[methodIndex] = value;
 }
 
 #if 0
index baa30a3..991c79a 100644 (file)
@@ -144,7 +144,7 @@ public:
     void registerInterceptor(int index, int valueIndex, QDeclarativePropertyValueInterceptor *interceptor);
     v8::Handle<v8::Function> vmeMethod(int index);
     int vmeMethodLineNumber(int index);
-    void setVmeMethod(int index, const QScriptValue &);
+    void setVmeMethod(int index, v8::Persistent<v8::Function>);
 #if 0
     QScriptValue vmeProperty(int index);
     void setVMEProperty(int index, const QScriptValue &);
@@ -171,7 +171,6 @@ private:
     QBitArray aInterceptors;
     QHash<int, QPair<int, QDeclarativePropertyValueInterceptor*> > interceptors;
 
-    QScriptValue *methods;
     v8::Persistent<v8::Function> *v8methods;
     v8::Handle<v8::Function> method(int);
 
index bc69466..8859b83 100644 (file)
@@ -7,6 +7,8 @@ SUBDIRS += \
 
 SUBDIRS += \
            examples \
+           geometry \
+           node \
            parserstress \
            qdeclarativecomponent \
            qdeclarativecontext \
@@ -37,6 +39,7 @@ contains(QT_CONFIG, private_tests) {
            qdeclarativeconnection \
            qdeclarativedebug \
            qdeclarativedebugclient \
+           qdeclarativedebughelper \
            qdeclarativedebugservice \
            qdeclarativeecmascript \
            qdeclarativeflickable \
@@ -59,6 +62,7 @@ contains(QT_CONFIG, private_tests) {
            qdeclarativeproperty \
            qdeclarativepropertymap \
            qdeclarativerepeater \
+           qdeclarativescriptdebugging \
            qdeclarativesmoothedanimation \
            qdeclarativespringanimation \
            qdeclarativestyledtext \