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

Reply via email to