From dfa2c9939a85ad1c01ef858b21942ab3773dcf27 Mon Sep 17 00:00:00 2001 From: Jochen Eisinger Date: Tue, 19 May 2015 00:38:00 +0200 Subject: 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 --- xfa/src/fxjse/src/class.cpp | 6 +++--- xfa/src/fxjse/src/class.h | 4 ++-- xfa/src/fxjse/src/context.cpp | 10 +++++----- xfa/src/fxjse/src/context.h | 4 ++-- xfa/src/fxjse/src/dynprop.cpp | 4 ++-- xfa/src/fxjse/src/runtime.h | 4 ++-- xfa/src/fxjse/src/util_inline.h | 2 +- xfa/src/fxjse/src/value.cpp | 12 ++++++------ xfa/src/fxjse/src/value.h | 4 ++-- 9 files changed, 25 insertions(+), 25 deletions(-) (limited to 'xfa/src') diff --git a/xfa/src/fxjse/src/class.cpp b/xfa/src/fxjse/src/class.cpp index 326e8d47c2..e29d4ce306 100644 --- a/xfa/src/fxjse/src/class.cpp +++ b/xfa/src/fxjse/src/class.cpp @@ -21,7 +21,7 @@ void FXJSE_DefineFunctions(FXJSE_HCONTEXT hContext, const FXJSE_FUNCTION* lpFunc ASSERT(lpContext); CFXJSE_ScopeUtil_IsolateHandleContext scope(lpContext); v8::Isolate *pIsolate = lpContext->GetRuntime(); - v8::Handle hGlobalObject = FXJSE_GetGlobalObjectFromContext(scope.GetLocalContext()); + v8::Local hGlobalObject = FXJSE_GetGlobalObjectFromContext(scope.GetLocalContext()); for(FX_INT32 i = 0; i < nNum; i++) { hGlobalObject->ForceSet(v8::String::NewFromUtf8(pIsolate, lpFunctions[i].name), v8::Function::New(pIsolate, FXJSE_V8FunctionCallback_Wrapper, v8::External::New(pIsolate, const_cast(lpFunctions + i))), @@ -164,14 +164,14 @@ FX_FLOAT CFXJSE_Arguments::GetFloat(FX_INT32 index) const CFX_ByteString CFXJSE_Arguments::GetUTF8String(FX_INT32 index) const { const CFXJSE_ArgumentsImpl* lpArguments = reinterpret_cast(this); - v8::Handle hString = (*lpArguments->m_pInfo)[index]->ToString(); + v8::Local hString = (*lpArguments->m_pInfo)[index]->ToString(); v8::String::Utf8Value szStringVal(hString); return CFX_ByteString(*szStringVal); } FX_LPVOID CFXJSE_Arguments::GetObject(FX_INT32 index, FXJSE_HCLASS hClass ) const { const CFXJSE_ArgumentsImpl* lpArguments = reinterpret_cast(this); - v8::Handle hValue = (*lpArguments->m_pInfo)[index]; + v8::Local hValue = (*lpArguments->m_pInfo)[index]; ASSERT(!hValue.IsEmpty()); if(!hValue->IsObject()) { return NULL; diff --git a/xfa/src/fxjse/src/class.h b/xfa/src/fxjse/src/class.h index 26ebb91bfa..f8cdc34022 100644 --- a/xfa/src/fxjse/src/class.h +++ b/xfa/src/fxjse/src/class.h @@ -17,7 +17,7 @@ public: { return m_pContext; } - inline v8::Persistent& GetTemplate() + inline v8::Global& GetTemplate() { return m_hTemplate; } @@ -29,7 +29,7 @@ public: protected: CFX_ByteString m_szClassName; CFXJSE_Context* m_pContext; - v8::Persistent m_hTemplate; + v8::Global m_hTemplate; friend class CFXJSE_Context; friend class CFXJSE_Value; }; diff --git a/xfa/src/fxjse/src/context.cpp b/xfa/src/fxjse/src/context.cpp index f2d979ee55..d78729fc35 100644 --- a/xfa/src/fxjse/src/context.cpp +++ b/xfa/src/fxjse/src/context.cpp @@ -63,12 +63,12 @@ FX_BOOL FXJSE_ExecuteScript(FXJSE_HCONTEXT hContext, FX_LPCSTR szScript, FXJSE_H ASSERT(pContext); return pContext->ExecuteScript(szScript, reinterpret_cast(hRetValue), reinterpret_cast(hNewThisObject)); } -v8::Handle FXJSE_CreateReturnValue(v8::Isolate* pIsolate, v8::TryCatch& trycatch) +v8::Local FXJSE_CreateReturnValue(v8::Isolate* pIsolate, v8::TryCatch& trycatch) { - v8::Handle hReturnValue = v8::Object::New(pIsolate); + v8::Local hReturnValue = v8::Object::New(pIsolate); if (trycatch.HasCaught()) { - v8::Handle hException = trycatch.Exception(); - v8::Handle hMessage = trycatch.Message(); + v8::Local hException = trycatch.Exception(); + v8::Local hMessage = trycatch.Message(); if (hException->IsObject()) { v8::Local hValue; hValue = hException.As()->Get(v8::String::NewFromUtf8(pIsolate, "name")); @@ -207,7 +207,7 @@ FX_BOOL CFXJSE_Context::ExecuteScript(FX_LPCSTR szScript, CFXJSE_Value* lpRetVal ASSERT(hWrapperValue->IsFunction()); v8::Local hWrapperFn = hWrapperValue.As(); if(!trycatch.HasCaught()) { - v8::Handle rgArgs[] = {hScriptString}; + v8::Local rgArgs[] = {hScriptString}; v8::Local hValue = hWrapperFn->Call(hNewThis.As(), 1, rgArgs); if(!trycatch.HasCaught()) { if(lpRetValue) { diff --git a/xfa/src/fxjse/src/context.h b/xfa/src/fxjse/src/context.h index 8d3300150f..973536932b 100644 --- a/xfa/src/fxjse/src/context.h +++ b/xfa/src/fxjse/src/context.h @@ -26,12 +26,12 @@ protected: CFXJSE_Context(const CFXJSE_Context&); CFXJSE_Context& operator = (const CFXJSE_Context&); protected: - v8::Persistent m_hContext; + v8::Global m_hContext; v8::Isolate* m_pIsolate; CFX_ArrayTemplate m_rgClasses; friend class CFXJSE_Class; friend class CFXJSE_ScopeUtil_IsolateHandleContext; friend class CFXJSE_ScopeUtil_IsolateHandleRootOrNormalContext; }; -v8::Handle FXJSE_CreateReturnValue(v8::Isolate* pIsolate, v8::TryCatch& trycatch); +v8::Local FXJSE_CreateReturnValue(v8::Isolate* pIsolate, v8::TryCatch& trycatch); #endif diff --git a/xfa/src/fxjse/src/dynprop.cpp b/xfa/src/fxjse/src/dynprop.cpp index fd03dcf6fd..ddc3e20054 100644 --- a/xfa/src/fxjse/src/dynprop.cpp +++ b/xfa/src/fxjse/src/dynprop.cpp @@ -146,7 +146,7 @@ static void FXJSE_V8ProxyCallback_getPropertyDescriptor (const v8::FunctionCall v8::Local fnSource = v8::Script::Compile(v8::String::NewFromUtf8(pIsolate, "(function (o, name) { var fn, x, d; fn = Object.getOwnPropertyDescriptor; x = o; while(x && !(d = fn(x, name))){x = x.__proto__;} return d; })")); v8::Local fn = fnSource->Run().As(); - v8::Handle rgArgs[] = {hChainObj, info[0]}; + v8::Local rgArgs[] = {hChainObj, info[0]}; v8::Local hChainDescriptor = fn->Call(info.This(), 2, rgArgs); if(!hChainDescriptor.IsEmpty() && hChainDescriptor->IsObject()) { info.GetReturnValue().Set(hChainDescriptor); @@ -270,7 +270,7 @@ void CFXJSE_Class::SetUpDynPropHandler(CFXJSE_Context* pContext, CFXJSE_Value* p hTrapper->ForceSet(v8::String::NewFromUtf8(pIsolate, "delete"), v8::Function::New(pIsolate, FXJSE_V8ProxyCallback_delete, v8::External::New(pIsolate, const_cast(lpClassDefinition)))); hTrapper->ForceSet(v8::String::NewFromUtf8(pIsolate, "defineProperty"), v8::Function::New(pIsolate, FXJSE_V8ProxyCallback_defineProperty, v8::External::New(pIsolate, const_cast(lpClassDefinition)))); hTrapper->ForceSet(v8::String::NewFromUtf8(pIsolate, "fix"), v8::Function::New(pIsolate, FXJSE_V8ProxyCallback_fix, v8::External::New(pIsolate, const_cast(lpClassDefinition)))); - v8::Handle rgArgs[] = {hTrapper, hOldPrototype}; + v8::Local rgArgs[] = {hTrapper, hOldPrototype}; v8::Local hNewPrototype = hHarmonyProxyCreateFn->Call(hHarmonyProxyObj, 2, rgArgs); hObject->SetPrototype(hNewPrototype); } diff --git a/xfa/src/fxjse/src/runtime.h b/xfa/src/fxjse/src/runtime.h index 87d540ec9b..a51dc8f3eb 100644 --- a/xfa/src/fxjse/src/runtime.h +++ b/xfa/src/fxjse/src/runtime.h @@ -16,8 +16,8 @@ public: static CFXJSE_RuntimeData* Get(v8::Isolate* pIsolate); public: v8::Isolate* m_pIsolate; - v8::Persistent m_hRootContextGlobalTemplate; - v8::Persistent m_hRootContext; + v8::Global m_hRootContextGlobalTemplate; + v8::Global m_hRootContext; public: static CFXJSE_RuntimeList* g_RuntimeList; protected: diff --git a/xfa/src/fxjse/src/util_inline.h b/xfa/src/fxjse/src/util_inline.h index dddcab3053..517b5545e8 100644 --- a/xfa/src/fxjse/src/util_inline.h +++ b/xfa/src/fxjse/src/util_inline.h @@ -24,7 +24,7 @@ static V8_INLINE FX_LPVOID FXJSE_RetrieveObjectBinding(const v8::Local hObject = hJSObject; if(hObject->InternalFieldCount() == 0) { - v8::Handle hProtoObject = hObject->GetPrototype(); + v8::Local hProtoObject = hObject->GetPrototype(); if(hProtoObject.IsEmpty() || !hProtoObject->IsObject()) { return NULL; } diff --git a/xfa/src/fxjse/src/value.cpp b/xfa/src/fxjse/src/value.cpp index de7e05455b..21939e8747 100644 --- a/xfa/src/fxjse/src/value.cpp +++ b/xfa/src/fxjse/src/value.cpp @@ -254,8 +254,8 @@ void FXJSE_ThrowMessage(FX_BSTR utf8Name, FX_BSTR utf8Message) v8::Isolate* pIsolate = v8::Isolate::GetCurrent(); ASSERT(pIsolate); CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); - v8::Handle hMessage = v8::String::NewFromUtf8(pIsolate, utf8Message.GetCStr(), v8::String::kNormalString, utf8Message.GetLength()); - v8::Handle hError; + v8::Local hMessage = v8::String::NewFromUtf8(pIsolate, utf8Message.GetCStr(), v8::String::kNormalString, utf8Message.GetLength()); + v8::Local hError; if(utf8Name == "RangeError") { hError = v8::Exception::RangeError(hMessage); } else if(utf8Name == "ReferenceError") { @@ -433,7 +433,7 @@ FX_BOOL CFXJSE_Value::SetObjectOwnProperty(FX_BSTR szPropName, CFXJSE_Value* lpP FX_BOOL CFXJSE_Value::SetFunctionBind(CFXJSE_Value* lpOldFunction, CFXJSE_Value* lpNewThis) { CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); - v8::Handle rgArgs[2]; + v8::Local rgArgs[2]; v8::Local hOldFunction = v8::Local::New(m_pIsolate, lpOldFunction->DirectGetValue()); if(hOldFunction.IsEmpty() || !hOldFunction->IsFunction()) { return FALSE; @@ -467,14 +467,14 @@ FX_BOOL CFXJSE_Value::Call(CFXJSE_Value* lpReceiver, CFXJSE_Value* lpRetValue, F return FALSE; } v8::Local hReturnValue; - v8::Handle* lpLocalArgs = NULL; + v8::Local* lpLocalArgs = NULL; if(nArgCount) { - lpLocalArgs = FX_Alloc(v8::Handle, nArgCount); + lpLocalArgs = FX_Alloc(v8::Local, nArgCount); if (!lpLocalArgs) { return FALSE; } for (FX_UINT32 i = 0; i < nArgCount; i++) { - new (lpLocalArgs + i) v8::Handle; + new (lpLocalArgs + i) v8::Local; CFXJSE_Value* lpArg = (CFXJSE_Value*)lpArgs[i]; if(lpArg) { lpLocalArgs[i] = v8::Local::New(m_pIsolate, lpArg->DirectGetValue()); diff --git a/xfa/src/fxjse/src/value.h b/xfa/src/fxjse/src/value.h index eb118fd5c6..547ae9251f 100644 --- a/xfa/src/fxjse/src/value.h +++ b/xfa/src/fxjse/src/value.h @@ -209,7 +209,7 @@ public: { return m_pIsolate; } - V8_INLINE const v8::Persistent& DirectGetValue() const + V8_INLINE const v8::Global& DirectGetValue() const { return m_hValue; } @@ -229,7 +229,7 @@ public: static CFXJSE_Value* Create(v8::Isolate* pIsolate); protected: v8::Isolate* m_pIsolate; - v8::Persistent m_hValue; + v8::Global m_hValue; friend class CFXJSE_Context; friend class CFXJSE_Class; }; -- cgit v1.2.3