예제 #1
0
 inline void Wrap(v8::Handle<v8::Object> handle) {
   assert(persistent().IsEmpty());
   assert(handle->InternalFieldCount() > 0);
   handle->SetAlignedPointerInInternalField(0, this);
   persistent().Reset(v8::Isolate::GetCurrent(), handle);
   MakeWeak();
 }
예제 #2
0
 /* Unref() marks an object as detached from the event loop.  This is its
  * default state.  When an object with a "weak" reference changes from
  * attached to detached state it will be freed. Be careful not to access
  * the object after making this call as it might be gone!
  * (A "weak reference" means an object that only has a
  * persistant handle.)
  *
  * DO NOT CALL THIS FROM DESTRUCTOR
  */
 virtual void Unref() {
   assert(!persistent().IsEmpty());
   assert(!persistent().IsWeak());
   assert(refs_ > 0);
   if (--refs_ == 0)
     MakeWeak();
 }
예제 #3
0
int NaObject::Release()
{
	if (--m_nRef == 0)
	{
		MakeWeak();
		delete this;
		return 0;
	}
	return m_nRef;
}