On May 3, 11:35 am, Stephan Beal <[email protected]> wrote: > On Tue, May 3, 2011 at 3:41 PM, Charles Lowell > <[email protected]>wrote: > > > into Ruby like Context and FunctionTemplate. That said, being able to > > get a stable, unique object id for all values would be killer. You > > mentioned that it would be relatively straightforward to roll your > > own? Any chance you could elaborate? > > For OBJECTS you can presumably use the identity hash, but for non-Objects v8 > does not publish a _stable_ unique ID. You can get a (void *) to the > underlying data (Value::Data(), IIRC), which could then be used as a key, > but that address is not guaranteed to be stable - v8 may relocate it as a > side-effect of allocation/gc. > > When i first started porting my SpiderMonkey JS/C++ type conversions > framework to v8. that lack of a stable ID was my first big hurdle, and > eventually gave up on the idea that one can tie a (T*) to a JS integer in > v8. > > For builtin Object types (Date, Regex, etc) you can't stuff your own > mappings into them because the number of internal fields is defined by the > Template and not on a per-instance basis. e.g. the Regex authors didn't set > aside an internal field for our use then we cannot stuff an internal field > in those instances. >
Indeed, but Mads mentioned at the very end of his response that there was a way to roll your own for values, and I'm curious to hear what he had in mind. cheers, Charles > -- > ----- stephan bealhttp://wanderinghorse.net/home/stephan/ -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
