From 152a60f4b3c79215d0569722be03db6e1586d7e8 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Thu, 30 Apr 2015 00:58:54 +0200 Subject: [PATCH] first resources added using eth_add_resources --- libjsconsole/CMakeLists.txt | 3 +++ libjsconsole/JSConsole.cpp | 11 +++++++++++ libjsconsole/JSConsole.h | 2 +- libjsconsole/JSResources.cmake | 7 +++++++ libjsengine/JSV8Printer.cpp | 1 - libjsengine/JSV8Printer.h | 1 - 6 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 libjsconsole/JSResources.cmake diff --git a/libjsconsole/CMakeLists.txt b/libjsconsole/CMakeLists.txt index b67803dbf..984874921 100644 --- a/libjsconsole/CMakeLists.txt +++ b/libjsconsole/CMakeLists.txt @@ -20,6 +20,9 @@ file(GLOB HEADERS "*.h") add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS}) +include(EthUtils) +eth_add_resources(${EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/JSResources.cmake") + target_link_libraries(${EXECUTABLE} jsengine) target_link_libraries(${EXECUTABLE} devcore) target_link_libraries(${EXECUTABLE} ${READLINE_LIBRARIES}) diff --git a/libjsconsole/JSConsole.cpp b/libjsconsole/JSConsole.cpp index 8cbc91d54..91860422f 100644 --- a/libjsconsole/JSConsole.cpp +++ b/libjsconsole/JSConsole.cpp @@ -6,6 +6,7 @@ #include #include #include "JSConsole.h" +#include "libjsconsole/JSConsoleResources.hpp" // TODO: readline! #include @@ -15,6 +16,14 @@ using namespace std; using namespace dev; using namespace dev::eth; +JSConsole::JSConsole(): m_engine(), m_printer(m_engine) +{ + JSConsoleResources resources; + string web3 = resources.loadResourceAsString("web3"); + m_engine.eval(web3.c_str()); + m_engine.eval("web3 = require('web3');"); +} + void JSConsole::repl() const { string cmd = ""; @@ -54,3 +63,5 @@ std::string JSConsole::promptForIndentionLevel(int _i) const return string((_i + 1) * 2, ' '); } + + diff --git a/libjsconsole/JSConsole.h b/libjsconsole/JSConsole.h index 216813a01..9c278a93d 100644 --- a/libjsconsole/JSConsole.h +++ b/libjsconsole/JSConsole.h @@ -15,7 +15,7 @@ namespace eth class JSConsole { public: - JSConsole(): m_engine(), m_printer(m_engine) {} + JSConsole(); void repl() const; private: diff --git a/libjsconsole/JSResources.cmake b/libjsconsole/JSResources.cmake new file mode 100644 index 000000000..c30d7614e --- /dev/null +++ b/libjsconsole/JSResources.cmake @@ -0,0 +1,7 @@ + +set(web3 "${CMAKE_CURRENT_LIST_DIR}/../libjsqrc/ethereumjs/dist/web3.min.js") + +set(ETH_RESOURCE_NAME "JSConsoleResources") +set(ETH_RESOURCE_LOCATION "${CMAKE_CURRENT_BINARY_DIR}") +set(ETH_RESOURCES "web3") + diff --git a/libjsengine/JSV8Printer.cpp b/libjsengine/JSV8Printer.cpp index 80c06d590..3ac7d475b 100644 --- a/libjsengine/JSV8Printer.cpp +++ b/libjsengine/JSV8Printer.cpp @@ -9,7 +9,6 @@ using namespace eth; JSV8Printer::JSV8Printer(JSV8Engine const& _engine) { - } const char* JSV8Printer::prettyPrint(JSV8Value const& _value) const diff --git a/libjsengine/JSV8Printer.h b/libjsengine/JSV8Printer.h index 430842129..b35f0d746 100644 --- a/libjsengine/JSV8Printer.h +++ b/libjsengine/JSV8Printer.h @@ -7,7 +7,6 @@ #include "JSPrinter.h" #include "JSV8Engine.h" - namespace dev { namespace eth