I like my version better than v8-juice. Takes advantage of boost to make the code neater and uses function pointer style template arguments to make the binding code smaller:
https://github.com/tsa/vu8 Cheers, James On 16 January 2011 14:12, Stephan Beal <[email protected]> wrote: > On Sun, Jan 16, 2011 at 12:43 PM, Jak Sprats <[email protected]> wrote: > >> Does V8 embedding have something like this, so not only a way to call >> Javascript from C, but also a way to call C from Javacript? >> > > There is, but only if you use C++ glue to bind your C API to v8's C++ API, > which in turn binds to JS space. > > If i may be so bold as to toot my own horn for a moment, i believe i've > implemented the world's simplest-to-use binding mechanism for wrapping C > functions (from C++) in v8. Here's an example of all the code one needs to > bind sleep() to v8: > > jsObj->Set( String::New("sleep"), FunctionTemplate::New( > convert::FunctionForwarder<1>::Invocable<unsigned int,unsigned > int,::sleep> > )->GetFunction() ); > > About 50% of that code is required by v8 (i.e. unavoidable, regardless of > the wrapping framework) and the other 50% is invoking one of my templates > which creates a new v8::InvocationCallback function (with compile-time type > safety and no dynamic memory costs) which acts a proxy for sleep(). > > More on this topic can be found here: > > http://code.google.com/p/v8-juice/wiki/BindingFunctions > > -- > ----- stephan beal > http://wanderinghorse.net/home/stephan/ > > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users > -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
