From 1626213af0aa35eba1f32d8350f09e1609045a26 Mon Sep 17 00:00:00 2001 From: arkpar Date: Mon, 5 Jan 2015 12:06:15 +0100 Subject: [PATCH] coding standards --- mix/AssemblyDebuggerControl.h | 10 ++++++++-- mix/CodeHighlighter.cpp | 28 +++++++++------------------- mix/CodeHighlighter.h | 17 +++++++++++++---- mix/CodeModel.cpp | 16 +++++----------- mix/CodeModel.h | 4 ++-- mix/StateListView.cpp | 1 + 6 files changed, 38 insertions(+), 38 deletions(-) diff --git a/mix/AssemblyDebuggerControl.h b/mix/AssemblyDebuggerControl.h index 4341b46e0..b4dff38f5 100644 --- a/mix/AssemblyDebuggerControl.h +++ b/mix/AssemblyDebuggerControl.h @@ -19,6 +19,7 @@ #pragma once +#include #include #include "Extension.h" #include "AssemblyDebuggerModel.h" @@ -55,7 +56,7 @@ private: void executeSequence(std::vector const& _sequence, u256 _balance); std::unique_ptr m_modelDebugger; - bool m_running; + std::atomic m_running; public slots: /// Run the contract constructor and show debugger window. @@ -67,13 +68,18 @@ public slots: private slots: /// Update UI with machine states result. Display a modal dialog. void showDebugger(QList const& _returnParams = QList(), QList const& _wStates = QList(), AssemblyDebuggerData const& _code = AssemblyDebuggerData()); + /// Update UI with transaction run error. void showDebugError(QString const& _error); - signals: + /// Transaction execution started void runStarted(); + /// Transaction execution completed successfully void runComplete(); + /// Transaction execution completed with error + /// @param _message Error message void runFailed(QString const& _message); + /// Execution state changed void stateChanged(); /// Emited when machine states are available. diff --git a/mix/CodeHighlighter.cpp b/mix/CodeHighlighter.cpp index 5f6cf7489..7cc07c9a5 100644 --- a/mix/CodeHighlighter.cpp +++ b/mix/CodeHighlighter.cpp @@ -25,25 +25,22 @@ #include #include #include +#include +#include +#include +#include #include "CodeHighlighter.h" -#include "libsolidity/ASTVisitor.h" -#include "libsolidity/AST.h" -#include "libsolidity/Scanner.h" -#include "libsolidity/Exceptions.h" -namespace dev -{ -namespace mix -{ +using namespace dev::mix; CodeHighlighterSettings::CodeHighlighterSettings() { - bg = QColor(0x00, 0x2b, 0x36); - fg = QColor (0xee, 0xe8, 0xd5); + backgroundColor = QColor(0x00, 0x2b, 0x36); + 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)); - formats[NumLiteral].setForeground(fg); + formats[NumLiteral].setForeground(foregroundColor); formats[Import].setForeground(QColor(0x6c, 0x71, 0xc4)); formats[CompilationError].setUnderlineColor(Qt::red); formats[CompilationError].setUnderlineStyle(QTextCharFormat::SingleUnderline); @@ -52,7 +49,7 @@ CodeHighlighterSettings::CodeHighlighterSettings() namespace { using namespace dev::solidity; - class HighlightVisitor : public solidity::ASTConstVisitor + class HighlightVisitor : public ASTConstVisitor { public: HighlightVisitor(CodeHighlighter::Formats* _formats) { m_formats = _formats; } @@ -67,7 +64,6 @@ namespace }; } - CodeHighlighter::FormatRange::FormatRange(CodeHighlighterSettings::Token _t, solidity::Location const& _location): token(_t), start(_location.start), length(_location.end - _location.start) {} @@ -172,9 +168,3 @@ void CodeHighlighter::updateFormatting(QTextDocument* _document, CodeHighlighter ++format; } } - - - - -} -} diff --git a/mix/CodeHighlighter.h b/mix/CodeHighlighter.h index d0c92f3fc..5083e6c82 100644 --- a/mix/CodeHighlighter.h +++ b/mix/CodeHighlighter.h @@ -42,6 +42,7 @@ namespace solidity namespace mix { +/// Code highligting settings class CodeHighlighterSettings { public: @@ -60,15 +61,16 @@ public: ///Format for each token QTextCharFormat formats[Size]; ///Background color - QColor bg; + QColor backgroundColor; ///Foreground color - QColor fg; + QColor foregroundColor; }; - +/// Code highlighting engine class class CodeHighlighter { public: + /// Formatting range struct FormatRange { FormatRange(CodeHighlighterSettings::Token _t, int _start, int _length): token(_t), start(_start), length(_length) {} @@ -82,13 +84,20 @@ public: typedef std::vector Formats; // Sorted by start position public: - /// Collect highligting information + /// Collect highligting information by lexing the source void processSource(std::string const& _source); + /// Collect additional highligting information from AST void processAST(solidity::ASTNode const& _ast); + /// Collect highlighting information from compilation exception void processError(dev::Exception const& _exception); + + /// Apply formatting for a text document + /// @todo Remove this once editor is reworked void updateFormatting(QTextDocument* _document, CodeHighlighterSettings const& _settings); private: + /// Collect highligting information by paring for comments + /// @todo Support this in solidity? void processComments(std::string const& _source); private: diff --git a/mix/CodeModel.cpp b/mix/CodeModel.cpp index 0c94173e9..8d2c24725 100644 --- a/mix/CodeModel.cpp +++ b/mix/CodeModel.cpp @@ -33,10 +33,7 @@ #include "CodeHighlighter.h" #include "CodeModel.h" -namespace dev -{ -namespace mix -{ +using namespace dev::mix; void BackgroundWorker::queueCodeChange(int _jobId, QString const& _content) { @@ -45,13 +42,13 @@ void BackgroundWorker::queueCodeChange(int _jobId, QString const& _content) CompilationResult::CompilationResult(): QObject(nullptr), m_successfull(false), + m_codeHash(qHash(QString())), m_contract(new QContractDefinition()), - m_codeHighlighter(new CodeHighlighter()), - m_codeHash(qHash(QString())) + m_codeHighlighter(new CodeHighlighter()) {} CompilationResult::CompilationResult(const solidity::CompilerStack& _compiler): - QObject(nullptr), m_successfull(true) + QObject(nullptr), m_successfull(true), m_codeHash(qHash(QString())) { if (!_compiler.getContractNames().empty()) { @@ -64,7 +61,7 @@ CompilationResult::CompilationResult(const solidity::CompilerStack& _compiler): } CompilationResult::CompilationResult(CompilationResult const& _prev, QString const& _compilerMessage): - QObject(nullptr), m_successfull(false), + QObject(nullptr), m_successfull(false), m_codeHash(qHash(QString())), m_contract(_prev.m_contract), m_compilerMessage(_compilerMessage), m_bytes(_prev.m_bytes), @@ -168,6 +165,3 @@ void CodeModel::updateFormatting(QTextDocument* _document) { m_result->codeHighlighter()->updateFormatting(_document, *m_codeHighlighterSettings); } - -} -} diff --git a/mix/CodeModel.h b/mix/CodeModel.h index da093183d..69c840aa5 100644 --- a/mix/CodeModel.h +++ b/mix/CodeModel.h @@ -91,14 +91,14 @@ public: private: bool m_successfull; + uint m_codeHash; std::shared_ptr m_contract; QString m_compilerMessage; ///< @todo: use some structure here dev::bytes m_bytes; QString m_assemblyCode; std::shared_ptr m_codeHighlighter; - ///@todo syntax highlighting, etc + friend class CodeModel; - uint m_codeHash; }; /// Background code compiler diff --git a/mix/StateListView.cpp b/mix/StateListView.cpp index 62df6530a..fef9ab8e9 100644 --- a/mix/StateListView.cpp +++ b/mix/StateListView.cpp @@ -26,6 +26,7 @@ #include #include #include "StateListView.h" + using namespace dev::mix; StateListView::StateListView(AppContext* _context): Extension(_context, ExtensionDisplayBehavior::RightTab)