Browse Source

Avoid failing Qt on pedantic.

Merge branch 'chromium' into develop

Conflicts:
	libjsqrc/ethereumjs/dist/ethereum.js.map
	libjsqrc/ethereumjs/dist/ethereum.min.js
cl-refactor
Gav Wood 10 years ago
parent
commit
7f8c9f22aa
  1. 5
      alethzero/CMakeLists.txt
  2. 15
      alethzero/Main.ui
  3. 55
      alethzero/MainWin.cpp
  4. 2
      alethzero/MainWin.h
  5. 3
      libethereum/CanonBlockChain.cpp
  6. 8
      libjsqrc/ethereumjs/dist/ethereum.js
  7. 4
      libjsqrc/ethereumjs/dist/ethereum.js.map
  8. 2
      libjsqrc/ethereumjs/dist/ethereum.min.js
  9. 8
      libjsqrc/ethereumjs/lib/web3.js

5
alethzero/CMakeLists.txt

@ -15,6 +15,9 @@ include_directories(BEFORE ..)
include_directories(${JSON_RPC_CPP_INCLUDE_DIRS}) include_directories(${JSON_RPC_CPP_INCLUDE_DIRS})
include_directories(${Boost_INCLUDE_DIRS}) include_directories(${Boost_INCLUDE_DIRS})
find_package (Qt5WebEngine QUIET)
find_package (Qt5WebEngineWidgets QUIET)
qt5_wrap_ui(ui_Main.h Main.ui) qt5_wrap_ui(ui_Main.h Main.ui)
qt5_wrap_ui(ui_Debugger.h Debugger.ui) qt5_wrap_ui(ui_Debugger.h Debugger.ui)
qt5_wrap_ui(ui_Transact.h Transact.ui) qt5_wrap_ui(ui_Transact.h Transact.ui)
@ -40,6 +43,8 @@ target_link_libraries(${EXECUTABLE} Qt5::Core)
target_link_libraries(${EXECUTABLE} Qt5::Widgets) target_link_libraries(${EXECUTABLE} Qt5::Widgets)
target_link_libraries(${EXECUTABLE} Qt5::WebKit) target_link_libraries(${EXECUTABLE} Qt5::WebKit)
target_link_libraries(${EXECUTABLE} Qt5::WebKitWidgets) target_link_libraries(${EXECUTABLE} Qt5::WebKitWidgets)
target_link_libraries(${EXECUTABLE} Qt5::WebEngine)
target_link_libraries(${EXECUTABLE} Qt5::WebEngineWidgets)
target_link_libraries(${EXECUTABLE} webthree) target_link_libraries(${EXECUTABLE} webthree)
target_link_libraries(${EXECUTABLE} ethereum) target_link_libraries(${EXECUTABLE} ethereum)
target_link_libraries(${EXECUTABLE} evm) target_link_libraries(${EXECUTABLE} evm)

15
alethzero/Main.ui

@ -102,13 +102,7 @@
<widget class="QLineEdit" name="urlEdit"/> <widget class="QLineEdit" name="urlEdit"/>
</item> </item>
<item> <item>
<widget class="QWebView" name="webView"> <widget class="QWebEngineView" name="webView" native="true"/>
<property name="url">
<url>
<string>about:blank</string>
</url>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
@ -1691,6 +1685,12 @@ font-size: 14pt</string>
<header>DownloadView.h</header> <header>DownloadView.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>QWebEngineView</class>
<extends>QWidget</extends>
<header location="global">QtWebEngineWidgets/QWebEngineView</header>
<container>1</container>
</customwidget>
</customwidgets> </customwidgets>
<tabstops> <tabstops>
<tabstop>shhTo</tabstop> <tabstop>shhTo</tabstop>
@ -1705,7 +1705,6 @@ font-size: 14pt</string>
<tabstop>jsConsole</tabstop> <tabstop>jsConsole</tabstop>
<tabstop>tabWidget</tabstop> <tabstop>tabWidget</tabstop>
<tabstop>urlEdit</tabstop> <tabstop>urlEdit</tabstop>
<tabstop>webView</tabstop>
<tabstop>idealPeers</tabstop> <tabstop>idealPeers</tabstop>
<tabstop>forceAddress</tabstop> <tabstop>forceAddress</tabstop>
<tabstop>port</tabstop> <tabstop>port</tabstop>

55
alethzero/MainWin.cpp

