diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-06-08 10:56:00 +1000 |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-06-08 10:56:00 +1000 |
commit | 96cfe77fa311e60a2dfb7967d7ad6c06d40b99fb (patch) | |
tree | 2a079fc5dccb784de03f2665b0056db80fb02d1c /src | |
parent | 8b39dbda19bfc0449022aacaaa2eb2975e9226c8 (diff) |
Allow methods to be changed by debugger
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/qml/qdeclarativeenginedebug.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeexpression.cpp | 44 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeexpression_p.h | 5 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativevmemetaobject.cpp | 14 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativevmemetaobject_p.h | 3 |
5 files changed, 10 insertions, 58 deletions
diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp index 8f22314530..7844d30e86 100644 --- a/src/declarative/qml/qdeclarativeenginedebug.cpp +++ b/src/declarative/qml/qdeclarativeenginedebug.cpp @@ -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) diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp index 24b3d0bf1d..557bb04bd0 100644 --- a/src/declarative/qml/qdeclarativeexpression.cpp +++ b/src/declarative/qml/qdeclarativeexpression.cpp @@ -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 diff --git a/src/declarative/qml/qdeclarativeexpression_p.h b/src/declarative/qml/qdeclarativeexpression_p.h index c4c4f86359..c87b6b4111 100644 --- a/src/declarative/qml/qdeclarativeexpression_p.h +++ b/src/declarative/qml/qdeclarativeexpression_p.h @@ -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); diff --git a/src/declarative/qml/qdeclarativevmemetaobject.cpp b/src/declarative/qml/qdeclarativevmemetaobject.cpp index 8c5956ca20..97c7754c6f 100644 --- a/src/declarative/qml/qdeclarativevmemetaobject.cpp +++ b/src/declarative/qml/qdeclarativevmemetaobject.cpp @@ -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 diff --git a/src/declarative/qml/qdeclarativevmemetaobject_p.h b/src/declarative/qml/qdeclarativevmemetaobject_p.h index baa30a3f71..991c79a4ef 100644 --- a/src/declarative/qml/qdeclarativevmemetaobject_p.h +++ b/src/declarative/qml/qdeclarativevmemetaobject_p.h @@ -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); |