I'm writing a little plugin that allows you to use v8 in the Ruby
programming language. Right now I'm kind of having trouble with
creating a callback to a non-static member function. Basically, the
FunctionTemplate allows me to input a callback, but it's impossible to
simply reference a member function (more about the complexities of
that here: http://www.parashift.com/c++-faq-lite/pointers-to-members.html)
However, when reading the embedder's guide, it seems that you've
solved this problem already for accessors!
"The complexity of an accessor depends upon the type of data you are
manipulating:
* Accessing Static Global Variables
* Accessing Dynamic Variables
"
For the latter, you're using a special mechanism that allows you to
define a static wrapper function, which then uses AccessorInfo to get
a reference to the object. This means that it's possible to call
member functions (dynamic functions of a class instance) when you use
accessors.
However, it is not possible to use dynamic functions when you use a
FunctionTemplate. Is this correct?
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.
Thanks!
P.S. My C++ is a bit rusty, but I've been digging into this problem
for quite some hours now.
you still use static functions, but you associate a class instance
when you create the v8 object and then invoke a method on the
instance.
> --
> v8-users mailing list
> v8-u...@googlegroups.com
> http://groups.google.com/group/v8-users
>
--
Eric Z. Ayers
Google Web Toolkit, Atlanta, GA USA
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.
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 <sgb...@googlemail.com> wrote:
--
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.