Hi All,

I'm seeking a way to trigger destruction (or reference decrement) of a C++
object attached to a V8 object when the V8 object is destroyed.  For
instance, consider the following code where I create and return a new V8
object in a function template callback:

static v8::Handle<v8::Value> MyCallback(const v8::Arguments& args) {
  // Create a new V8 object template with one internal field.
  v8::Handle<v8::ObjectTemplate> my_templ = v8::ObjectTemplate::New();
  my_templ->SetInternalFieldCount(1);

  // Create a new MyClass instance.
  MyClass* my_class = ...;

  // Create a new V8 object.
  v8::Local<v8::Object> obj = my_templ->NewInstance();

  // Attach the MyClass instance to the V8 object.
  obj->SetInternalField(0, v8::External::New(my_class));

  return obj;
}

How can I clean up the MyClass instance when the associated V8 object
destroyed?  Is there some way that I can assign a destructor callback for
the V8 object?

Thanks,
Marshall

--~--~---------~--~----~------------~-------~--~----~
Chromium Developers mailing list: chromium-dev@googlegroups.com 
View archives, change email options, or unsubscribe: 
    http://groups.google.com/group/chromium-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to