diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-06-15 14:12:28 +0200 |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-06-15 14:12:28 +0200 |
commit | a5756c3216ff67bca2bd232efbaac431ec9633a6 (patch) | |
tree | 9350c3306a0f3b7a33352f1802fb0e050cd45174 | |
parent | 45a72e2dfeffb582da7f8b4ffd92924bcd6a9166 (diff) |
renamings
-rw-r--r-- | examples/debuggee/debuggee.pro | 2 | ||||
-rw-r--r-- | examples/debuggee/main.cpp | 38 | ||||
-rw-r--r-- | examples/debugger/main.cpp | 20 | ||||
-rw-r--r-- | src/debuggerconnector.pri | 4 | ||||
-rw-r--r-- | src/debuggerengine.pri | 4 | ||||
-rw-r--r-- | src/qscriptdebuggerengine.cpp (renamed from src/qscriptdebuggerconnector.cpp) | 60 | ||||
-rw-r--r-- | src/qscriptdebuggerengine.h (renamed from src/qscriptdebuggerconnector.h) | 16 |
7 files changed, 76 insertions, 68 deletions
diff --git a/examples/debuggee/debuggee.pro b/examples/debuggee/debuggee.pro index 00cb1df..53a6fbe 100644 --- a/examples/debuggee/debuggee.pro +++ b/examples/debuggee/debuggee.pro @@ -5,5 +5,5 @@ INCLUDEPATH += . QT += network script scripttools win32: CONFIG += console mac:CONFIG -= app_bundle -include(../../src/debuggerconnector.pri) +include(../../src/debuggerengine.pri) SOURCES += main.cpp diff --git a/examples/debuggee/main.cpp b/examples/debuggee/main.cpp index ee024ef..f7cde4a 100644 --- a/examples/debuggee/main.cpp +++ b/examples/debuggee/main.cpp @@ -20,36 +20,36 @@ ****************************************************************************/ #include <QtScript> -#include <qscriptdebuggerconnector.h> +#include <qscriptdebuggerengine.h> void qScriptDebugRegisterMetaTypes(); -class MyObject : public QObject +class Runner : public QObject { Q_OBJECT public: - MyObject(const QHostAddress &addr, quint16 port, bool connect, QObject *parent = 0); + Runner(const QHostAddress &addr, quint16 port, bool connect, QObject *parent = 0); private slots: void onConnected(); void onDisconnected(); private: - QScriptEngine *m_engine; - QScriptDebuggerConnector *m_connector; + QScriptEngine *m_scriptEngine; + QScriptDebuggerEngine *m_debuggerEngine; }; -MyObject::MyObject(const QHostAddress &addr, quint16 port, bool connect, QObject *parent) +Runner::Runner(const QHostAddress &addr, quint16 port, bool connect, QObject *parent) : QObject(parent) { - m_engine = new QScriptEngine(this); - m_connector = new QScriptDebuggerConnector(this); - QObject::connect(m_connector, SIGNAL(connected()), this, SLOT(onConnected()), Qt::QueuedConnection); - QObject::connect(m_connector, SIGNAL(disconnected()), this, SLOT(onDisconnected()), Qt::QueuedConnection); - m_connector->setEngine(m_engine); + m_scriptEngine = new QScriptEngine(this); + m_debuggerEngine = new QScriptDebuggerEngine(this); + QObject::connect(m_debuggerEngine, SIGNAL(connected()), this, SLOT(onConnected()), Qt::QueuedConnection); + QObject::connect(m_debuggerEngine, SIGNAL(disconnected()), this, SLOT(onDisconnected()), Qt::QueuedConnection); + m_debuggerEngine->setTarget(m_scriptEngine); if (connect) { qDebug("attempting to connect to debugger at %s:%d", qPrintable(addr.toString()), port); - m_connector->connectToDebugger(addr, port); + m_debuggerEngine->connectToDebugger(addr, port); } else { - if (m_connector->listen(addr, port)) + if (m_debuggerEngine->listen(addr, port)) qDebug("waiting for debugger to connect at %s:%d", qPrintable(addr.toString()), port); else { qWarning("Failed to listen!"); @@ -58,9 +58,9 @@ MyObject::MyObject(const QHostAddress &addr, quint16 port, bool connect, QObject } } -void MyObject::onConnected() +void Runner::onConnected() { - qDebug("connected!!"); + qDebug("connected to debugger"); QStringList fileNames; QString path = QDir::currentPath(); fileNames << (path + QDir::separator() + "foo.qs") @@ -71,13 +71,13 @@ void MyObject::onConnected() file.open(QIODevice::ReadOnly); QString program = file.readAll(); qDebug("calling evaluate"); - m_engine->evaluate(program, fn); + m_scriptEngine->evaluate(program, fn); qDebug("evaluate done"); } - m_connector->disconnectFromDebugger(); + m_debuggerEngine->disconnectFromDebugger(); } -void MyObject::onDisconnected() +void Runner::onDisconnected() { qDebug("disconnected"); QCoreApplication::quit(); @@ -116,7 +116,7 @@ int main(int argc, char **argv) } qScriptDebugRegisterMetaTypes(); - MyObject obj(addr, port, connect); + Runner runner(addr, port, connect); return app.exec(); } diff --git a/examples/debugger/main.cpp b/examples/debugger/main.cpp index 74f0e9e..90b361b 100644 --- a/examples/debugger/main.cpp +++ b/examples/debugger/main.cpp @@ -26,24 +26,27 @@ void qScriptDebugRegisterMetaTypes(); -class MyObject : public QObject +class Runner : public QObject { Q_OBJECT public: - MyObject(const QHostAddress &addr, quint16 port, bool listen, QObject *parent = 0); + Runner(const QHostAddress &addr, quint16 port, bool listen, QObject *parent = 0); private slots: void onAttached(); void onDetached(); + void onError(QScriptRemoteTargetDebugger::Error error); private: QScriptRemoteTargetDebugger *m_debugger; }; -MyObject::MyObject(const QHostAddress &addr, quint16 port, bool listen, QObject *parent) +Runner::Runner(const QHostAddress &addr, quint16 port, bool listen, QObject *parent) : QObject(parent) { m_debugger = new QScriptRemoteTargetDebugger(this); QObject::connect(m_debugger, SIGNAL(attached()), this, SLOT(onAttached())); QObject::connect(m_debugger, SIGNAL(detached()), this, SLOT(onDetached())); + QObject::connect(m_debugger, SIGNAL(error(QScriptRemoteTargetDebugger::Error)), + this, SLOT(onError(QScriptRemoteTargetDebugger::Error))); if (listen) { if (m_debugger->listen(addr, port)) qDebug("listening for debuggee connection at %s:%d", qPrintable(addr.toString()), port); @@ -57,11 +60,16 @@ MyObject::MyObject(const QHostAddress &addr, quint16 port, bool listen, QObject } } -void MyObject::onAttached() +void Runner::onAttached() { } -void MyObject::onDetached() +void Runner::onDetached() +{ + QApplication::quit(); +} + +void Runner::onError(QScriptRemoteTargetDebugger::Error /*error*/) { QApplication::quit(); } @@ -100,7 +108,7 @@ int main(int argc, char **argv) } qScriptDebugRegisterMetaTypes(); - MyObject object(addr, port, listen); + Runner runner(addr, port, listen); return app.exec(); } diff --git a/src/debuggerconnector.pri b/src/debuggerconnector.pri deleted file mode 100644 index 872be0f..0000000 --- a/src/debuggerconnector.pri +++ /dev/null @@ -1,4 +0,0 @@ -INCLUDEPATH += $$PWD -DEPENDPATH += $$PWD -SOURCES += $$PWD/qscriptdebuggerconnector.cpp $$PWD/qscriptdebuggermetatypes.cpp -HEADERS += $$PWD/qscriptdebuggerconnector.h diff --git a/src/debuggerengine.pri b/src/debuggerengine.pri new file mode 100644 index 0000000..f2c6139 --- /dev/null +++ b/src/debuggerengine.pri @@ -0,0 +1,4 @@ +INCLUDEPATH += $$PWD +DEPENDPATH += $$PWD +SOURCES += $$PWD/qscriptdebuggerengine.cpp $$PWD/qscriptdebuggermetatypes.cpp +HEADERS += $$PWD/qscriptdebuggerengine.h diff --git a/src/qscriptdebuggerconnector.cpp b/src/qscriptdebuggerengine.cpp index b677d27..b08e3ad 100644 --- a/src/qscriptdebuggerconnector.cpp +++ b/src/qscriptdebuggerengine.cpp @@ -19,7 +19,7 @@ ** ****************************************************************************/ -#include "qscriptdebuggerconnector.h" +#include "qscriptdebuggerengine.h" #include <QtCore/qeventloop.h> #include <QtNetwork/qtcpserver.h> #include <QtNetwork/qtcpsocket.h> @@ -32,7 +32,7 @@ #include <private/qscriptbreakpointdata_p.h> #include <private/qscriptdebuggerobjectsnapshotdelta_p.h> -// #define DEBUGGERCONNECTOR_DEBUG +// #define DEBUGGERENGINE_DEBUG class QScriptRemoteTargetDebuggerBackend : public QObject, public QScriptDebuggerBackend @@ -173,7 +173,7 @@ void QScriptRemoteTargetDebuggerBackend::onReadyRead() if (m_socket->bytesAvailable() == handshakeData.size()) { QByteArray ba = m_socket->read(handshakeData.size()); if (ba == handshakeData) { -#ifdef DEBUGGERCONNECTOR_DEBUG +#ifdef DEBUGGERENGINE_DEBUG qDebug() << "sending handshake reply (" << handshakeData.size() << "bytes )"; #endif m_socket->write(handshakeData); @@ -184,7 +184,7 @@ void QScriptRemoteTargetDebuggerBackend::onReadyRead() m_state = ConnectedState; emit connected(); } else { -// d->error = QScriptDebuggerConnector::HandshakeError; +// d->error = QScriptDebuggerEngine::HandshakeError; // d->errorString = QString::fromLatin1("Incorrect handshake data received"); m_state = UnconnectedState; emit error(HandshakeError); @@ -194,7 +194,7 @@ void QScriptRemoteTargetDebuggerBackend::onReadyRead() } break; case ConnectedState: { -#ifdef DEBUGGERCONNECTOR_DEBUG +#ifdef DEBUGGERENGINE_DEBUG qDebug() << "received data. bytesAvailable:" << m_socket->bytesAvailable(); #endif QDataStream in(m_socket); @@ -203,14 +203,14 @@ void QScriptRemoteTargetDebuggerBackend::onReadyRead() if (m_socket->bytesAvailable() < (int)sizeof(quint32)) return; in >> m_blockSize; -#ifdef DEBUGGERCONNECTOR_DEBUG +#ifdef DEBUGGERENGINE_DEBUG qDebug() << " blockSize:" << m_blockSize; #endif } if (m_socket->bytesAvailable() < m_blockSize) return; -#ifdef DEBUGGERCONNECTOR_DEBUG +#ifdef DEBUGGERENGINE_DEBUG qDebug() << "deserializing command"; #endif int wasAvailable = m_socket->bytesAvailable(); @@ -220,12 +220,12 @@ void QScriptRemoteTargetDebuggerBackend::onReadyRead() in >> command; Q_ASSERT(m_socket->bytesAvailable() == wasAvailable - m_blockSize); -#ifdef DEBUGGERCONNECTOR_DEBUG +#ifdef DEBUGGERENGINE_DEBUG qDebug("executing command (id=%d, type=%d)", id, command.type()); #endif QScriptDebuggerResponse response = commandExecutor()->execute(this, command); -#ifdef DEBUGGERCONNECTOR_DEBUG +#ifdef DEBUGGERENGINE_DEBUG qDebug() << "serializing response"; #endif QByteArray block; @@ -237,13 +237,13 @@ void QScriptRemoteTargetDebuggerBackend::onReadyRead() out << response; out.device()->seek(0); out << (quint32)(block.size() - sizeof(quint32)); -#ifdef DEBUGGERCONNECTOR_DEBUG +#ifdef DEBUGGERENGINE_DEBUG qDebug() << "writing response (" << block.size() << "bytes )" << block.toHex(); #endif m_socket->write(block); m_blockSize = 0; -#ifdef DEBUGGERCONNECTOR_DEBUG +#ifdef DEBUGGERENGINE_DEBUG qDebug() << "bytes available is now" << m_socket->bytesAvailable(); #endif if (m_socket->bytesAvailable() != 0) @@ -266,7 +266,7 @@ void QScriptRemoteTargetDebuggerBackend::event(const QScriptDebuggerEvent &event Q_ASSERT(!eventLoop->isRunning()); m_eventLoopStack.prepend(eventLoop); -#ifdef DEBUGGERCONNECTOR_DEBUG +#ifdef DEBUGGERENGINE_DEBUG qDebug() << "serializing event of type" << event.type(); #endif QByteArray block; @@ -278,17 +278,17 @@ void QScriptRemoteTargetDebuggerBackend::event(const QScriptDebuggerEvent &event out.device()->seek(0); out << (quint32)(block.size() - sizeof(quint32)); -#ifdef DEBUGGERCONNECTOR_DEBUG +#ifdef DEBUGGERENGINE_DEBUG qDebug() << "writing event (" << block.size() << " bytes )"; #endif m_socket->write(block); // run an event loop until the debugger triggers a resume -#ifdef DEBUGGERCONNECTOR_DEBUG +#ifdef DEBUGGERENGINE_DEBUG qDebug("entering event loop"); #endif eventLoop->exec(); -#ifdef DEBUGGERCONNECTOR_DEBUG +#ifdef DEBUGGERENGINE_DEBUG qDebug("returned from event loop"); #endif @@ -314,26 +314,26 @@ void QScriptRemoteTargetDebuggerBackend::resume() } /*! - Constructs a new QScriptDebuggerConnector object with the given \a + Constructs a new QScriptDebuggerEngine object with the given \a parent. */ -QScriptDebuggerConnector::QScriptDebuggerConnector(QObject *parent) +QScriptDebuggerEngine::QScriptDebuggerEngine(QObject *parent) : QObject(parent), m_backend(0) { } /*! - Destroys this QScriptDebuggerConnector. + Destroys this QScriptDebuggerEngine. */ -QScriptDebuggerConnector::~QScriptDebuggerConnector() +QScriptDebuggerEngine::~QScriptDebuggerEngine() { delete m_backend; } /*! - Sets the \a engine that this connector will manage a connection to. + Sets the \a target engine that this debugger engine will manage. */ -void QScriptDebuggerConnector::setEngine(QScriptEngine *engine) +void QScriptDebuggerEngine::setTarget(QScriptEngine *target) { if (m_backend) { m_backend->detach(); @@ -344,14 +344,14 @@ void QScriptDebuggerConnector::setEngine(QScriptEngine *engine) QObject::connect(m_backend, SIGNAL(disconnected()), this, SIGNAL(disconnected())); } - m_backend->attachTo(engine); + m_backend->attachTo(target); } /*! - Returns the \a engine that this connector manages a connection to, + Returns the script engine that this debugger engine manages a connection to, or 0 if no engine has been set. */ -QScriptEngine *QScriptDebuggerConnector::engine() const +QScriptEngine *QScriptDebuggerEngine::target() const { if (!m_backend) return 0; @@ -367,10 +367,10 @@ QScriptEngine *QScriptDebuggerConnector::engine() const \sa disconnectFromDebugger(), listen() */ -void QScriptDebuggerConnector::connectToDebugger(const QHostAddress &address, quint16 port) +void QScriptDebuggerEngine::connectToDebugger(const QHostAddress &address, quint16 port) { if (!m_backend) { - qWarning("QScriptDebuggerConnector::connectToDebugger(): no engine has been set (call setEngine() first)"); + qWarning("QScriptDebuggerEngine::connectToDebugger(): no engine has been set (call setEngine() first)"); return; } m_backend->connectToDebugger(address, port); @@ -384,7 +384,7 @@ void QScriptDebuggerConnector::connectToDebugger(const QHostAddress &address, qu \sa connectToDebugger() */ -void QScriptDebuggerConnector::disconnectFromDebugger() +void QScriptDebuggerEngine::disconnectFromDebugger() { if (m_backend) m_backend->disconnectFromDebugger(); @@ -401,13 +401,13 @@ void QScriptDebuggerConnector::disconnectFromDebugger() \sa connectToDebugger() */ -bool QScriptDebuggerConnector::listen(const QHostAddress &address, quint16 port) +bool QScriptDebuggerEngine::listen(const QHostAddress &address, quint16 port) { if (!m_backend) { - qWarning("QScriptDebuggerConnector::listen(): no engine has been set (call setEngine() first)"); + qWarning("QScriptDebuggerEngine::listen(): no script engine has been set (call setTarget() first)"); return false; } return m_backend->listen(address, port); } -#include "qscriptdebuggerconnector.moc" +#include "qscriptdebuggerengine.moc" diff --git a/src/qscriptdebuggerconnector.h b/src/qscriptdebuggerengine.h index c4b4549..e6655df 100644 --- a/src/qscriptdebuggerconnector.h +++ b/src/qscriptdebuggerengine.h @@ -19,8 +19,8 @@ ** ****************************************************************************/ -#ifndef QSCRIPTDEBUGGERCONNECTOR_H -#define QSCRIPTDEBUGGERCONNECTOR_H +#ifndef QSCRIPTDEBUGGERENGINE_H +#define QSCRIPTDEBUGGERENGINE_H #include <QtCore/qobject.h> @@ -30,15 +30,15 @@ class QScriptEngine; class QScriptRemoteTargetDebuggerBackend; -class QScriptDebuggerConnector : public QObject +class QScriptDebuggerEngine : public QObject { Q_OBJECT public: - QScriptDebuggerConnector(QObject *parent = 0); - ~QScriptDebuggerConnector(); + QScriptDebuggerEngine(QObject *parent = 0); + ~QScriptDebuggerEngine(); - void setEngine(QScriptEngine *engine); - QScriptEngine *engine() const; + void setTarget(QScriptEngine *engine); + QScriptEngine *target() const; void connectToDebugger(const QHostAddress &address, quint16 port); void disconnectFromDebugger(); @@ -53,7 +53,7 @@ signals: private: QScriptRemoteTargetDebuggerBackend *m_backend; - Q_DISABLE_COPY(QScriptDebuggerConnector) + Q_DISABLE_COPY(QScriptDebuggerEngine) }; #endif |