// // Created by Marek Kotewicz on 28/04/15. // #include #include "JSV8Printer.h" #include "libjsengine/JSEngineResources.hpp" using namespace std; using namespace dev; using namespace eth; JSV8Printer::JSV8Printer(JSV8Engine const& _engine): m_engine(_engine) { JSEngineResources resources; string prettyPrint = resources.loadResourceAsString("pretty_print"); m_engine.eval(prettyPrint.c_str()); } const char* JSV8Printer::prettyPrint(JSV8Value const& _value) const { v8::HandleScope handleScope(m_engine.context()->GetIsolate()); v8::Local pp = v8::String::NewFromUtf8(m_engine.context()->GetIsolate(), "prettyPrint"); v8::Handle func = v8::Handle::Cast(m_engine.context()->Global()->Get(pp)); v8::Local values[1] = {_value.value()}; v8::Local res = v8::Local::Cast(func->Call(func, 1, values)); v8::String::Utf8Value str(res); return *str ? *str : ""; }