Yes, it works!! But I need bind objects with c++ pointers, it seems more natural the object has the c++ pointer and their methods/properties use it.
I have tested with ObjectTemplate::New() but it don't accept a data parameter. I have tested with SetInternalField but it only works with Global (after context being created) not with objects into Global (you know, B, C, D in my original email). I need bind every object (not template) with a c++ pointer. There must be a general (and simple) technique to do that. Thanks in advance. De: [email protected] [mailto:[email protected]] En nombre de Abdulla Kamar Enviado el: martes, 23 de febrero de 2010 1:01 Para: [email protected] Asunto: Re: [v8-users] Re: Function Templates: Calling non-static member functions When you create a function with v8::FunctionTemplate::New(), you can optionally pass a v8::Value along with it. This value can be a pointer to a class that you can get when your callback is invoked by using v8::Arguments::Data(). Hopefully that helps. On Tue, Feb 23, 2010 at 6:08 AM, cretz <[email protected]> wrote: I am sorry to revive an old thread, but I am running in to the same issue. I am trying to make a JSR-223 compatible Java bridge to V8. I also need dynamic function binding. I am unable to see the pastebin since it has expired. Can someone repost? Also, I prefer to use pure V8 w/out the v8-juice project. Does anyone know the best way to dynamically bind functions at runtime? I was considering binding all functions to a single function and obtaining some form of unique identification from the Arguments object. Any help is appreciated. On Jan 8, 5:42 am, Stephan Beal <[email protected]> wrote: > On Fri, Jan 8, 2010 at 4:02 AM, dominiek <[email protected]> wrote: > > Is there any hack you can think of that allows me to do it anyway? > > Providing callbacks to non-static member functions is essential for > > writing scripting language extensions. > > A callback to a non-static member function always requires an instance of > that class. Aside from that, binding a member function is very similar to > binding a non-member function (with the additional step of decoding the > native "this" object before calling the native member function). > > The v8-juice project provides support for binding any of the following C++ > constructs to v8: > > - free functions > - member functions (if the class containing the member is also wrapped) > - member variables, either via the Accessor interceptors or by binding > functions to them, such that the functions are called in place of the > get/set operations. > - static variables, whether member or free. > > You might find it useful for your project. > > The main project page:http://code.google.com/p/v8-juice/ > > Some useful wiki pages: > > How the type conversions work:http://code.google.com/p/v8-juice/wiki/ConvertingTypes > (that part is central to the whole binding mechanism) > > Binding free functions:http://code.google.com/p/v8-juice/wiki/BindingFunctions > > Binding classes (including member funcs/variables):http://code.google.com/p/v8-juice/wiki/ClassWrap > > > P.S. My C++ is a bit rusty, but I've been digging > > into this problem for quite some hours now. > > Given that: be aware that generic binding mechanisms require either code > generators (i'm not aware of any for v8, unless one counts macros) or rather > intricate templates-based mechanisms. Thus you may want to brush up on your > C++ before undertaking any significant JS/C++ binding projects. Simple (or > "brute force") bindings can be done without too much C++ know-how, but > generic solutions to the problem require a fairly good understanding of C++ > templates (or a hypothetical code generator). > > -- > ----- stephan bealhttp://wanderinghorse.net/home/stephan/ -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users -- Thank you Abdulla -- 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
