From 6030db73f771bc6edb8dcb4837464ffa5456df7b Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 8 Dec 2014 17:42:47 +0100 Subject: [PATCH] - Bug fix (failed compilation alert was loaded in a separate thread). - Coding Standards. - Add DebuggingStatusResult in AssemblyDebuggerCtrl --- mix/AssemblyDebuggerCtrl.cpp | 25 ++++++++++++++++--------- mix/AssemblyDebuggerCtrl.h | 11 +++++++++-- mix/AssemblyDebuggerModel.cpp | 4 ++-- mix/DebuggingStateWrapper.h | 4 ++-- mix/KeyEventManager.h | 6 +++--- mix/TransactionBuilder.cpp | 4 ++-- 6 files changed, 34 insertions(+), 20 deletions(-) diff --git a/mix/AssemblyDebuggerCtrl.cpp b/mix/AssemblyDebuggerCtrl.cpp index 4d293cd8d..e48aa9138 100644 --- a/mix/AssemblyDebuggerCtrl.cpp +++ b/mix/AssemblyDebuggerCtrl.cpp @@ -33,8 +33,9 @@ using namespace dev::mix; AssemblyDebuggerCtrl::AssemblyDebuggerCtrl(QTextDocument* _doc): Extension(ExtensionDisplayBehavior::ModalDialog) { qRegisterMetaType(); - connect(this, SIGNAL(dataAvailable(QList, AssemblyDebuggerData)), - this, SLOT(updateGUI(QList, AssemblyDebuggerData)), Qt::QueuedConnection); + qRegisterMetaType(); + connect(this, SIGNAL(dataAvailable(bool, DebuggingStatusResult, QList, AssemblyDebuggerData)), + this, SLOT(updateGUI(bool, DebuggingStatusResult, QList, AssemblyDebuggerData)), Qt::QueuedConnection); m_modelDebugger = std::unique_ptr(new AssemblyDebuggerModel); m_doc = _doc; } @@ -65,7 +66,7 @@ void AssemblyDebuggerCtrl::keyPressed(int _key) if (!m_modelDebugger->compile(m_doc->toPlainText())) { - AppContext::getInstance()->displayMessageDialog("debugger","compilation failed"); + emit dataAvailable(false, DebuggingStatusResult::Compilationfailed); return; } @@ -84,15 +85,21 @@ void AssemblyDebuggerCtrl::keyPressed(int _key) wStates.append(s); } AssemblyDebuggerData code = DebuggingStateWrapper::getHumanReadableCode(debuggingContent.executionCode, this); - emit dataAvailable(wStates, code); + emit dataAvailable(true, DebuggingStatusResult::Ok, wStates, code); }); } } -void AssemblyDebuggerCtrl::updateGUI(QList _wStates, AssemblyDebuggerData _code) +void AssemblyDebuggerCtrl::updateGUI(bool success, DebuggingStatusResult reason, QList _wStates, AssemblyDebuggerData _code) { - AppContext::getInstance()->appEngine()->rootContext()->setContextProperty("debugStates", QVariant::fromValue(_wStates)); - AppContext::getInstance()->appEngine()->rootContext()->setContextProperty("humanReadableExecutionCode", QVariant::fromValue(std::get<0>(_code))); - AppContext::getInstance()->appEngine()->rootContext()->setContextProperty("bytesCodeMapping", QVariant::fromValue(std::get<1>(_code))); - this->addContentOn(this); + Q_UNUSED(reason); + if (success) + { + AppContext::getInstance()->appEngine()->rootContext()->setContextProperty("debugStates", QVariant::fromValue(_wStates)); + AppContext::getInstance()->appEngine()->rootContext()->setContextProperty("humanReadableExecutionCode", QVariant::fromValue(std::get<0>(_code))); + AppContext::getInstance()->appEngine()->rootContext()->setContextProperty("bytesCodeMapping", QVariant::fromValue(std::get<1>(_code))); + this->addContentOn(this); + } + else + AppContext::getInstance()->displayMessageDialog("debugger","compilation failed"); } diff --git a/mix/AssemblyDebuggerCtrl.h b/mix/AssemblyDebuggerCtrl.h index 66256e472..0c092c46d 100644 --- a/mix/AssemblyDebuggerCtrl.h +++ b/mix/AssemblyDebuggerCtrl.h @@ -26,7 +26,14 @@ #include "AssemblyDebuggerModel.h" using AssemblyDebuggerData = std::tuple, dev::mix::QQMLMap*>; +enum DebuggingStatusResult +{ + Ok, + Compilationfailed +}; + Q_DECLARE_METATYPE(AssemblyDebuggerData) +Q_DECLARE_METATYPE(DebuggingStatusResult) namespace dev { @@ -51,10 +58,10 @@ private: public Q_SLOTS: void keyPressed(int); - void updateGUI(QList _wStates, AssemblyDebuggerData _code); + void updateGUI(bool success, DebuggingStatusResult reason, QList _wStates = QList(), AssemblyDebuggerData _code = AssemblyDebuggerData()); signals: - void dataAvailable(QList _wStates, AssemblyDebuggerData _code); + void dataAvailable(bool success, DebuggingStatusResult reason, QList _wStates = QList(), AssemblyDebuggerData _code = AssemblyDebuggerData()); }; diff --git a/mix/AssemblyDebuggerModel.cpp b/mix/AssemblyDebuggerModel.cpp index aa9795d53..bcf58835c 100644 --- a/mix/AssemblyDebuggerModel.cpp +++ b/mix/AssemblyDebuggerModel.cpp @@ -81,11 +81,11 @@ DebuggingContent AssemblyDebuggerModel::getContractInitiationDebugStates(dev::by DebuggingContent AssemblyDebuggerModel::getContractInitiationDebugStates(dev::u256 _value, dev::u256 _gasPrice, dev::u256 _gas, - QString code, + QString _code, KeyPair _key) { ConstantCompilationModel compiler; - CompilerResult res = compiler.compile(code); + CompilerResult res = compiler.compile(_code); if (!res.success) { DebuggingContent r; diff --git a/mix/DebuggingStateWrapper.h b/mix/DebuggingStateWrapper.h index df3b8ccce..89f90bfbd 100644 --- a/mix/DebuggingStateWrapper.h +++ b/mix/DebuggingStateWrapper.h @@ -111,7 +111,7 @@ class DebuggingStateWrapper: public QObject Q_PROPERTY(QStringList levels READ levels) public: - DebuggingStateWrapper(bytes _code, bytes _data, QObject* parent): QObject(parent), m_code(_code), m_data(_data) {} + DebuggingStateWrapper(bytes _code, bytes _data, QObject* _parent): QObject(_parent), m_code(_code), m_data(_data) {} int step() { return (int)m_state.steps; } int curPC() { return (int)m_state.curPC; } int gasCost() { return (int)m_state.gasCost; } @@ -125,7 +125,7 @@ public: QStringList levels(); DebuggingState state() { return m_state; } void setState(DebuggingState _state) { m_state = _state; } - static std::tuple, QQMLMap*> getHumanReadableCode(bytes const& code, QObject* _objUsedAsParent); + static std::tuple, QQMLMap*> getHumanReadableCode(bytes const& _code, QObject* _objUsedAsParent); private: DebuggingState m_state; diff --git a/mix/KeyEventManager.h b/mix/KeyEventManager.h index ecd768c4c..32ee5e867 100644 --- a/mix/KeyEventManager.h +++ b/mix/KeyEventManager.h @@ -30,13 +30,13 @@ class KeyEventManager: public QObject public: KeyEventManager() {} - void registerEvent(const QObject* receiver, const char* slot); - void unRegisterEvent(QObject* receiver); + void registerEvent(const QObject* _receiver, const char* _slot); + void unRegisterEvent(QObject* _receiver); signals: void onKeyPressed(int); public Q_SLOTS: - void keyPressed(QVariant event); + void keyPressed(QVariant _event); }; diff --git a/mix/TransactionBuilder.cpp b/mix/TransactionBuilder.cpp index bb7cda939..68eecf10b 100644 --- a/mix/TransactionBuilder.cpp +++ b/mix/TransactionBuilder.cpp @@ -33,8 +33,8 @@ Transaction TransactionBuilder::getCreationTransaction(u256 _value, u256 _gasPri } Transaction TransactionBuilder::getBasicTransaction(u256 _value, u256 _gasPrice, u256 _gas, - QString address, bytes _data, u256 _nonce, Secret _secret) const + QString _address, bytes _data, u256 _nonce, Secret _secret) const { - return Transaction(_value, _gasPrice, _gas, dev::fromString(address.toStdString()), _data, _nonce, _secret); + return Transaction(_value, _gasPrice, _gas, dev::fromString(_address.toStdString()), _data, _nonce, _secret); }