Browse Source

- coding standards.

- set 'parent' on QObject custom class to ensure object deletion.
cl-refactor
yann300 10 years ago
parent
commit
dbc5201e98
  1. 6
      mix/ApplicationCtx.cpp
  2. 2
      mix/AssemblyDebuggerCtrl.cpp
  3. 1
      mix/AssemblyDebuggerModel.cpp
  4. 1
      mix/AssemblyDebuggerModel.h
  5. 12
      mix/CodeEditorExtensionManager.cpp
  6. 2
      mix/ConstantCompilationModel.h
  7. 6
      mix/DebuggingStateWrapper.cpp
  8. 6
      mix/DebuggingStateWrapper.h
  9. 2
      mix/qml/Debugger.qml

6
mix/ApplicationCtx.cpp

@ -38,10 +38,8 @@ ApplicationCtx* ApplicationCtx::Instance = nullptr;
ApplicationCtx::ApplicationCtx(QQmlApplicationEngine* _engine)
{
m_applicationEngine = _engine;
m_keyEventManager = std::unique_ptr<KeyEventManager>();
m_webThree = std::unique_ptr<dev::WebThreeDirect>();
m_webThree.reset(new WebThreeDirect(std::string("Mix/v") + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM), getDataDir() + "/Mix", false, {"eth", "shh"}));
m_keyEventManager.reset(new KeyEventManager());
m_keyEventManager = std::unique_ptr<KeyEventManager>(new KeyEventManager());
m_webThree = std::unique_ptr<dev::WebThreeDirect>(new WebThreeDirect(std::string("Mix/v") + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM), getDataDir() + "/Mix", false, {"eth", "shh"}));
}
ApplicationCtx::~ApplicationCtx()

2
mix/AssemblyDebuggerCtrl.cpp

@ -75,7 +75,7 @@ void AssemblyDebuggerCtrl::keyPressed(int _key)
s->setState(debuggingContent.states.at(i));
wStates.append(s);
}
std::tuple<QList<QObject*>, QQMLMap*> code = DebuggingStateWrapper::getHumanReadableCode(debuggingContent.executionCode);
std::tuple<QList<QObject*>, QQMLMap*> code = DebuggingStateWrapper::getHumanReadableCode(debuggingContent.executionCode, this);
ApplicationCtx::getInstance()->appEngine()->rootContext()->setContextProperty("debugStates", QVariant::fromValue(wStates));
ApplicationCtx::getInstance()->appEngine()->rootContext()->setContextProperty("humanReadableExecutionCode", QVariant::fromValue(std::get<0>(code)));
ApplicationCtx::getInstance()->appEngine()->rootContext()->setContextProperty("bytesCodeMapping", QVariant::fromValue(std::get<1>(code)));

1
mix/AssemblyDebuggerModel.cpp

@ -78,7 +78,6 @@ DebuggingContent AssemblyDebuggerModel::getContractInitiationDebugStates(dev::by
return d;
}
DebuggingContent AssemblyDebuggerModel::getContractInitiationDebugStates(dev::u256 _value,
dev::u256 _gasPrice,
dev::u256 _gas,

1
mix/AssemblyDebuggerModel.h

@ -25,6 +25,7 @@
#include "libethereum/Executive.h"
#include "libdevcore/Common.h"
#include "DebuggingStateWrapper.h"
namespace dev
{

12
mix/CodeEditorExtensionManager.cpp

@ -64,15 +64,15 @@ void CodeEditorExtensionManager::initExtensions()
initExtension(std::make_shared<AssemblyDebuggerCtrl>(m_doc));
}
void CodeEditorExtensionManager::initExtension(std::shared_ptr<Extension> ext)
void CodeEditorExtensionManager::initExtension(std::shared_ptr<Extension> _ext)
{
if (!ext.get()->contentUrl().isEmpty())
if (!_ext.get()->contentUrl().isEmpty())
{
try
{
if (ext.get()->getDisplayBehavior() == ExtensionDisplayBehavior::Tab)
if (_ext.get()->getDisplayBehavior() == ExtensionDisplayBehavior::Tab)
{
ext.get()->addTabOn(m_tabView);
_ext.get()->addTabOn(m_tabView);
}
}
catch (...)
@ -81,8 +81,8 @@ void CodeEditorExtensionManager::initExtension(std::shared_ptr<Extension> ext)
return;
}
}
ext.get()->start();
m_features.append(ext);
_ext.get()->start();
m_features.append(_ext);
}
void CodeEditorExtensionManager::setEditor(QQuickItem* _editor)

