diff options
author | Jedrzej Nowacki <jedrzej.nowacki@nokia.com> | 2009-08-11 19:09:14 (GMT) |
---|---|---|
committer | Jedrzej Nowacki <jedrzej.nowacki@nokia.com> | 2009-08-11 19:25:20 (GMT) |
commit | 40c54d32e287b7f043dd0d94ad43c250082c7172 (patch) | |
tree | 2842628ceef1072b4bbf9234f502759e8af3ab16 /src/script/api/qscriptengineagent.cpp | |
parent | 2449e7fc567f8151736949032a001cf2aa2d5bb9 (diff) | |
download | Qt-40c54d32e287b7f043dd0d94ad43c250082c7172.zip Qt-40c54d32e287b7f043dd0d94ad43c250082c7172.tar.gz Qt-40c54d32e287b7f043dd0d94ad43c250082c7172.tar.bz2 |
Implement connection between JSC::Debugger and QScriptEngineAgent.
Complete reimplementation of QScriptEngineAgentPrivate.
New QScriptEngineAgentPrivate implementation makes conversion from
different JSC::Debuger types and events to corresponding
QScriptEngineAgent.
contextPush and contextPop events are created in QScriptEngine each time
contextPush or contextPop is ordered from public API
Diffstat (limited to 'src/script/api/qscriptengineagent.cpp')
-rw-r--r-- | src/script/api/qscriptengineagent.cpp | 57 |
1 files changed, 43 insertions, 14 deletions
diff --git a/src/script/api/qscriptengineagent.cpp b/src/script/api/qscriptengineagent.cpp index 3d96725..b958f2b 100644 --- a/src/script/api/qscriptengineagent.cpp +++ b/src/script/api/qscriptengineagent.cpp @@ -40,6 +40,10 @@ ****************************************************************************/ #include "qscriptengineagent.h" +#include "qscriptengineagent_p.h" + +#include "CodeBlock.h" +#include "Instruction.h" QT_BEGIN_NAMESPACE @@ -122,29 +126,51 @@ QT_BEGIN_NAMESPACE \sa extension() */ -class QScriptEngineAgent; -class Q_SCRIPT_EXPORT QScriptEngineAgentPrivate + +void QScriptEngineAgentPrivate::attach() { - Q_DECLARE_PUBLIC(QScriptEngineAgent) -public: - QScriptEngineAgentPrivate(); - virtual ~QScriptEngineAgentPrivate(); + QScriptEnginePrivate *d = QScriptEnginePrivate::get(engine); + if (d->originalGlobalObject()->debugger()) + d->originalGlobalObject()->setDebugger(0); + JSC::Debugger::attach(d->originalGlobalObject()); +} - QScriptEngine *engine; +void QScriptEngineAgentPrivate::detach() +{ + JSC::Debugger::detach(QScriptEnginePrivate::get(engine)->originalGlobalObject()); +} - QScriptEngineAgent *q_ptr; +void QScriptEngineAgentPrivate::exceptionThrow(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, bool hasHandler) +{ + QScriptValue value(QScriptEnginePrivate::get(engine)->scriptValueFromJSCValue(frame.exception())); + q_ptr->exceptionThrow(sourceID, value, hasHandler); }; -QScriptEngineAgentPrivate::QScriptEngineAgentPrivate() +void QScriptEngineAgentPrivate::exceptionCatch(const JSC::DebuggerCallFrame& frame, intptr_t sourceID) { + QScriptValue value(QScriptEnginePrivate::get(engine)->scriptValueFromJSCValue(frame.exception())); + q_ptr->exceptionCatch(sourceID, value); } -QScriptEngineAgentPrivate::~QScriptEngineAgentPrivate() +void QScriptEngineAgentPrivate::atStatement(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineno, int column) { -// ### QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(engine); -// ### eng_p->agentDeleted(q_ptr); + q_ptr->positionChange(sourceID, lineno, column); } +void QScriptEngineAgentPrivate::functionExit(const JSC::JSValue& returnValue, intptr_t sourceID) +{ + QScriptValue result = QScriptEnginePrivate::get(engine)->scriptValueFromJSCValue(returnValue); + q_ptr->functionExit(sourceID, result); + q_ptr->contextPop(); +} + +void QScriptEngineAgentPrivate::evaluateStop(const JSC::JSValue& returnValue, intptr_t sourceID) +{ + QScriptValue result = QScriptEnginePrivate::get(engine)->scriptValueFromJSCValue(returnValue); + q_ptr->functionExit(sourceID, result); +} + + /*! Constructs a QScriptEngineAgent object for the given \a engine. @@ -154,10 +180,13 @@ QScriptEngineAgentPrivate::~QScriptEngineAgentPrivate() agent. */ QScriptEngineAgent::QScriptEngineAgent(QScriptEngine *engine) - : d_ptr(new QScriptEngineAgentPrivate) + : d_ptr(new QScriptEngineAgentPrivate()) { - d_ptr->q_ptr = this; d_ptr->engine = engine; + d_ptr->q_ptr = this; + if (engine) { + d_ptr->engine->setAgent(this); + } } /*! |