Hi, I am using Functors and templates maybe it can help you

http://code.google.com/p/cproxyv8/

On Oct 21, 7:13 pm, Stephan Beal <[email protected]> wrote:
> Hi, all!
>
> i thought this might be interesting for some of you...
>
> The past few days i've written some template code which generates
> v8::InvocationCallback functions from near-arbitrary native functions.
>
> As an example, here we bind the Unix-standard sleep() function to an
> arbitrary JS object:
>
> jsObj->Set( String::New("sleep"), FunctionTemplate::New(
>       juice::convert::FunctionForwarder<1>::Invocable<unsigned
> int,unsigned int,::sleep>
>     )->GetFunction() );
>
> It doesn't get much easier that that! (Except maybe with some template
> mega-magic which would figure out and pass on the templatized types
> needed to bind the functions.)
>
> i've started documenting it here:
>
> http://code.google.com/p/v8-juice/wiki/BindingFunctions
>
> theres a link to demo code there, and a fairly detailed description of
> what the framework can and cannot do.
>
> It also supports binding native _member_ functions, provided one knows
> what one is doing and can set up a proper cast-from-js-to-native
> template specialization for his given type (it's easy to do, in any
> case).
>
> The (member) function binding parts demonstrated above require only a
> few header files, and are otherwise independent of the v8-juice
> project's source code, so they should be easy to extract for use in
> your pet v8-based projects. The class binding parts incidentally also
> demonstrated above are dependent on other parts of v8-juice (but the
> class binding bits are based partly off of the function binding code,
> so they demonstrate how to use it).
--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to