diff options
author | Jochen Eisinger <jochen@chromium.org> | 2015-05-19 00:38:00 +0200 |
---|---|---|
committer | Jochen Eisinger <jochen@chromium.org> | 2015-05-19 00:38:00 +0200 |
commit | dfa2c9939a85ad1c01ef858b21942ab3773dcf27 (patch) | |
tree | 064ae26fd633fe7ffcc6c72ce59bd2cfdd429246 /fpdfsdk/src/javascript | |
parent | 34d839653f3c7a821dadb8e3219f9a8da83d83e6 (diff) | |
download | pdfium-dfa2c9939a85ad1c01ef858b21942ab3773dcf27.tar.xz |
Merge V8 API updates to xfa branch
Set pointers in internal fields directly instead of wrapping them
Review URL: https://codereview.chromium.org/1139853003
Use phantom handles instead of weak handles
Review URL: https://codereview.chromium.org/1129253004
Replace deprecated with non-deprecated V8 APIs
Review URL: https://codereview.chromium.org/1126203010
Add myself to OWNERS file
Review URL: https://codereview.chromium.org/1133333005
Replace v8::Handle with v8::Local and v8::Persistent with v8::Global
Review URL: https://codereview.chromium.org/1138823004
TBR=tsepez@chromium.org
BUG=
Review URL: https://codereview.chromium.org/1140033004
Diffstat (limited to 'fpdfsdk/src/javascript')
-rw-r--r-- | fpdfsdk/src/javascript/Document.cpp | 6 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_Object.cpp | 27 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_Runtime.cpp | 6 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_Value.cpp | 67 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/app.cpp | 6 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/global.cpp | 45 |
6 files changed, 83 insertions, 74 deletions
diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp index 6396095ede..c4a93ede61 100644 --- a/fpdfsdk/src/javascript/Document.cpp +++ b/fpdfsdk/src/javascript/Document.cpp @@ -663,7 +663,7 @@ FX_BOOL Document::submitForm(IFXJS_Context* cc, const CJS_Parameters& params, CJ else if (v.GetType() == VT_object) { JSObject pObj = params[0].ToV8Object(); - v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate, pObj, L"cURL"); + v8::Local<v8::Value> pValue = JS_GetObjectElement(isolate, pObj, L"cURL"); if (!pValue.IsEmpty()) strURL = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); pValue = JS_GetObjectElement(isolate, pObj, L"bFDF"); @@ -796,7 +796,7 @@ FX_BOOL Document::mailDoc(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V { JSObject pObj = params[0].ToV8Object(); - v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj, L"bUI"); + v8::Local<v8::Value> pValue = JS_GetObjectElement(isolate,pObj, L"bUI"); bUI = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToInt(); pValue = JS_GetObjectElement(isolate,pObj, L"cTo"); @@ -1863,7 +1863,7 @@ FX_BOOL Document::deletePages(IFXJS_Context* cc, const CJS_Parameters& params, C if (params[0].GetType() == VT_object) { JSObject pObj = params[0].ToV8Object(); - v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate, pObj, L"nStart"); + v8::Local<v8::Value> pValue = JS_GetObjectElement(isolate, pObj, L"nStart"); nStart = CJS_Value(m_isolate, pValue, GET_VALUE_TYPE(pValue)).ToInt(); pValue = JS_GetObjectElement(isolate, pObj, L"nEnd"); diff --git a/fpdfsdk/src/javascript/JS_Object.cpp b/fpdfsdk/src/javascript/JS_Object.cpp index 44978fa421..96c5307e63 100644 --- a/fpdfsdk/src/javascript/JS_Object.cpp +++ b/fpdfsdk/src/javascript/JS_Object.cpp @@ -88,16 +88,19 @@ void CJS_EmbedObj::EndTimer(CJS_Timer* pTimer) } /* --------------------------------- CJS_Object --------------------------------- */ -void FreeObject(const v8::WeakCallbackData<v8::Object, CJS_Object>& data) +void FreeObject(const v8::WeakCallbackInfo<CJS_Object>& data) { CJS_Object* pJSObj = data.GetParameter(); - if(pJSObj) - { - pJSObj->ExitInstance(); - delete pJSObj; - } - v8::Local<v8::Object> obj = data.GetValue(); - JS_FreePrivate(obj); + pJSObj->ExitInstance(); + delete pJSObj; + JS_FreePrivate(data.GetInternalField(0)); +} + +void DisposeObject(const v8::WeakCallbackInfo<CJS_Object>& data) +{ + CJS_Object* pJSObj = data.GetParameter(); + pJSObj->Dispose(); + data.SetSecondPassCallback(FreeObject); } CJS_Object::CJS_Object(JSFXObject pObject) :m_pEmbedObj(NULL) @@ -117,7 +120,13 @@ CJS_Object::~CJS_Object(void) void CJS_Object::MakeWeak() { - m_pObject.SetWeak(this, FreeObject); + m_pObject.SetWeak( + this, DisposeObject, v8::WeakCallbackType::kInternalFields); +} + +void CJS_Object::Dispose() +{ + m_pObject.Reset(); } CPDFSDK_PageView* CJS_Object::JSGetPageView(IFXJS_Context* cc) diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp index 2ad5667b2e..f3d7cf3972 100644 --- a/fpdfsdk/src/javascript/JS_Runtime.cpp +++ b/fpdfsdk/src/javascript/JS_Runtime.cpp @@ -106,7 +106,7 @@ void CJS_ArrayBufferAllocator::Free(void* data, size_t length) { } /* ------------------------------ CJS_Runtime ------------------------------ */ -extern v8::Persistent<v8::ObjectTemplate>& _getGlobalObjectTemplate(IJS_Runtime* pJSRuntime); +extern v8::Global<v8::ObjectTemplate>& _getGlobalObjectTemplate(IJS_Runtime* pJSRuntime); CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) : m_pApp(pApp), m_pDocument(NULL), @@ -168,7 +168,7 @@ FX_BOOL CJS_Runtime::InitJSObjects() v8::Isolate::Scope isolate_scope(GetIsolate()); v8::Locker locker(GetIsolate()); v8::HandleScope handle_scope(GetIsolate()); - v8::Handle<v8::Context> context = v8::Context::New(GetIsolate()); + v8::Local<v8::Context> context = v8::Context::New(GetIsolate()); v8::Context::Scope context_scope(context); //0 - 8 if (CJS_Border::Init(*this, JS_STATIC) < 0) return FALSE; @@ -348,7 +348,7 @@ void CJS_Runtime::RemoveEventsInLoop(CJS_FieldEvent* pStart) } } -v8::Handle<v8::Context> CJS_Runtime::NewJSContext() +v8::Local<v8::Context> CJS_Runtime::NewJSContext() { return v8::Local<v8::Context>::New(m_isolate, m_context); } diff --git a/fpdfsdk/src/javascript/JS_Value.cpp b/fpdfsdk/src/javascript/JS_Value.cpp index 1b36f314ca..0943802508 100644 --- a/fpdfsdk/src/javascript/JS_Value.cpp +++ b/fpdfsdk/src/javascript/JS_Value.cpp @@ -15,7 +15,7 @@ CJS_Value::CJS_Value(v8::Isolate* isolate) : m_eType(VT_unknown),m_isolate(isolate) { } -CJS_Value::CJS_Value(v8::Isolate* isolate, v8::Handle<v8::Value> pValue,FXJSVALUETYPE t) : +CJS_Value::CJS_Value(v8::Isolate* isolate, v8::Local<v8::Value> pValue,FXJSVALUETYPE t) : m_pValue(pValue), m_eType(t), m_isolate(isolate) { } @@ -76,7 +76,7 @@ CJS_Value::~CJS_Value() { } -void CJS_Value::Attach(v8::Handle<v8::Value> pValue,FXJSVALUETYPE t) +void CJS_Value::Attach(v8::Local<v8::Value> pValue,FXJSVALUETYPE t) { m_pValue = pValue; m_eType = t; @@ -90,7 +90,7 @@ void CJS_Value::Attach(CJS_Value *pValue) void CJS_Value::Detach() { - m_pValue = v8::Handle<v8::Value>(); + m_pValue = v8::Local<v8::Value>(); m_eType = VT_unknown; } @@ -98,17 +98,17 @@ void CJS_Value::Detach() int CJS_Value::ToInt() const { - return JS_ToInt32(m_pValue); + return JS_ToInt32(m_isolate, m_pValue); } bool CJS_Value::ToBool() const { - return JS_ToBoolean(m_pValue); + return JS_ToBoolean(m_isolate, m_pValue); } double CJS_Value::ToDouble() const { - return JS_ToNumber(m_pValue); + return JS_ToNumber(m_isolate, m_pValue); } float CJS_Value::ToFloat() const @@ -118,18 +118,18 @@ float CJS_Value::ToFloat() const CJS_Object* CJS_Value::ToCJSObject() const { - v8::Handle<v8::Object> pObj = JS_ToObject(m_pValue); + v8::Local<v8::Object> pObj = JS_ToObject(m_isolate, m_pValue); return (CJS_Object*)JS_GetPrivate(m_isolate, pObj); } -v8::Handle<v8::Object> CJS_Value::ToV8Object() const +v8::Local<v8::Object> CJS_Value::ToV8Object() const { - return JS_ToObject(m_pValue); + return JS_ToObject(m_isolate, m_pValue); } CFX_WideString CJS_Value::ToCFXWideString() const { - return JS_ToString(m_pValue); + return JS_ToString(m_isolate, m_pValue); } CFX_ByteString CJS_Value::ToCFXByteString() const @@ -137,16 +137,16 @@ CFX_ByteString CJS_Value::ToCFXByteString() const return CFX_ByteString::FromUnicode(ToCFXWideString()); } -v8::Handle<v8::Value> CJS_Value::ToV8Value() const +v8::Local<v8::Value> CJS_Value::ToV8Value() const { return m_pValue; } -v8::Handle<v8::Array>CJS_Value::ToV8Array() const +v8::Local<v8::Array>CJS_Value::ToV8Array() const { if (IsArrayObject()) - return v8::Handle<v8::Array>::Cast(JS_ToObject(m_pValue)); - return v8::Handle<v8::Array>(); + return v8::Local<v8::Array>::Cast(JS_ToObject(m_isolate, m_pValue)); + return v8::Local<v8::Array>(); } /* ---------------------------------------------------------------------------------------- */ @@ -178,7 +178,7 @@ void CJS_Value::operator = (float fValue) m_eType = VT_number; } -void CJS_Value::operator =(v8::Handle<v8::Object> pObj) +void CJS_Value::operator =(v8::Local<v8::Object> pObj) { m_pValue = JS_NewObject(m_isolate,pObj); @@ -221,7 +221,7 @@ void CJS_Value::operator = (FX_LPCSTR pStr) void CJS_Value::operator = (CJS_Array & array) { - m_pValue = JS_NewObject2(m_isolate,(v8::Handle<v8::Array>)array); + m_pValue = JS_NewObject2(m_isolate,(v8::Local<v8::Array>)array); m_eType = VT_object; } @@ -238,6 +238,7 @@ void CJS_Value::operator = (CJS_Value value) m_pValue = value.ToV8Value(); m_eType = value.m_eType; + m_isolate = value.m_isolate; } /* ---------------------------------------------------------------------------------------- */ @@ -272,7 +273,7 @@ FX_BOOL CJS_Value::ConvertToArray(CJS_Array &array) const { if (IsArrayObject()) { - array.Attach(JS_ToArray(m_pValue)); + array.Attach(JS_ToArray(m_isolate, m_pValue)); return TRUE; } @@ -460,7 +461,7 @@ void CJS_PropValue::operator<<(CJS_Date &date) CJS_Value::operator=(date); } -CJS_PropValue::operator v8::Handle<v8::Value>() const +CJS_PropValue::operator v8::Local<v8::Value>() const { return m_pValue; } @@ -474,7 +475,7 @@ CJS_Array::~CJS_Array() { } -void CJS_Array::Attach(v8::Handle<v8::Array> pArray) +void CJS_Array::Attach(v8::Local<v8::Array> pArray) { m_pArray = pArray; } @@ -488,7 +489,7 @@ void CJS_Array::GetElement(unsigned index,CJS_Value &value) { if (m_pArray.IsEmpty()) return; - v8::Handle<v8::Value> p = JS_GetArrayElemnet(m_pArray,index); + v8::Local<v8::Value> p = JS_GetArrayElement(m_isolate, m_pArray,index); value.Attach(p,VT_object); } @@ -497,7 +498,7 @@ void CJS_Array::SetElement(unsigned index,CJS_Value value) if (m_pArray.IsEmpty()) m_pArray = JS_NewArray(m_isolate); - JS_PutArrayElement(m_pArray, index, value.ToV8Value(), value.GetType()); + JS_PutArrayElement(m_isolate, m_pArray, index, value.ToV8Value(), value.GetType()); } int CJS_Array::GetLength() @@ -507,7 +508,7 @@ int CJS_Array::GetLength() return JS_GetArrayLength(m_pArray); } -CJS_Array:: operator v8::Handle<v8::Array>() +CJS_Array:: operator v8::Local<v8::Array>() { if (m_pArray.IsEmpty()) m_pArray = JS_NewArray(m_isolate); @@ -545,10 +546,10 @@ CJS_Date::~CJS_Date() FX_BOOL CJS_Date::IsValidDate() { if(m_pDate.IsEmpty()) return FALSE; - return !JS_PortIsNan(JS_ToNumber(m_pDate)); + return !JS_PortIsNan(JS_ToNumber(m_isolate, m_pDate)); } -void CJS_Date::Attach(v8::Handle<v8::Value> pDate) +void CJS_Date::Attach(v8::Local<v8::Value> pDate) { m_pDate = pDate; } @@ -556,7 +557,7 @@ void CJS_Date::Attach(v8::Handle<v8::Value> pDate) int CJS_Date::GetYear() { if (IsValidDate()) - return JS_GetYearFromTime(JS_LocalTime(JS_ToNumber(m_pDate))); + return JS_GetYearFromTime(JS_LocalTime(JS_ToNumber(m_isolate, m_pDate))); return 0; } @@ -570,7 +571,7 @@ void CJS_Date::SetYear(int iYear) int CJS_Date::GetMonth() { if (IsValidDate()) - return JS_GetMonthFromTime(JS_LocalTime(JS_ToNumber(m_pDate))); + return JS_GetMonthFromTime(JS_LocalTime(JS_ToNumber(m_isolate, m_pDate))); return 0; } @@ -586,7 +587,7 @@ void CJS_Date::SetMonth(int iMonth) int CJS_Date::GetDay() { if (IsValidDate()) - return JS_GetDayFromTime(JS_LocalTime(JS_ToNumber(m_pDate))); + return JS_GetDayFromTime(JS_LocalTime(JS_ToNumber(m_isolate, m_pDate))); return 0; } @@ -602,7 +603,7 @@ void CJS_Date::SetDay(int iDay) int CJS_Date::GetHours() { if (IsValidDate()) - return JS_GetHourFromTime(JS_LocalTime(JS_ToNumber(m_pDate))); + return JS_GetHourFromTime(JS_LocalTime(JS_ToNumber(m_isolate, m_pDate))); return 0; } @@ -616,7 +617,7 @@ void CJS_Date::SetHours(int iHours) int CJS_Date::GetMinutes() { if (IsValidDate()) - return JS_GetMinFromTime(JS_LocalTime(JS_ToNumber(m_pDate))); + return JS_GetMinFromTime(JS_LocalTime(JS_ToNumber(m_isolate, m_pDate))); return 0; } @@ -630,7 +631,7 @@ void CJS_Date::SetMinutes(int minutes) int CJS_Date::GetSeconds() { if (IsValidDate()) - return JS_GetSecFromTime(JS_LocalTime(JS_ToNumber(m_pDate))); + return JS_GetSecFromTime(JS_LocalTime(JS_ToNumber(m_isolate, m_pDate))); return 0; } @@ -641,7 +642,7 @@ void CJS_Date::SetSeconds(int seconds) JS_ValueCopy(m_pDate,JS_NewDate(m_isolate,date)); } -CJS_Date::operator v8::Handle<v8::Value>() +CJS_Date::operator v8::Local<v8::Value>() { return m_pDate; } @@ -650,12 +651,12 @@ CJS_Date::operator double() const { if(m_pDate.IsEmpty()) return 0.0; - return JS_ToNumber(m_pDate); + return JS_ToNumber(m_isolate, m_pDate); } CFX_WideString CJS_Date::ToString() const { if(m_pDate.IsEmpty()) return L""; - return JS_ToString(m_pDate); + return JS_ToString(m_isolate, m_pDate); } diff --git a/fpdfsdk/src/javascript/app.cpp b/fpdfsdk/src/javascript/app.cpp index f975238c81..adcb7c6281 100644 --- a/fpdfsdk/src/javascript/app.cpp +++ b/fpdfsdk/src/javascript/app.cpp @@ -340,7 +340,7 @@ FX_BOOL app::alert(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& v { JSObject pObj = params[0].ToV8Object(); { - v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate, pObj, L"cMsg"); + v8::Local<v8::Value> pValue = JS_GetObjectElement(isolate, pObj, L"cMsg"); swMsg = CJS_Value(isolate, pValue, VT_unknown).ToCFXWideString(); pValue = JS_GetObjectElement(isolate, pObj, L"cTitle"); @@ -728,7 +728,7 @@ FX_BOOL app::mailMsg(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& { JSObject pObj = params[0].ToV8Object(); - v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate, pObj, L"bUI"); + v8::Local<v8::Value> pValue = JS_GetObjectElement(isolate, pObj, L"bUI"); bUI = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool(); pValue = JS_GetObjectElement(isolate, pObj, L"cTo"); @@ -862,7 +862,7 @@ FX_BOOL app::response(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value if (iLength > 0 && params[0].GetType() == VT_object) { JSObject pObj = params[0].ToV8Object(); - v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj,L"cQuestion"); + v8::Local<v8::Value> pValue = JS_GetObjectElement(isolate,pObj,L"cQuestion"); swQuestion = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).ToCFXWideString(); pValue = JS_GetObjectElement(isolate,pObj,L"cTitle"); diff --git a/fpdfsdk/src/javascript/global.cpp b/fpdfsdk/src/javascript/global.cpp index 45b9248155..daf5a85ffe 100644 --- a/fpdfsdk/src/javascript/global.cpp +++ b/fpdfsdk/src/javascript/global.cpp @@ -169,19 +169,19 @@ FX_BOOL global_alternate::DoProperty(IFXJS_Context* cc, FX_LPCWSTR propname, CJS { double dData; vp >> dData; - return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_NUMBER, dData, false, "", v8::Handle<v8::Object>(), FALSE); + return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_NUMBER, dData, false, "", v8::Local<v8::Object>(), FALSE); } case VT_boolean: { bool bData; vp >> bData; - return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_BOOLEAN, 0, bData, "", v8::Handle<v8::Object>(), FALSE); + return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_BOOLEAN, 0, bData, "", v8::Local<v8::Object>(), FALSE); } case VT_string: { CFX_ByteString sData; vp >> sData; - return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_STRING, 0, false, sData, v8::Handle<v8::Object>(), FALSE); + return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_STRING, 0, false, sData, v8::Local<v8::Object>(), FALSE); } case VT_object: { @@ -191,7 +191,7 @@ FX_BOOL global_alternate::DoProperty(IFXJS_Context* cc, FX_LPCWSTR propname, CJS } case VT_null: { - return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_NULL, 0, false, "", v8::Handle<v8::Object>(), FALSE); + return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_NULL, 0, false, "", v8::Local<v8::Object>(), FALSE); } case VT_undefined: { @@ -226,7 +226,7 @@ FX_BOOL global_alternate::DoProperty(IFXJS_Context* cc, FX_LPCWSTR propname, CJS break; case JS_GLOBALDATA_TYPE_OBJECT: { - v8::Handle<v8::Object> obj = v8::Local<v8::Object>::New(vp.GetIsolate(),pData->pData); + v8::Local<v8::Object> obj = v8::Local<v8::Object>::New(vp.GetIsolate(),pData->pData); vp << obj; break; } @@ -296,17 +296,17 @@ void global_alternate::UpdateGlobalPersistentVariables() switch (pData->data.nType) { case JS_GLOBALDATA_TYPE_NUMBER: - this->SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_NUMBER, pData->data.dData, false, "", v8::Handle<v8::Object>(), pData->bPersistent == 1); + this->SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_NUMBER, pData->data.dData, false, "", v8::Local<v8::Object>(), pData->bPersistent == 1); JS_PutObjectNumber(NULL,(JSFXObject)(*m_pJSObject), pData->data.sKey.UTF8Decode().c_str(), pData->data.dData); break; case JS_GLOBALDATA_TYPE_BOOLEAN: - this->SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_BOOLEAN, 0, (bool)(pData->data.bData == 1), "", v8::Handle<v8::Object>(), pData->bPersistent == 1); + this->SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_BOOLEAN, 0, (bool)(pData->data.bData == 1), "", v8::Local<v8::Object>(), pData->bPersistent == 1); JS_PutObjectBoolean(NULL,(JSFXObject)(*m_pJSObject), pData->data.sKey.UTF8Decode().c_str(), (bool)(pData->data.bData == 1)); break; case JS_GLOBALDATA_TYPE_STRING: - this->SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_STRING, 0, false, pData->data.sData, v8::Handle<v8::Object>(), pData->bPersistent == 1); + this->SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_STRING, 0, false, pData->data.sData, v8::Local<v8::Object>(), pData->bPersistent == 1); JS_PutObjectString(NULL, (JSFXObject)(*m_pJSObject), pData->data.sKey.UTF8Decode().c_str(), pData->data.sData.UTF8Decode().c_str()); @@ -314,7 +314,7 @@ void global_alternate::UpdateGlobalPersistentVariables() case JS_GLOBALDATA_TYPE_OBJECT: { IJS_Runtime* pRuntime = JS_GetRuntime((JSFXObject)(*m_pJSObject)); - v8::Handle<v8::Object> pObj = JS_NewFxDynamicObj(pRuntime, NULL, -1); + v8::Local<v8::Object> pObj = JS_NewFxDynamicObj(pRuntime, NULL, -1); PutObjectProperty(pObj, &pData->data); @@ -325,7 +325,7 @@ void global_alternate::UpdateGlobalPersistentVariables() } break; case JS_GLOBALDATA_TYPE_NULL: - this->SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_NULL, 0, false, "", v8::Handle<v8::Object>(), pData->bPersistent == 1); + this->SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_NULL, 0, false, "", v8::Local<v8::Object>(), pData->bPersistent == 1); JS_PutObjectNull(NULL,(JSFXObject)(*m_pJSObject), pData->data.sKey.UTF8Decode().c_str()); break; @@ -370,7 +370,7 @@ void global_alternate::CommitGlobalPersisitentVariables() //if (pData->pData) { CJS_GlobalVariableArray array; - v8::Handle<v8::Object> obj = v8::Local<v8::Object>::New(GetJSObject()->GetIsolate(),pData->pData); + v8::Local<v8::Object> obj = v8::Local<v8::Object>::New(GetJSObject()->GetIsolate(),pData->pData); ObjectToArray(obj, array); m_pGlobalData->SetGlobalVariableObject(name, array); m_pGlobalData->SetGlobalVariablePersistent(name, pData->bPersistent); @@ -386,21 +386,20 @@ void global_alternate::CommitGlobalPersisitentVariables() } } -void global_alternate::ObjectToArray(v8::Handle<v8::Object> pObj, CJS_GlobalVariableArray& array) +void global_alternate::ObjectToArray(v8::Local<v8::Object> pObj, CJS_GlobalVariableArray& array) { - v8::Handle<v8::Array> pKeyList = JS_GetObjectElementNames(pObj); - int nObjElements = pKeyList->Length(); - v8::Local<v8::Context> context = pObj->CreationContext(); v8::Isolate* isolate = context->GetIsolate(); + v8::Local<v8::Array> pKeyList = JS_GetObjectElementNames(isolate, pObj); + int nObjElements = pKeyList->Length(); for (int i=0; i<nObjElements; i++) { - CFX_WideString ws = JS_ToString(JS_GetArrayElemnet(pKeyList, i)); + CFX_WideString ws = JS_ToString(isolate, JS_GetArrayElement(isolate, pKeyList, i)); CFX_ByteString sKey = ws.UTF8Encode(); - v8::Handle<v8::Value> v = JS_GetObjectElement(isolate, pObj, ws.c_str()); + v8::Local<v8::Value> v = JS_GetObjectElement(isolate, pObj, ws.c_str()); FXJSVALUETYPE vt = GET_VALUE_TYPE(v); switch (vt) { @@ -409,7 +408,7 @@ void global_alternate::ObjectToArray(v8::Handle<v8::Object> pObj, CJS_GlobalVari CJS_KeyValue* pObjElement = new CJS_KeyValue; pObjElement->nType = JS_GLOBALDATA_TYPE_NUMBER; pObjElement->sKey = sKey; - pObjElement->dData = JS_ToNumber(v); + pObjElement->dData = JS_ToNumber(isolate, v); array.Add(pObjElement); } break; @@ -418,7 +417,7 @@ void global_alternate::ObjectToArray(v8::Handle<v8::Object> pObj, CJS_GlobalVari CJS_KeyValue* pObjElement = new CJS_KeyValue; pObjElement->nType = JS_GLOBALDATA_TYPE_BOOLEAN; pObjElement->sKey = sKey; - pObjElement->dData = JS_ToBoolean(v); + pObjElement->dData = JS_ToBoolean(isolate, v); array.Add(pObjElement); } break; @@ -437,7 +436,7 @@ void global_alternate::ObjectToArray(v8::Handle<v8::Object> pObj, CJS_GlobalVari CJS_KeyValue* pObjElement = new CJS_KeyValue; pObjElement->nType = JS_GLOBALDATA_TYPE_OBJECT; pObjElement->sKey = sKey; - ObjectToArray(JS_ToObject(v), pObjElement->objData); + ObjectToArray(JS_ToObject(isolate, v), pObjElement->objData); array.Add(pObjElement); } break; @@ -455,7 +454,7 @@ void global_alternate::ObjectToArray(v8::Handle<v8::Object> pObj, CJS_GlobalVari } } -void global_alternate::PutObjectProperty(v8::Handle<v8::Object> pObj, CJS_KeyValue* pData) +void global_alternate::PutObjectProperty(v8::Local<v8::Object> pObj, CJS_KeyValue* pData) { ASSERT(pData != NULL); @@ -478,7 +477,7 @@ void global_alternate::PutObjectProperty(v8::Handle<v8::Object> pObj, CJS_KeyVal case JS_GLOBALDATA_TYPE_OBJECT: { IJS_Runtime* pRuntime = JS_GetRuntime((JSFXObject)(*m_pJSObject)); - v8::Handle<v8::Object> pNewObj = JS_NewFxDynamicObj(pRuntime, NULL, -1); + v8::Local<v8::Object> pNewObj = JS_NewFxDynamicObj(pRuntime, NULL, -1); PutObjectProperty(pNewObj, pObjData); JS_PutObjectObject(NULL, (JSObject)pObj, pObjData->sKey.UTF8Decode().c_str(), (JSObject)pNewObj); } @@ -608,7 +607,7 @@ FX_BOOL global_alternate::SetGlobalVariables(FX_LPCSTR propname, int nType, return TRUE; } -FXJSVALUETYPE GET_VALUE_TYPE(v8::Handle<v8::Value> p) +FXJSVALUETYPE GET_VALUE_TYPE(v8::Local<v8::Value> p) { const unsigned int nHash = JS_CalcHash(JS_GetTypeof(p)); |