Browse Source

first resources added using eth_add_resources

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
152a60f4b3
  1. 3
      libjsconsole/CMakeLists.txt
  2. 11
      libjsconsole/JSConsole.cpp
  3. 2
      libjsconsole/JSConsole.h
  4. 7
      libjsconsole/JSResources.cmake
  5. 1
      libjsengine/JSV8Printer.cpp
  6. 1
      libjsengine/JSV8Printer.h

3
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})

11
libjsconsole/JSConsole.cpp

@ -6,6 +6,7 @@
#include <algorithm>
#include <libdevcore/Log.h>
#include "JSConsole.h"
#include "libjsconsole/JSConsoleResources.hpp"
// TODO: readline!
#include <readline/readline.h>
@ -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, ' ');
}

2
libjsconsole/JSConsole.h

@ -15,7 +15,7 @@ namespace eth
class JSConsole
{
public:
JSConsole(): m_engine(), m_printer(m_engine) {}
JSConsole();
void repl() const;
private:

7
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")

1
libjsengine/JSV8Printer.cpp

@ -9,7 +9,6 @@ using namespace eth;
JSV8Printer::JSV8Printer(JSV8Engine const& _engine)
{
}
const char* JSV8Printer::prettyPrint(JSV8Value const& _value) const

1
libjsengine/JSV8Printer.h

@ -7,7 +7,6 @@
#include "JSPrinter.h"
#include "JSV8Engine.h"
namespace dev
{
namespace eth

Loading…
Cancel
Save