void JS_ReleaseRuntime(IJS_Runtime* pJSRuntime, v8::Persistent<v8::Context>& v8PersistentContext) { v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolate, v8PersistentContext); v8::Context::Scope context_scope(context); CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); if(!pArray) return ; for(int i=0; i<pArray->GetSize(); i++) { CJS_ObjDefintion* pObjDef = (CJS_ObjDefintion*)pArray->GetAt(i); if(!pObjDef->m_StaticObj.IsEmpty()) { v8::Local<v8::Object> pObj = v8::Local<v8::Object>::New(isolate, pObjDef->m_StaticObj); if(pObjDef->m_pDestructor) pObjDef->m_pDestructor(pObj); JS_FreePrivate(pObj); } delete pObjDef; } delete pArray; isolate->SetData(0,NULL); }
/* --------------------------------- CJS_Object --------------------------------- */ void FreeObject(const v8::WeakCallbackData<v8::Object, CJS_Object>& data) { CJS_Object* pJSObj = data.GetParameter(); if(pJSObj) { pJSObj->ExitInstance(); delete pJSObj; } v8::Local<v8::Object> obj = data.GetValue(); JS_FreePrivate(obj); }
void JS_FreePrivate(v8::Handle<v8::Object> pObj) { if(pObj.IsEmpty() || !pObj->InternalFieldCount()) return; JS_FreePrivate(pObj->GetAlignedPointerFromInternalField(0)); pObj->SetAlignedPointerInInternalField(0, NULL); }