On Mon, Sep 3, 2012 at 5:24 PM, Mohammad Ashiqur Rahaman <
[email protected]> wrote:

> regarding 1 so far what i understood that you need to be still in the C++
> side in order to somehow use JS. That is you have to write JS code as
> string inside C++ and then run. But what if i want to use an external JS
> file where I can simply write the v8 code to invoke v8 enabled c++ classes
> and methods?? I am missing this part.
>

The v8 sources have an example of doing this (not a GREAT example, mind
you, but a working example) in their shell app. In short: use std::istream
to read in the contents (google std::copy and std::istream_iterator) and
then feed it to v8. There are several libraries out there which
demonstrate/simplify this, e.g., here's mine:

http://code.google.com/p/v8-juice/

here's a concrete example of executing external JS from JS:

http://code.google.com/p/v8-juice/source/browse/convert/include/cvv8/V8Shell.hpp#370
http://code.google.com/p/v8-juice/source/browse/convert/include/cvv8/V8Shell.hpp#451

(also not a GREAT example, but a working one ;)

-- 
----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to