You need to be in a Context Scope, I think...  I was dealing with a
similar problem a while ago; here's what I have.

---
v8::HandleScope handle_scope;

v8::Handle<v8::ObjectTemplate> point_inst = v8::ObjectTemplate::New();
point_inst->SetInternalFieldCount(1);

point_inst->SetAccessor(v8::String::New("x"), JS_GetXPos, JS_SetXPos);

v8::Handle<v8::Context> context = v8::Context::New(NULL, point_inst);
v8::Context::Scope context_scope(context);

Point* p = new Point;
v8::Handle<v8::Object> obj = point_inst->NewInstance();
obj->SetInternalField(0, v8::External::New(p));

context->Global()->Set(v8::String::New("Point"), obj);
---

I hope that helps you.  It compiles, but I'm not sure if I'm doing
things properly/efficiently.  As for the documentation thing, I
couldn't agree more.  A long while back someone started working on a
v8 Cookbook with code samples, etc., but it seems the project died. =(

~Dennis

--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to