On Thu, Sep 22, 2011 at 11:37 AM, avasilev <[email protected]> wrote:
> 1) Does the global object always have 0 internal fields - (vanilla V8, > no third-party extensions)? My code sets the internal fields count to > 1 and uses internal field with index 0 to store a pointer. Is this > 'hardcoded' approach correct? > While i've never done this, you can create your own global object from your own template, which should allow you to use internal fields with the global object. You cannot set the number of internal fields on an Object, only on a Template. 2) I need to associate a pointer with a function object - the > function is used as a constructor of objects with C++ bindings, and > the pointer value is passed to the constructor of the bound native > object constructor (thus I have a context in which the object is > constructed). Since function objects don't have internal fields, I > first construct an ordinary object, and set its internal field, and > See FunctionTemplate::New(). It takes a (vaguely undocumented) parameter called "data". That "data" value can then be fetched from the Arguments object when the callback is actually called. Or at least that's what it APPEARS to do. Set the "data" handle: http://code.google.com/p/v8-juice/source/browse/convert/include/cvv8/V8Shell.hpp#554 Use it in the callback: http://code.google.com/p/v8-juice/source/browse/convert/include/cvv8/V8Shell.hpp#518 -- ----- stephan beal http://wanderinghorse.net/home/stephan/ -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