2
mix/ConstantCompilationModel.h

@ -45,7 +45,7 @@ class ConstantCompilationModel
public:
ConstantCompilationModel() {}
~ConstantCompilationModel() {}
CompilerResult compile(QString code);
CompilerResult compile(QString);
};
}

6
mix/DebuggingStateWrapper.cpp

@ -31,7 +31,7 @@ using namespace dev;
using namespace dev::eth;
using namespace dev::mix;
std::tuple<QList<QObject*>, QQMLMap*> DebuggingStateWrapper::getHumanReadableCode(const bytes& code)
std::tuple<QList<QObject*>, QQMLMap*> DebuggingStateWrapper::getHumanReadableCode(const bytes& code, QObject* _objUsedAsParent)
{
QList<QObject*> codeStr;
QMap<int, int> codeMapping;
@ -51,7 +51,7 @@ std::tuple<QList<QObject*>, QQMLMap*> DebuggingStateWrapper::getHumanReadableCod
s = "PUSH 0x" + QString::fromStdString(toHex(bytesConstRef(&code[i + 1], bc)));
i += bc;
}
HumanReadableCode* humanCode = new HumanReadableCode(QString::fromStdString(out.str()) + " " + s, line);
HumanReadableCode* humanCode = new HumanReadableCode(QString::fromStdString(out.str()) + " " + s, line, _objUsedAsParent);
codeStr.append(humanCode);
}
catch (...)
@ -61,7 +61,7 @@ std::tuple<QList<QObject*>, QQMLMap*> DebuggingStateWrapper::getHumanReadableCod
break; // probably hit data segment
}
}
return std::make_tuple(codeStr, new QQMLMap(codeMapping));
return std::make_tuple(codeStr, new QQMLMap(codeMapping, _objUsedAsParent));
}
QString DebuggingStateWrapper::debugStack()

6
mix/DebuggingStateWrapper.h

@ -65,7 +65,7 @@ class HumanReadableCode: public QObject
Q_PROPERTY(int processIndex READ processIndex)
public:
HumanReadableCode(QString _line, int _processIndex) : m_line(_line), m_processIndex(_processIndex) {}
HumanReadableCode(QString _line, int _processIndex, QObject* _parent) : m_line(_line), m_processIndex(_processIndex), QObject(_parent) {}
QString line() { return m_line; }
int processIndex() { return m_processIndex; }
@ -80,7 +80,7 @@ class QQMLMap : public QObject
Q_OBJECT
public:
QQMLMap(QMap<int, int> _map) : m_map(_map) { }
QQMLMap(QMap<int, int> _map, QObject* _parent) : m_map(_map), QObject(_parent) { }
Q_INVOKABLE int getValue(int _key) { return m_map.value(_key); }
private:
@ -118,7 +118,7 @@ public:
QStringList levels();
DebuggingState state() { return m_state; }
void setState(DebuggingState _state) { m_state = _state; }
static std::tuple<QList<QObject*>, QQMLMap*> getHumanReadableCode(bytes const& code);
static std::tuple<QList<QObject*>, QQMLMap*> getHumanReadableCode(bytes const& code, QObject* _objUsedAsParent);
private:
DebuggingState m_state;

2
mix/qml/Debugger.qml

@ -84,7 +84,7 @@ Rectangle {
anchors.top: statesList.bottom
height: parent.height * 0.35
width: parent.width
anchors.topMargin: 13
anchors.topMargin: 15
color: "transparent"
Label {
id: callStackLabel

Loading…
Cancel
Save