Browse Source

- CommonJS => fromString(string _sn) fromString(string const& _sn).

- Wrapping string with QApplication::tr(), used for localization.
cl-refactor
yann300 10 years ago
committed by yann300
parent
commit
4da294f86d
  1. 7
      libdevcore/CommonJS.cpp
  2. 2
      libdevcore/CommonJS.h
  3. 5
      mix/AssemblyDebuggerCtrl.cpp
  4. 3
      mix/AssemblyDebuggerModel.cpp
  5. 6
      mix/ConstantCompilationCtrl.cpp
  6. 3
      mix/ConstantCompilationModel.cpp
  7. 2
      mix/KeyEventManager.cpp

7
libdevcore/CommonJS.cpp

@ -105,13 +105,8 @@ std::string fromRaw(h256 _n, unsigned* _inc)
return ""; return "";
} }
Address fromString(std::string _sn) Address fromString(std::string const& _sn)
{ {
if (_sn.size() > 32)
_sn.resize(32);
h256 n;
memcpy(n.data(), _sn.data(), _sn.size());
memset(n.data() + _sn.size(), 0, 32 - _sn.size());
if (_sn.size() == 40) if (_sn.size() == 40)
return Address(fromHex(_sn)); return Address(fromHex(_sn));
else else

2
libdevcore/CommonJS.h

@ -51,7 +51,7 @@ bytes padded(bytes _b, unsigned _l);
bytes unpadded(bytes _s); bytes unpadded(bytes _s);
std::string prettyU256(u256 _n); std::string prettyU256(u256 _n);
std::string fromRaw(h256 _n, unsigned* _inc = nullptr); std::string fromRaw(h256 _n, unsigned* _inc = nullptr);
Address fromString(std::string _a); Address fromString(std::string const& _a);
template <unsigned N> FixedHash<N> jsToFixed(std::string const& _s) template <unsigned N> FixedHash<N> jsToFixed(std::string const& _s)
{ {

5
mix/AssemblyDebuggerCtrl.cpp

@ -47,7 +47,7 @@ QString AssemblyDebuggerCtrl::contentUrl() const
QString AssemblyDebuggerCtrl::title() const QString AssemblyDebuggerCtrl::title() const
{ {
return "debugger"; return QApplication::tr("debugger");
} }
void AssemblyDebuggerCtrl::start() const void AssemblyDebuggerCtrl::start() const
@ -63,7 +63,6 @@ void AssemblyDebuggerCtrl::keyPressed(int _key)
QString code = m_doc->toPlainText(); QString code = m_doc->toPlainText();
QtConcurrent::run([this, code]() QtConcurrent::run([this, code]()
{ {
if (!m_modelDebugger->compile(m_doc->toPlainText())) if (!m_modelDebugger->compile(m_doc->toPlainText()))
{ {
emit dataAvailable(false, DebuggingStatusResult::Compilationfailed); emit dataAvailable(false, DebuggingStatusResult::Compilationfailed);
@ -101,5 +100,5 @@ void AssemblyDebuggerCtrl::updateGUI(bool success, DebuggingStatusResult reason,
this->addContentOn(this); this->addContentOn(this);
} }
else else
m_ctx->displayMessageDialog("debugger","compilation failed"); m_ctx->displayMessageDialog(QApplication::tr("debugger"), QApplication::tr("compilation failed"));
} }

3
mix/AssemblyDebuggerModel.cpp

@ -17,6 +17,7 @@
* used as a model to debug contract assembly code. * used as a model to debug contract assembly code.
*/ */
#include <QApplication>
#include "libethereum/Executive.h" #include "libethereum/Executive.h"
#include "libethereum/Transaction.h" #include "libethereum/Transaction.h"
#include "libethereum/ExtVM.h" #include "libethereum/ExtVM.h"
@ -90,7 +91,7 @@ DebuggingContent AssemblyDebuggerModel::getContractInitiationDebugStates(dev::u2
{ {
DebuggingContent r; DebuggingContent r;
r.contentAvailable = false; r.contentAvailable = false;
r.message = "compile failed"; r.message = QApplication::tr("compilation failed");
return r; return r;
} }

6
mix/ConstantCompilationCtrl.cpp

@ -43,7 +43,7 @@ QString ConstantCompilationCtrl::contentUrl() const
QString ConstantCompilationCtrl::title() const QString ConstantCompilationCtrl::title() const
{ {
return "compiler"; return QApplication::tr("compiler");
} }
void ConstantCompilationCtrl::start() const void ConstantCompilationCtrl::start() const
@ -80,13 +80,13 @@ void ConstantCompilationCtrl::writeOutPut(CompilerResult const& _res)
status->setProperty("text", "succeeded"); status->setProperty("text", "succeeded");
status->setProperty("color", "green"); status->setProperty("color", "green");
content->setProperty("text", _res.hexCode); content->setProperty("text", _res.hexCode);
qDebug() << QString("compile succeeded " + _res.hexCode); qDebug() << QString(QApplication::tr("compile succeeded") + " " + _res.hexCode);
} }
else else
{ {
status->setProperty("text", "failure"); status->setProperty("text", "failure");
status->setProperty("color", "red"); status->setProperty("color", "red");
content->setProperty("text", _res.comment); content->setProperty("text", _res.comment);
qDebug() << QString("compile failed " + _res.comment); qDebug() << QString(QApplication::tr("compile failed") + " " + _res.comment);
} }
} }

3
mix/ConstantCompilationModel.cpp

@ -20,6 +20,7 @@
* Ethereum IDE client. * Ethereum IDE client.
*/ */
#include <QApplication>
#include <QObject> #include <QObject>
#include <libevm/VM.h> #include <libevm/VM.h>
#include <libsolidity/Scanner.h> #include <libsolidity/Scanner.h>
@ -55,7 +56,7 @@ CompilerResult ConstantCompilationModel::compile(QString _code)
catch (...) catch (...)
{ {
res.success = false; res.success = false;
res.comment = "Uncaught exception."; res.comment = QApplication::tr("Uncaught exception.");
res.hexCode = ""; res.hexCode = "";
} }
return res; return res;

2
mix/KeyEventManager.cpp

@ -39,5 +39,3 @@ void KeyEventManager::keyPressed(QVariant _event)
{ {
emit onKeyPressed(_event.toInt()); emit onKeyPressed(_event.toInt());
} }

Loading…
Cancel
Save