@ -19,17 +19,21 @@
* @date 2014 * @date 2014
*/ */
#define QWEBENGINEINSPECTOR 1
#include <fstream> #include <fstream>
// Make sure boost/asio.hpp is included before windows.h. // Make sure boost/asio.hpp is included before windows.h.
#include <boost/asio.hpp> #include <boost/asio.hpp>
#pragma GCC diagnostic ignored "-Wpedantic"
#include <QtNetwork/QNetworkReply> #include <QtNetwork/QNetworkReply>
#include <QtWidgets/QFileDialog> #include <QtWidgets/QFileDialog>
#include <QtWidgets/QMessageBox> #include <QtWidgets/QMessageBox>
#include <QtWidgets/QInputDialog> #include <QtWidgets/QInputDialog>
#include <QtWebKitWidgets/QWebFrame> #include <QtWebEngine/QtWebEngine>
#include <QtWebKit/QWebSettings> #include <QtWebEngineWidgets/QWebEngineView>
#include <QtWebEngineWidgets/QWebEngineCallback>
#include <QtWebEngineWidgets/QWebEngineSettings>
#include <QtGui/QClipboard> #include <QtGui/QClipboard>
#include <QtCore/QtCore> #include <QtCore/QtCore>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
@ -113,8 +117,10 @@ Main::Main(QWidget *parent) :
ui(new Ui::Main), ui(new Ui::Main),
m_transact(this, this) m_transact(this, this)
{ {
QtWebEngine::initialize();
setWindowFlags(Qt::Window); setWindowFlags(Qt::Window);
ui->setupUi(this); ui->setupUi(this);
QtWebEngine::initialize();
g_logPost = [=](string const& s, char const* c) g_logPost = [=](string const& s, char const* c)
{ {
simpleDebugOut(s, c); simpleDebugOut(s, c);
@ -160,31 +166,24 @@ Main::Main(QWidget *parent) :
m_server->setIdentities(keysAsVector(owned())); m_server->setIdentities(keysAsVector(owned()));
m_server->StartListening(); m_server->StartListening();
connect(ui->webView, &QWebView::loadStarted, [this]() connect(ui->webView, &QWebEngineView::loadFinished, [this]()
{
QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
QWebFrame* f = ui->webView->page()->mainFrame();
f->disconnect(SIGNAL(javaScriptWindowObjectCleared()));
connect(f, &QWebFrame::javaScriptWindowObjectCleared, [f, this]()
{
f->disconnect();
f->addToJavaScriptWindowObject("env", this, QWebFrame::QtOwnership);
f->evaluateJavaScript(contentsOfQResource(":/js/bignumber.min.js"));
f->evaluateJavaScript(contentsOfQResource(":/js/webthree.js"));
f->evaluateJavaScript(contentsOfQResource(":/js/setup.js"));
});
});
connect(ui->webView, &QWebView::loadFinished, [=]()
{ {
// f->disconnect();
// f->addToJavaScriptWindowObject("env", this, QWebFrame::QtOwnership);
auto f = ui->webView->page();
f->runJavaScript(contentsOfQResource(":/js/bignumber.min.js"));
f->runJavaScript(contentsOfQResource(":/js/webthree.js"));
f->runJavaScript(contentsOfQResource(":/js/setup.js"));
}); });
connect(ui->webView, &QWebView::titleChanged, [=]() connect(ui->webView, &QWebEngineView::titleChanged, [=]()
{ {
ui->tabWidget->setTabText(0, ui->webView->title()); ui->tabWidget->setTabText(0, ui->webView->title());
}); });
// ui->webView->page()->settings()->setAttribute(QWebEngineSettings::DeveloperExtrasEnabled, true);
// QWebEngineInspector* inspector = new QWebEngineInspector();
// inspector->setPage(page);
readSettings(); readSettings();
installWatches(); installWatches();
startTimer(100); startTimer(100);
@ -372,7 +371,7 @@ QString Main::contents(QString _s)
void Main::load(QString _s) void Main::load(QString _s)
{ {
QString contents = QString::fromStdString(dev::asString(dev::contents(_s.toStdString()))); QString contents = QString::fromStdString(dev::asString(dev::contents(_s.toStdString())));
ui->webView->page()->currentFrame()->evaluateJavaScript(contents); ui->webView->page()->runJavaScript(contents);
/* /*
QFile fin(_s); QFile fin(_s);
if (!fin.open(QFile::ReadOnly)) if (!fin.open(QFile::ReadOnly))
@ -431,17 +430,12 @@ void Main::on_jsInput_returnPressed()
ui->jsInput->setText(""); ui->jsInput->setText("");
} }
QVariant Main::evalRaw(QString const& _js)
{
return ui->webView->page()->currentFrame()->evaluateJavaScript(_js);
}
void Main::eval(QString const& _js) void Main::eval(QString const& _js)
{ {
if (_js.trimmed().isEmpty()) if (_js.trimmed().isEmpty())
return; return;
QVariant ev = ui->webView->page()->currentFrame()->evaluateJavaScript((_js.startsWith("{") || _js.startsWith("if ") || _js.startsWith("if(")) ? _js : ("___RET=(" + _js + ")")); auto f = [=](QVariant ev) {
QVariant jsonEv = ui->webView->page()->currentFrame()->evaluateJavaScript("JSON.stringify(___RET)"); auto f2 = [=](QVariant jsonEv) {
QString s; QString s;
if (ev.isNull()) if (ev.isNull())
s = "<span style=\"color: #888\">null</span>"; s = "<span style=\"color: #888\">null</span>";
@ -460,6 +454,11 @@ void Main::eval(QString const& _js)
"<div style=\"border-bottom: 1 solid #eee; width: 100%\"><span style=\"float: left; width: 1em\">&nbsp;</span><span>" + i.second + "</span></div>"; "<div style=\"border-bottom: 1 solid #eee; width: 100%\"><span style=\"float: left; width: 1em\">&nbsp;</span><span>" + i.second + "</span></div>";
s += "</div></body></html>"; s += "</div></body></html>";
ui->jsConsole->setHtml(s); ui->jsConsole->setHtml(s);
};
ui->webView->page()->runJavaScript("JSON.stringify(___RET)", f2);
};
auto c = (_js.startsWith("{") || _js.startsWith("if ") || _js.startsWith("if(")) ? _js : ("___RET=(" + _js + ")");
ui->webView->page()->runJavaScript(c, f);
} }
static Public stringToPublic(QString const& _a) static Public stringToPublic(QString const& _a)

2
alethzero/MainWin.h

@ -76,8 +76,6 @@ public:
bool confirm() const; bool confirm() const;
NatSpecFace* natSpec() { return &m_natSpecDB; } NatSpecFace* natSpec() { return &m_natSpecDB; }
QVariant evalRaw(QString const& _js);
QString pretty(dev::Address _a) const override; QString pretty(dev::Address _a) const override;
QString prettyU256(dev::u256 _n) const override; QString prettyU256(dev::u256 _n) const override;
QString render(dev::Address _a) const override; QString render(dev::Address _a) const override;

3
libethereum/CanonBlockChain.cpp

@ -43,6 +43,7 @@ namespace js = json_spirit;
std::map<Address, Account> const& dev::eth::genesisState() std::map<Address, Account> const& dev::eth::genesisState()
{ {
static std::map<Address, Account> s_ret; static std::map<Address, Account> s_ret;
if (s_ret.empty()) if (s_ret.empty())
{ {
js::mValue val; js::mValue val;
@ -66,6 +67,8 @@ std::map<Address, Account> const& dev::eth::genesisState()
return s_ret; return s_ret;
} }
// TODO: place Registry in here.
std::unique_ptr<BlockInfo> CanonBlockChain::s_genesis; std::unique_ptr<BlockInfo> CanonBlockChain::s_genesis;
boost::shared_mutex CanonBlockChain::x_genesis; boost::shared_mutex CanonBlockChain::x_genesis;

8
libjsqrc/ethereumjs/dist/ethereum.js

@ -1787,6 +1787,14 @@ var web3 = {
}; };
}, },
canary: function (abi) {
return function(addr) {
// Default to address of Config. TODO: rremove prior to genesis.
addr = addr || '0xc6d9d2cd449a754c494264e1809c50e34d64562b';
return addr;
};
},
/// @param filter may be a string, object or event /// @param filter may be a string, object or event
/// @param indexed is optional, this is an object with optional event indexed params /// @param indexed is optional, this is an object with optional event indexed params
/// @param options is optional, this is an object with optional event options ('max'...) /// @param options is optional, this is an object with optional event options ('max'...)

4
libjsqrc/ethereumjs/dist/ethereum.js.map

File diff suppressed because one or more lines are too long

2
libjsqrc/ethereumjs/dist/ethereum.min.js

File diff suppressed because one or more lines are too long

8
libjsqrc/ethereumjs/lib/web3.js

@ -141,6 +141,14 @@ var web3 = {
}; };
}, },
canary: function (abi) {
return function(addr) {
// Default to address of Config. TODO: rremove prior to genesis.
addr = addr || '0xc6d9d2cd449a754c494264e1809c50e34d64562b';
return addr;
};
},
/// @param filter may be a string, object or event /// @param filter may be a string, object or event
/// @param indexed is optional, this is an object with optional event indexed params /// @param indexed is optional, this is an object with optional event indexed params
/// @param options is optional, this is an object with optional event options ('max'...) /// @param options is optional, this is an object with optional event options ('max'...)

Loading…
Cancel
Save