Browse Source

fixed code style

cl-refactor
arkpar 10 years ago
parent
commit
525ac762dd
  1. 4
      mix/AppContext.cpp
  2. 2
      mix/AppContext.h
  3. 18
      mix/AssemblyDebuggerControl.cpp
  4. 4
      mix/CodeHighlighter.cpp
  5. 22
      mix/CodeModel.cpp
  6. 10
      mix/CodeModel.h
  7. 3
      mix/MixApplication.h
  8. 2
      mix/main.cpp

4
mix/AppContext.cpp

@ -60,7 +60,7 @@ void AppContext::loadProject()
if (!path.isEmpty())
{
QFile file(path);
if(file.open(QIODevice::ReadOnly | QIODevice::Text))
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream stream(&file);
QString json = stream.readAll();
@ -95,7 +95,7 @@ void AppContext::saveProject(QString const& _json)
{
dirPath.mkpath(dirPath.path());
QFile file(path);
if(file.open(QIODevice::WriteOnly | QIODevice::Text))
if (file.open(QIODevice::WriteOnly | QIODevice::Text))
{
QTextStream stream(&file);
stream << _json;

2
mix/AppContext.h

@ -51,7 +51,7 @@ class CodeModel;
* @brief Provides access to application scope variable.
*/
class AppContext : public QObject
class AppContext: public QObject
{
Q_OBJECT

18
mix/AssemblyDebuggerControl.cpp

@ -92,7 +92,7 @@ void AssemblyDebuggerControl::debugState(QVariantMap _state)
std::vector<TransactionSettings> transactionSequence;
for (auto const& t : transactions)
for (auto const& t: transactions)
{
QVariantMap transaction = t.toMap();
@ -132,14 +132,14 @@ void AssemblyDebuggerControl::executeSequence(std::vector<TransactionSettings> c
QFunctionDefinition* f;
ContractCallDataEncoder c;
//encode data for all transactions
for (auto const& t : _sequence)
for (auto const& t: _sequence)
{
f = nullptr;
for (int k = 0; k < contractDef->functionsList().size(); k++)
for (int tf = 0; tf < contractDef->functionsList().size(); tf++)
{
if (contractDef->functionsList().at(k)->name() == t.functionId)
if (contractDef->functionsList().at(tf)->name() == t.functionId)
{
f = contractDef->functionsList().at(k);
f = contractDef->functionsList().at(tf);
break;
}
}
@ -147,9 +147,9 @@ void AssemblyDebuggerControl::executeSequence(std::vector<TransactionSettings> c
throw std::runtime_error("function " + t.functionId.toStdString() + " not found");
c.encode(f->index());
for (int k = 0; k < f->parametersList().size(); k++)
for (int p = 0; p < f->parametersList().size(); p++)
{
QVariableDeclaration* var = (QVariableDeclaration*)f->parametersList().at(k);
QVariableDeclaration* var = (QVariableDeclaration*)f->parametersList().at(p);
u256 value = 0;
auto v = t.parameterValues.find(var->name());
if (v != t.parameterValues.cend())
@ -171,7 +171,7 @@ void AssemblyDebuggerControl::executeSequence(std::vector<TransactionSettings> c
//we need to wrap states in a QObject before sending to QML.
QList<QObject*> wStates;
for(int i = 0; i < debuggingContent.machineStates.size(); i++)
for (int i = 0; i < debuggingContent.machineStates.size(); i++)
{
QPointer<DebuggingStateWrapper> s(new DebuggingStateWrapper(debuggingContent.executionCode, debuggingContent.executionData.toBytes()));
s->setState(debuggingContent.machineStates.at(i));
@ -182,7 +182,7 @@ void AssemblyDebuggerControl::executeSequence(std::vector<TransactionSettings> c
emit dataAvailable(debuggingContent.returnParameters, wStates, code);
emit runComplete();
}
catch(boost::exception const& e)
catch(boost::exception const&)
{
emit runFailed(QString::fromStdString(boost::current_exception_diagnostic_information()));
}

4
mix/CodeHighlighter.cpp

@ -36,7 +36,7 @@ using namespace dev::mix;
CodeHighlighterSettings::CodeHighlighterSettings()
{
backgroundColor = QColor(0x00, 0x2b, 0x36);
foregroundColor = QColor (0xee, 0xe8, 0xd5);
foregroundColor = QColor(0xee, 0xe8, 0xd5);
formats[Keyword].setForeground(QColor(0x93, 0xa1, 0xa1));
formats[Comment].setForeground(QColor(0x85, 0x99, 0x00));
formats[StringLiteral].setForeground(QColor(0xdc, 0x32, 0x2f));
@ -49,7 +49,7 @@ CodeHighlighterSettings::CodeHighlighterSettings()
namespace
{
using namespace dev::solidity;
class HighlightVisitor : public ASTConstVisitor
class HighlightVisitor: public ASTConstVisitor
{
public:
HighlightVisitor(CodeHighlighter::Formats* _formats) { m_formats = _formats; }

22
mix/CodeModel.cpp

@ -41,14 +41,17 @@ void BackgroundWorker::queueCodeChange(int _jobId, QString const& _content)
}
CompilationResult::CompilationResult():
QObject(nullptr), m_successfull(false),
QObject(nullptr),
m_successful(false),
m_codeHash(qHash(QString())),
m_contract(new QContractDefinition()),
m_codeHighlighter(new CodeHighlighter())
{}
CompilationResult::CompilationResult(const solidity::CompilerStack& _compiler):
QObject(nullptr), m_successfull(true), m_codeHash(qHash(QString()))
QObject(nullptr),
m_successful(true),
m_codeHash(qHash(QString()))
{
if (!_compiler.getContractNames().empty())
{
@ -61,7 +64,9 @@ CompilationResult::CompilationResult(const solidity::CompilerStack& _compiler):
}
CompilationResult::CompilationResult(CompilationResult const& _prev, QString const& _compilerMessage):
QObject(nullptr), m_successfull(false), m_codeHash(qHash(QString())),
QObject(nullptr),
m_successful(false),
m_codeHash(qHash(QString())),
m_contract(_prev.m_contract),
m_compilerMessage(_compilerMessage),
m_bytes(_prev.m_bytes),
@ -69,8 +74,13 @@ CompilationResult::CompilationResult(CompilationResult const& _prev, QString con
m_codeHighlighter(_prev.m_codeHighlighter)
{}
CodeModel::CodeModel(QObject* _parent) : QObject(_parent),
m_compiling(false), m_result(new CompilationResult()), m_codeHighlighterSettings(new CodeHighlighterSettings()), m_backgroundWorker(this), m_backgroundJobId(0)
CodeModel::CodeModel(QObject* _parent):
QObject(_parent),
m_compiling(false),
m_result(new CompilationResult()),
m_codeHighlighterSettings(new CodeHighlighterSettings()),
m_backgroundWorker(this),
m_backgroundJobId(0)
{
m_backgroundWorker.moveToThread(&m_backgroundThread);
connect(this, &CodeModel::scheduleCompilationJob, &m_backgroundWorker, &BackgroundWorker::queueCodeChange, Qt::QueuedConnection);
@ -97,7 +107,7 @@ void CodeModel::stop()
m_backgroundThread.wait();
}
void CodeModel::registerCodeChange(const QString &_code)
void CodeModel::registerCodeChange(QString const& _code)
{
// launch the background thread
uint hash = qHash(_code);

10
mix/CodeModel.h

@ -61,7 +61,7 @@ private:
};
///Compilation result model. Contains all the compiled contract data required by UI
class CompilationResult : public QObject
class CompilationResult: public QObject
{
Q_OBJECT
Q_PROPERTY(QContractDefinition* contract READ contract)
@ -79,7 +79,7 @@ public:
/// @returns contract definition
std::shared_ptr<QContractDefinition> sharedContract() { return m_contract; }
/// Indicates if the compilation was successfull
bool successfull() const { return m_successfull; }
bool successfull() const { return m_successful; }
/// @returns compiler error message in case of unsuccessfull compilation
QString compilerMessage() const { return m_compilerMessage; }
/// @returns contract bytecode
@ -90,7 +90,7 @@ public:
std::shared_ptr<CodeHighlighter> codeHighlighter() { return m_codeHighlighter; }
private:
bool m_successfull;
bool m_successful;
uint m_codeHash;
std::shared_ptr<QContractDefinition> m_contract;
QString m_compilerMessage; ///< @todo: use some structure here
@ -102,7 +102,7 @@ private:
};
/// Background code compiler
class CodeModel : public QObject
class CodeModel: public QObject
{
Q_OBJECT
@ -139,7 +139,7 @@ signals:
void compilationCompleteInternal(CompilationResult* _newResult);
private slots:
void onCompilationComplete(CompilationResult*_newResult);
void onCompilationComplete(CompilationResult* _newResult);
public slots:
/// Update code model on source code change

3
mix/MixApplication.h

@ -43,7 +43,8 @@ public:
MixApplication(int _argc, char* _argv[]);
virtual ~MixApplication();
AppContext* context() { return m_appContext.get(); }
QQmlApplicationEngine* engine( ) { return m_engine.get(); }
QQmlApplicationEngine* engine() { return m_engine.get(); }
private:
std::unique_ptr<QQmlApplicationEngine> m_engine;
std::unique_ptr<AppContext> m_appContext;

2
mix/main.cpp

@ -23,7 +23,7 @@
#include "MixApplication.h"
using namespace dev::mix;
int main(int _argc, char *_argv[])
int main(int _argc, char* _argv[])
{
MixApplication app(_argc, _argv);
return app.exec();

Loading…
Cancel
Save