On Fri, Oct 5, 2012 at 7:04 PM, Pablo Sole <[email protected]> wrote:
> I found that the Foreign Class is actually a subclass of HeapObject and
> the only difference is that it has some extra size to store a pointer
> inside.
>
> So, Can I use a Foreign instance to store a pointer from some C function
> and pass it back and forth from/to JS?

Have you looked at External::Wrap (and Unwrap)? It returns an
v8::Value than can be passed through the embedding api. It states
(literally) "The Wrap function V8 will return the most optimal Value
object wrapping the C++ void*. "

>
> From the code of SetPointerInInternalField I see that's what V8 does if
> the pointer cannot be encoded as a SMI. But for the purpose of *just*
> sending pointers back and forth, creating an object with an internal
> field that ends up having another object on it that actually stores the
> address seems overkill, if a Foreign object is a valid JS object, I'd
> use that directly.
>
> Thanks,
>
> pablo.
>
> --
> 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

Reply via email to