1 // Copyright 2014 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #include "fpdfsdk/javascript/JS_Object.h" 8 9 #include "fpdfsdk/javascript/JS_Define.h" 10 #include "fpdfsdk/javascript/cjs_event_context.h" 11 12 CJS_EmbedObj::CJS_EmbedObj(CJS_Object* pJSObject) : m_pJSObject(pJSObject) {} 13 14 CJS_EmbedObj::~CJS_EmbedObj() { 15 } 16 17 void FreeObject(const v8::WeakCallbackInfo<CJS_Object>& data) { 18 CJS_Object* pJSObj = data.GetParameter(); 19 delete pJSObj; 20 CFXJS_Engine::FreeObjectPrivate(data.GetInternalField(0)); 21 } 22 23 void DisposeObject(const v8::WeakCallbackInfo<CJS_Object>& data) { 24 CJS_Object* pJSObj = data.GetParameter(); 25 pJSObj->Dispose(); 26 data.SetSecondPassCallback(FreeObject); 27 } 28 29 CJS_Object::CJS_Object(v8::Local<v8::Object> pObject) { 30 m_pIsolate = pObject->GetIsolate(); 31 m_pV8Object.Reset(m_pIsolate, pObject); 32 } 33 34 CJS_Object::~CJS_Object() {} 35 36 void CJS_Object::MakeWeak() { 37 m_pV8Object.SetWeak(this, DisposeObject, 38 v8::WeakCallbackType::kInternalFields); 39 } 40 41 void CJS_Object::Dispose() { 42 m_pV8Object.Reset(); 43 } 44 45 void CJS_Object::InitInstance(IJS_Runtime* pIRuntime) {} 46