On Fri, Mar 27, 2009 at 7:38 PM, <[email protected]> wrote: > Handle<Value> TestAccessorGetter(Local<String> property, > const AccessorInfo &info) { > Local<Object> self = info.Holder(); > Local<External> wrap = Local<External>::Cast(self->GetInternalField > (0)); <big snip> > --> Call to TestFunction works perfectly. But the next call to > TestAccessor throws within Local<External> wrap = Local<External>::Cast > (self->GetInternalField(0));...
Hi! i don't see any immediately wrong with what you've done - i hope one of the more experienced v8'ers out there can answer it. i agree with Alex that having an external in the global object is a bit curious. As i understood (perhaps very incorrectly), the internal field count applies to new instances of the object's class. Aside from that: this approach to using Externals to tie native data *is* the official method provided by v8, but is a road filled with potholes and segfaults. If someone ever passes the wrong type of object to your function (or you somehow get a non-External), the cast will fail and the app will likely segfault. It is possible to use templates to make this operations typesafe and lookup tables to provide an extra layer of "is this REALLY an object of type type", and i've written an article on the topic which you can find here: http://code.google.com/p/v8-juice/wiki/CreatingJSClasses -- ----- stephan beal http://wanderinghorse.net/home/stephan/ --~--~---------~--~----~------------~-------~--~----~ v8-users mailing list [email protected] http://groups.google.com/group/v8-users -~----------~----~----~----~------~----~------~--~---
