From 3fea540931b6b2c700c50809a3d4d8a506f4f797 Mon Sep 17 00:00:00 2001 From: Jochen Eisinger Date: Tue, 19 May 2015 00:33:06 +0200 Subject: Replace v8::Handle with v8::Local and v8::Persistent with v8::Global those types are just aliases, and we should consistently use the new version R=tsepez@chromium.org BUG= Review URL: https://codereview.chromium.org/1138823004 --- fpdfsdk/include/javascript/JS_Define.h | 20 ++-- fpdfsdk/include/javascript/JS_Object.h | 2 +- fpdfsdk/include/javascript/JS_Runtime.h | 4 +- fpdfsdk/include/javascript/JS_Value.h | 28 +++--- fpdfsdk/include/javascript/global.h | 6 +- fpdfsdk/include/jsapi/fxjs_v8.h | 112 ++++++++++----------- fpdfsdk/src/javascript/Document.cpp | 6 +- fpdfsdk/src/javascript/JS_Runtime.cpp | 4 +- fpdfsdk/src/javascript/JS_Value.cpp | 34 +++---- fpdfsdk/src/javascript/app.cpp | 6 +- fpdfsdk/src/javascript/global.cpp | 34 +++---- fpdfsdk/src/jsapi/fxjs_v8.cpp | 166 ++++++++++++++++---------------- 12 files changed, 211 insertions(+), 211 deletions(-) diff --git a/fpdfsdk/include/javascript/JS_Define.h b/fpdfsdk/include/javascript/JS_Define.h index 1c3c64e4dd..4fcd50600c 100644 --- a/fpdfsdk/include/javascript/JS_Define.h +++ b/fpdfsdk/include/javascript/JS_Define.h @@ -60,7 +60,7 @@ void JSPropGetter(const char* prop_name_string, v8::Isolate* isolate = info.GetIsolate(); v8::Local context = isolate->GetCurrentContext(); v8::Local v = context->GetEmbedderData(1); - v8::Handle field = v8::Handle::Cast(v); + v8::Local field = v8::Local::Cast(v); IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); IFXJS_Context* pContext = pRuntime->GetCurrentContext(); CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder()); @@ -72,7 +72,7 @@ void JSPropGetter(const char* prop_name_string, JS_Error(isolate, JSFormatErrorString(class_name_string, prop_name_string, sError)); return; } - info.GetReturnValue().Set((v8::Handle)value); + info.GetReturnValue().Set((v8::Local)value); } template @@ -84,7 +84,7 @@ void JSPropSetter(const char* prop_name_string, v8::Isolate* isolate = info.GetIsolate(); v8::Local context = isolate->GetCurrentContext(); v8::Local v = context->GetEmbedderData(1); - v8::Handle field = v8::Handle::Cast(v); + v8::Local field = v8::Local::Cast(v); IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); IFXJS_Context* pContext = pRuntime->GetCurrentContext(); CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder()); @@ -121,7 +121,7 @@ void JSMethod(const char* method_name_string, v8::Isolate* isolate = info.GetIsolate(); v8::Local context = isolate->GetCurrentContext(); v8::Local v = context->GetEmbedderData(1); - v8::Handle field = v8::Handle::Cast(v); + v8::Local field = v8::Local::Cast(v); IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); IFXJS_Context* cc = pRuntime->GetCurrentContext(); CJS_Parameters parameters; @@ -252,7 +252,7 @@ void JSSpecialPropGet(const char* class_name, v8::Isolate* isolate = info.GetIsolate(); v8::Local context = isolate->GetCurrentContext(); v8::Local v = context->GetEmbedderData(1); - v8::Handle field = v8::Handle::Cast(v); + v8::Local field = v8::Local::Cast(v); IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); CJS_Object* pJSObj = reinterpret_cast(JS_GetPrivate(isolate, info.Holder())); @@ -266,7 +266,7 @@ void JSSpecialPropGet(const char* class_name, JS_Error(isolate, JSFormatErrorString(class_name, "GetProperty", sError)); return; } - info.GetReturnValue().Set((v8::Handle)value); + info.GetReturnValue().Set((v8::Local)value); } template @@ -277,7 +277,7 @@ void JSSpecialPropPut(const char* class_name, v8::Isolate* isolate = info.GetIsolate(); v8::Local context = isolate->GetCurrentContext(); v8::Local v = context->GetEmbedderData(1); - v8::Handle field = v8::Handle::Cast(v); + v8::Local field = v8::Local::Cast(v); IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); CJS_Object* pJSObj = reinterpret_cast(JS_GetPrivate(isolate, info.Holder())); @@ -299,7 +299,7 @@ void JSSpecialPropDel(const char* class_name, v8::Isolate* isolate = info.GetIsolate(); v8::Local context = isolate->GetCurrentContext(); v8::Local v = context->GetEmbedderData(1); - v8::Handle field = v8::Handle::Cast(v); + v8::Local field = v8::Local::Cast(v); IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); CJS_Object* pJSObj = reinterpret_cast(JS_GetPrivate(isolate, info.Holder())); @@ -389,7 +389,7 @@ void JSGlobalFunc(const char *func_name_string, v8::Isolate* isolate = info.GetIsolate(); v8::Local context = isolate->GetCurrentContext(); v8::Local v = context->GetEmbedderData(1); - v8::Handle field = v8::Handle::Cast(v); + v8::Local field = v8::Local::Cast(v); IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value(); IFXJS_Context* cc = pRuntime->GetCurrentContext(); CJS_Parameters parameters; @@ -464,6 +464,6 @@ if (JS_DefineGlobalConst(pRuntime, (const wchar_t*)ArrayName, prop.ToV8Value()) #define VALUE_NAME_NULL L"null" #define VALUE_NAME_UNDEFINED L"undefined" -FXJSVALUETYPE GET_VALUE_TYPE(v8::Handle p); +FXJSVALUETYPE GET_VALUE_TYPE(v8::Local p); #endif //_JS_DEFINE_H_ diff --git a/fpdfsdk/include/javascript/JS_Object.h b/fpdfsdk/include/javascript/JS_Object.h index acbff840f1..a26482db6a 100644 --- a/fpdfsdk/include/javascript/JS_Object.h +++ b/fpdfsdk/include/javascript/JS_Object.h @@ -67,7 +67,7 @@ public: v8::Isolate* GetIsolate() {return m_pIsolate;} protected: CJS_EmbedObj * m_pEmbedObj; - v8::Persistent m_pObject; + v8::Global m_pObject; v8::Isolate* m_pIsolate; }; diff --git a/fpdfsdk/include/javascript/JS_Runtime.h b/fpdfsdk/include/javascript/JS_Runtime.h index 5326db693d..1f51638bf9 100644 --- a/fpdfsdk/include/javascript/JS_Runtime.h +++ b/fpdfsdk/include/javascript/JS_Runtime.h @@ -58,7 +58,7 @@ public: v8::Isolate* GetIsolate(){return m_isolate;}; void SetIsolate(v8::Isolate* isolate){m_isolate = isolate;} - v8::Handle NewJSContext(); + v8::Local NewJSContext(); protected: CFX_ArrayTemplate m_ContextArray; CPDFDoc_Environment* m_pApp; @@ -69,7 +69,7 @@ protected: v8::Isolate* m_isolate; nonstd::unique_ptr m_pArrayBufferAllocator; - v8::Persistent m_context; + v8::Global m_context; }; #endif //_JS_RUNTIME_H_ diff --git a/fpdfsdk/include/javascript/JS_Value.h b/fpdfsdk/include/javascript/JS_Value.h index ecd0f832d4..faa612d21e 100644 --- a/fpdfsdk/include/javascript/JS_Value.h +++ b/fpdfsdk/include/javascript/JS_Value.h @@ -19,7 +19,7 @@ class CJS_Value { public: CJS_Value(v8::Isolate* isolate); - CJS_Value(v8::Isolate* isolate, v8::Handle pValue,FXJSVALUETYPE t); + CJS_Value(v8::Isolate* isolate, v8::Local pValue,FXJSVALUETYPE t); CJS_Value(v8::Isolate* isolate, const int &iValue); CJS_Value(v8::Isolate* isolate, const double &dValue); CJS_Value(v8::Isolate* isolate, const float &fValue); @@ -34,7 +34,7 @@ public: ~CJS_Value(); void SetNull(); - void Attach(v8::Handle pValue,FXJSVALUETYPE t); + void Attach(v8::Local pValue,FXJSVALUETYPE t); void Attach(CJS_Value *pValue); void Detach(); @@ -46,9 +46,9 @@ public: CJS_Object* ToCJSObject() const; CFX_WideString ToCFXWideString() const; CFX_ByteString ToCFXByteString() const; - v8::Handle ToV8Object() const; - v8::Handle ToV8Array() const; - v8::Handle ToV8Value() const; + v8::Local ToV8Object() const; + v8::Local ToV8Array() const; + v8::Local ToV8Value() const; void operator = (int iValue); void operator = (bool bValue); @@ -56,7 +56,7 @@ public: void operator = (float); void operator = (CJS_Object*); void operator = (CJS_Document*); - void operator = (v8::Handle); + void operator = (v8::Local); void operator = (CJS_Array &); void operator = (CJS_Date &); void operator = (FX_LPCWSTR pWstr); @@ -72,7 +72,7 @@ public: v8::Isolate* GetIsolate() {return m_isolate;} protected: - v8::Handle m_pValue; + v8::Local m_pValue; FXJSVALUETYPE m_eType; v8::Isolate* m_isolate; }; @@ -118,7 +118,7 @@ public: void operator<<(CJS_Array& array); void operator<<(CJS_Date& date); void operator>>(CJS_Date& date) const; - operator v8::Handle() const; + operator v8::Local() const; void StartSetting(); void StartGetting(); private: @@ -131,16 +131,16 @@ public: CJS_Array(v8::Isolate* isolate); virtual ~CJS_Array(); - void Attach(v8::Handle pArray); + void Attach(v8::Local pArray); void GetElement(unsigned index,CJS_Value &value); void SetElement(unsigned index,CJS_Value value); int GetLength(); FX_BOOL IsAttached(); - operator v8::Handle(); + operator v8::Local(); v8::Isolate* GetIsolate() {return m_isolate;} private: - v8::Handle m_pArray; + v8::Local m_pArray; v8::Isolate* m_isolate; }; @@ -152,7 +152,7 @@ public: CJS_Date(v8::Isolate* isolate,double dMsec_time); CJS_Date(v8::Isolate* isolate,int year, int mon, int day,int hour, int min, int sec); virtual ~CJS_Date(); - void Attach(v8::Handle pDate); + void Attach(v8::Local pDate); int GetYear(); void SetYear(int iYear); @@ -172,7 +172,7 @@ public: int GetSeconds(); void SetSeconds(int seconds); - operator v8::Handle(); + operator v8::Local(); operator double() const; CFX_WideString ToString() const; @@ -182,7 +182,7 @@ public: FX_BOOL IsValidDate(); protected: - v8::Handle m_pDate; + v8::Local m_pDate; v8::Isolate* m_isolate; }; diff --git a/fpdfsdk/include/javascript/global.h b/fpdfsdk/include/javascript/global.h index 9ee9f42b42..2690f6822c 100644 --- a/fpdfsdk/include/javascript/global.h +++ b/fpdfsdk/include/javascript/global.h @@ -33,7 +33,7 @@ struct js_global_data double dData; bool bData; CFX_ByteString sData; - v8::Persistent pData; + v8::Global pData; bool bPersistent; bool bDeleted; }; @@ -61,8 +61,8 @@ private: FX_BOOL SetGlobalVariables(FX_LPCSTR propname, int nType, double dData, bool bData, const CFX_ByteString& sData, JSObject pData, bool bDefaultPersistent); - void ObjectToArray(v8::Handle pObj, CJS_GlobalVariableArray& array); - void PutObjectProperty(v8::Handle obj, CJS_KeyValue* pData); + void ObjectToArray(v8::Local pObj, CJS_GlobalVariableArray& array); + void PutObjectProperty(v8::Local obj, CJS_KeyValue* pData); private: CFX_MapByteStringToPtr m_mapGlobal; diff --git a/fpdfsdk/include/jsapi/fxjs_v8.h b/fpdfsdk/include/jsapi/fxjs_v8.h index d84b216117..cc1eb6b2c1 100644 --- a/fpdfsdk/include/jsapi/fxjs_v8.h +++ b/fpdfsdk/include/jsapi/fxjs_v8.h @@ -14,8 +14,8 @@ #include "../../../core/include/fxcrt/fx_string.h" // For CFX_WideString typedef v8::Value JSValue; -typedef v8::Handle JSObject; -typedef v8::Handle JSFXObject; +typedef v8::Local JSObject; +typedef v8::Local JSFXObject; enum FXJSOBJTYPE { @@ -49,78 +49,78 @@ typedef v8::Isolate IJS_Runtime; class IFXJS_Context; class IFXJS_Runtime; -typedef void (*LP_CONSTRUCTOR)(IFXJS_Context* cc, v8::Handle obj, v8::Handle global); -typedef void (*LP_DESTRUCTOR)(v8::Handle obj); +typedef void (*LP_CONSTRUCTOR)(IFXJS_Context* cc, v8::Local obj, v8::Local global); +typedef void (*LP_DESTRUCTOR)(v8::Local obj); int JS_DefineObj(IJS_Runtime* pJSRuntime, const wchar_t* sObjName, FXJSOBJTYPE eObjType, LP_CONSTRUCTOR pConstructor, LP_DESTRUCTOR pDestructor, unsigned bApplyNew); int JS_DefineObjMethod(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sMethodName, v8::FunctionCallback pMethodCall); int JS_DefineObjProperty(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sPropName, v8::AccessorGetterCallback pPropGet, v8::AccessorSetterCallback pPropPut); int JS_DefineObjAllProperties(IJS_Runtime* pJSRuntime, int nObjDefnID, v8::NamedPropertyQueryCallback pPropQurey, v8::NamedPropertyGetterCallback pPropGet, v8::NamedPropertySetterCallback pPropPut, v8::NamedPropertyDeleterCallback pPropDel); -int JS_DefineObjConst(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sConstName, v8::Handle pDefault); +int JS_DefineObjConst(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sConstName, v8::Local pDefault); int JS_DefineGlobalMethod(IJS_Runtime* pJSRuntime, const wchar_t* sMethodName, v8::FunctionCallback pMethodCall); -int JS_DefineGlobalConst(IJS_Runtime* pJSRuntime, const wchar_t* sConstName, v8::Handle pDefault); +int JS_DefineGlobalConst(IJS_Runtime* pJSRuntime, const wchar_t* sConstName, v8::Local pDefault); -void JS_InitialRuntime(IJS_Runtime* pJSRuntime,IFXJS_Runtime* pFXRuntime, IFXJS_Context* context, v8::Persistent& v8PersistentContext); -void JS_ReleaseRuntime(IJS_Runtime* pJSRuntime, v8::Persistent& v8PersistentContext); +void JS_InitialRuntime(IJS_Runtime* pJSRuntime,IFXJS_Runtime* pFXRuntime, IFXJS_Context* context, v8::Global& v8PersistentContext); +void JS_ReleaseRuntime(IJS_Runtime* pJSRuntime, v8::Global& v8PersistentContext); void JS_Initial(); void JS_Release(); int JS_Parse(IJS_Runtime* pJSRuntime, IFXJS_Context* pJSContext, const wchar_t* script, long length, FXJSErr* perror); int JS_Execute(IJS_Runtime* pJSRuntime, IFXJS_Context* pJSContext, const wchar_t* script, long length, FXJSErr* perror); -v8::Handle JS_NewFxDynamicObj(IJS_Runtime* pJSRuntime, IFXJS_Context* pJSContext, int nObjDefnID); -v8::Handle JS_GetStaticObj(IJS_Runtime* pJSRuntime, int nObjDefnID); +v8::Local JS_NewFxDynamicObj(IJS_Runtime* pJSRuntime, IFXJS_Context* pJSContext, int nObjDefnID); +v8::Local JS_GetStaticObj(IJS_Runtime* pJSRuntime, int nObjDefnID); void JS_SetThisObj(IJS_Runtime* pJSRuntime, int nThisObjID); -v8::Handle JS_GetThisObj(IJS_Runtime * pJSRuntime); -int JS_GetObjDefnID(v8::Handle pObj); -IJS_Runtime* JS_GetRuntime(v8::Handle pObj); +v8::Local JS_GetThisObj(IJS_Runtime * pJSRuntime); +int JS_GetObjDefnID(v8::Local pObj); +IJS_Runtime* JS_GetRuntime(v8::Local pObj); int JS_GetObjDefnID(IJS_Runtime * pJSRuntime, const wchar_t* pObjName); void JS_Error(v8::Isolate* isolate, const CFX_WideString& message); unsigned JS_CalcHash(const wchar_t* main, unsigned nLen); unsigned JS_CalcHash(const wchar_t* main); -const wchar_t* JS_GetTypeof(v8::Handle pObj); -void JS_SetPrivate(IJS_Runtime* pJSRuntime, v8::Handle pObj, void* p); -void* JS_GetPrivate(IJS_Runtime* pJSRuntime, v8::Handle pObj); -void JS_SetPrivate(v8::Handle pObj, void* p); -void* JS_GetPrivate(v8::Handle pObj); +const wchar_t* JS_GetTypeof(v8::Local pObj); +void JS_SetPrivate(IJS_Runtime* pJSRuntime, v8::Local pObj, void* p); +void* JS_GetPrivate(IJS_Runtime* pJSRuntime, v8::Local pObj); +void JS_SetPrivate(v8::Local pObj, void* p); +void* JS_GetPrivate(v8::Local pObj); void JS_FreePrivate(void* p); -void JS_FreePrivate(v8::Handle pObj); -v8::Handle JS_GetObjectValue(v8::Handle pObj); -v8::Handle JS_GetObjectElement(IJS_Runtime* pJSRuntime, v8::Handle pObj,const wchar_t* PropertyName); -v8::Handle JS_GetObjectElementNames(IJS_Runtime* pJSRuntime, v8::Handle pObj); -void JS_PutObjectString(IJS_Runtime* pJSRuntime,v8::Handle pObj, const wchar_t* PropertyName, const wchar_t* sValue); -void JS_PutObjectNumber(IJS_Runtime* pJSRuntime,v8::Handle pObj, const wchar_t* PropertyName, int nValue); -void JS_PutObjectNumber(IJS_Runtime* pJSRuntime,v8::Handle pObj, const wchar_t* PropertyName, float fValue); -void JS_PutObjectNumber(IJS_Runtime* pJSRuntime,v8::Handle pObj, const wchar_t* PropertyName, double dValue); -void JS_PutObjectBoolean(IJS_Runtime* pJSRuntime,v8::Handle pObj, const wchar_t* PropertyName, bool bValue); -void JS_PutObjectObject(IJS_Runtime* pJSRuntime,v8::Handle pObj, const wchar_t* PropertyName, v8::Handle pPut); -void JS_PutObjectNull(IJS_Runtime* pJSRuntime,v8::Handle pObj, const wchar_t* PropertyName); -unsigned JS_PutArrayElement(IJS_Runtime* pJSRuntime, v8::Handle pArray,unsigned index,v8::Handle pValue,FXJSVALUETYPE eType); -v8::Handle JS_GetArrayElement(IJS_Runtime* pJSRuntime, v8::Handle pArray,unsigned index); -unsigned JS_GetArrayLength(v8::Handle pArray); -v8::Handle JS_GetListValue(IJS_Runtime* pJSRuntime, v8::Handle pList, int index); - - -v8::Handle JS_NewArray(IJS_Runtime* pJSRuntime); -v8::Handle JS_NewNumber(IJS_Runtime* pJSRuntime,int number); -v8::Handle JS_NewNumber(IJS_Runtime* pJSRuntime,double number); -v8::Handle JS_NewNumber(IJS_Runtime* pJSRuntime,float number); -v8::Handle JS_NewBoolean(IJS_Runtime* pJSRuntime,bool b); -v8::Handle JS_NewObject(IJS_Runtime* pJSRuntime,v8::Handle pObj); -v8::Handle JS_NewObject2(IJS_Runtime* pJSRuntime,v8::Handle pObj); -v8::Handle JS_NewString(IJS_Runtime* pJSRuntime,const wchar_t* string); -v8::Handle JS_NewString(IJS_Runtime* pJSRuntime,const wchar_t* string, unsigned nLen); -v8::Handle JS_NewNull(); -v8::Handle JS_NewDate(IJS_Runtime* pJSRuntime,double d); -v8::Handle JS_NewValue(IJS_Runtime* pJSRuntime); - - -int JS_ToInt32(IJS_Runtime* pJSRuntime, v8::Handle pValue); -bool JS_ToBoolean(IJS_Runtime* pJSRuntime, v8::Handle pValue); -double JS_ToNumber(IJS_Runtime* pJSRuntime, v8::Handle pValue); -v8::Handle JS_ToObject(IJS_Runtime* pJSRuntime, v8::Handle pValue); -CFX_WideString JS_ToString(IJS_Runtime* pJSRuntime, v8::Handle pValue); -v8::Handle JS_ToArray(IJS_Runtime* pJSRuntime, v8::Handle pValue); -void JS_ValueCopy(v8::Handle& pTo, v8::Handle pFrom); +void JS_FreePrivate(v8::Local pObj); +v8::Local JS_GetObjectValue(v8::Local pObj); +v8::Local JS_GetObjectElement(IJS_Runtime* pJSRuntime, v8::Local pObj,const wchar_t* PropertyName); +v8::Local JS_GetObjectElementNames(IJS_Runtime* pJSRuntime, v8::Local pObj); +void JS_PutObjectString(IJS_Runtime* pJSRuntime,v8::Local pObj, const wchar_t* PropertyName, const wchar_t* sValue); +void JS_PutObjectNumber(IJS_Runtime* pJSRuntime,v8::Local pObj, const wchar_t* PropertyName, int nValue); +void JS_PutObjectNumber(IJS_Runtime* pJSRuntime,v8::Local pObj, const wchar_t* PropertyName, float fValue); +void JS_PutObjectNumber(IJS_Runtime* pJSRuntime,v8::Local pObj, const wchar_t* PropertyName, double dValue); +void JS_PutObjectBoolean(IJS_Runtime* pJSRuntime,v8::Local pObj, const wchar_t* PropertyName, bool bValue); +void JS_PutObjectObject(IJS_Runtime* pJSRuntime,v8::Local pObj, const wchar_t* PropertyName, v8::Local pPut); +void JS_PutObjectNull(IJS_Runtime* pJSRuntime,v8::Local pObj, const wchar_t* PropertyName); +unsigned JS_PutArrayElement(IJS_Runtime* pJSRuntime, v8::Local pArray,unsigned index,v8::Local pValue,FXJSVALUETYPE eType); +v8::Local JS_GetArrayElement(IJS_Runtime* pJSRuntime, v8::Local pArray,unsigned index); +unsigned JS_GetArrayLength(v8::Local pArray); +v8::Local JS_GetListValue(IJS_Runtime* pJSRuntime, v8::Local pList, int index); + + +v8::Local JS_NewArray(IJS_Runtime* pJSRuntime); +v8::Local JS_NewNumber(IJS_Runtime* pJSRuntime,int number); +v8::Local JS_NewNumber(IJS_Runtime* pJSRuntime,double number); +v8::Local JS_NewNumber(IJS_Runtime* pJSRuntime,float number); +v8::Local JS_NewBoolean(IJS_Runtime* pJSRuntime,bool b); +v8::Local JS_NewObject(IJS_Runtime* pJSRuntime,v8::Local pObj); +v8::Local JS_NewObject2(IJS_Runtime* pJSRuntime,v8::Local pObj); +v8::Local JS_NewString(IJS_Runtime* pJSRuntime,const wchar_t* string); +v8::Local JS_NewString(IJS_Runtime* pJSRuntime,const wchar_t* string, unsigned nLen); +v8::Local JS_NewNull(); +v8::Local JS_NewDate(IJS_Runtime* pJSRuntime,double d); +v8::Local JS_NewValue(IJS_Runtime* pJSRuntime); + + +int JS_ToInt32(IJS_Runtime* pJSRuntime, v8::Local pValue); +bool JS_ToBoolean(IJS_Runtime* pJSRuntime, v8::Local pValue); +double JS_ToNumber(IJS_Runtime* pJSRuntime, v8::Local pValue); +v8::Local JS_ToObject(IJS_Runtime* pJSRuntime, v8::Local pValue); +CFX_WideString JS_ToString(IJS_Runtime* pJSRuntime, v8::Local pValue); +v8::Local JS_ToArray(IJS_Runtime* pJSRuntime, v8::Local pValue); +void JS_ValueCopy(v8::Local& pTo, v8::Local pFrom); double JS_GetDateTime(); int JS_GetYearFromTime(double dt); diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp index be568e10cc..b821f1eca3 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 pValue = JS_GetObjectElement(isolate, pObj, L"cURL"); + v8::Local 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 pValue = JS_GetObjectElement(isolate,pObj, L"bUI"); + v8::Local 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 pValue = JS_GetObjectElement(isolate, pObj, L"nStart"); + v8::Local 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_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp index e2f50067e6..31d61e37c8 100644 --- a/fpdfsdk/src/javascript/JS_Runtime.cpp +++ b/fpdfsdk/src/javascript/JS_Runtime.cpp @@ -149,7 +149,7 @@ FX_BOOL CJS_Runtime::InitJSObjects() { v8::Isolate::Scope isolate_scope(GetIsolate()); v8::HandleScope handle_scope(GetIsolate()); - v8::Handle context = v8::Context::New(GetIsolate()); + v8::Local context = v8::Context::New(GetIsolate()); v8::Context::Scope context_scope(context); //0 - 8 if (CJS_Border::Init(*this, JS_STATIC) < 0) return FALSE; @@ -328,7 +328,7 @@ void CJS_Runtime::RemoveEventsInLoop(CJS_FieldEvent* pStart) } } -v8::Handle CJS_Runtime::NewJSContext() +v8::Local CJS_Runtime::NewJSContext() { return v8::Local::New(m_isolate, m_context); } diff --git a/fpdfsdk/src/javascript/JS_Value.cpp b/fpdfsdk/src/javascript/JS_Value.cpp index d3de6d1719..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 pValue,FXJSVALUETYPE t) : +CJS_Value::CJS_Value(v8::Isolate* isolate, v8::Local 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 pValue,FXJSVALUETYPE t) +void CJS_Value::Attach(v8::Local 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(); + m_pValue = v8::Local(); m_eType = VT_unknown; } @@ -118,11 +118,11 @@ float CJS_Value::ToFloat() const CJS_Object* CJS_Value::ToCJSObject() const { - v8::Handle pObj = JS_ToObject(m_isolate, m_pValue); + v8::Local pObj = JS_ToObject(m_isolate, m_pValue); return (CJS_Object*)JS_GetPrivate(m_isolate, pObj); } -v8::Handle CJS_Value::ToV8Object() const +v8::Local CJS_Value::ToV8Object() const { return JS_ToObject(m_isolate, m_pValue); } @@ -137,16 +137,16 @@ CFX_ByteString CJS_Value::ToCFXByteString() const return CFX_ByteString::FromUnicode(ToCFXWideString()); } -v8::Handle CJS_Value::ToV8Value() const +v8::Local CJS_Value::ToV8Value() const { return m_pValue; } -v8::HandleCJS_Value::ToV8Array() const +v8::LocalCJS_Value::ToV8Array() const { if (IsArrayObject()) - return v8::Handle::Cast(JS_ToObject(m_isolate, m_pValue)); - return v8::Handle(); + return v8::Local::Cast(JS_ToObject(m_isolate, m_pValue)); + return v8::Local(); } /* ---------------------------------------------------------------------------------------- */ @@ -178,7 +178,7 @@ void CJS_Value::operator = (float fValue) m_eType = VT_number; } -void CJS_Value::operator =(v8::Handle pObj) +void CJS_Value::operator =(v8::Local 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)array); + m_pValue = JS_NewObject2(m_isolate,(v8::Local)array); m_eType = VT_object; } @@ -461,7 +461,7 @@ void CJS_PropValue::operator<<(CJS_Date &date) CJS_Value::operator=(date); } -CJS_PropValue::operator v8::Handle() const +CJS_PropValue::operator v8::Local() const { return m_pValue; } @@ -475,7 +475,7 @@ CJS_Array::~CJS_Array() { } -void CJS_Array::Attach(v8::Handle pArray) +void CJS_Array::Attach(v8::Local pArray) { m_pArray = pArray; } @@ -489,7 +489,7 @@ void CJS_Array::GetElement(unsigned index,CJS_Value &value) { if (m_pArray.IsEmpty()) return; - v8::Handle p = JS_GetArrayElement(m_isolate, m_pArray,index); + v8::Local p = JS_GetArrayElement(m_isolate, m_pArray,index); value.Attach(p,VT_object); } @@ -508,7 +508,7 @@ int CJS_Array::GetLength() return JS_GetArrayLength(m_pArray); } -CJS_Array:: operator v8::Handle() +CJS_Array:: operator v8::Local() { if (m_pArray.IsEmpty()) m_pArray = JS_NewArray(m_isolate); @@ -549,7 +549,7 @@ FX_BOOL CJS_Date::IsValidDate() return !JS_PortIsNan(JS_ToNumber(m_isolate, m_pDate)); } -void CJS_Date::Attach(v8::Handle pDate) +void CJS_Date::Attach(v8::Local pDate) { m_pDate = pDate; } @@ -642,7 +642,7 @@ void CJS_Date::SetSeconds(int seconds) JS_ValueCopy(m_pDate,JS_NewDate(m_isolate,date)); } -CJS_Date::operator v8::Handle() +CJS_Date::operator v8::Local() { return m_pDate; } diff --git a/fpdfsdk/src/javascript/app.cpp b/fpdfsdk/src/javascript/app.cpp index 552d26854d..896622822c 100644 --- a/fpdfsdk/src/javascript/app.cpp +++ b/fpdfsdk/src/javascript/app.cpp @@ -327,7 +327,7 @@ FX_BOOL app::alert(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& v { JSObject pObj = params[0].ToV8Object(); { - v8::Handle pValue = JS_GetObjectElement(isolate, pObj, L"cMsg"); + v8::Local pValue = JS_GetObjectElement(isolate, pObj, L"cMsg"); swMsg = CJS_Value(isolate, pValue, VT_unknown).ToCFXWideString(); pValue = JS_GetObjectElement(isolate, pObj, L"cTitle"); @@ -715,7 +715,7 @@ FX_BOOL app::mailMsg(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& { JSObject pObj = params[0].ToV8Object(); - v8::Handle pValue = JS_GetObjectElement(isolate, pObj, L"bUI"); + v8::Local pValue = JS_GetObjectElement(isolate, pObj, L"bUI"); bUI = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool(); pValue = JS_GetObjectElement(isolate, pObj, L"cTo"); @@ -849,7 +849,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 pValue = JS_GetObjectElement(isolate,pObj,L"cQuestion"); + v8::Local 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 99db9e7a71..7065933143 100644 --- a/fpdfsdk/src/javascript/global.cpp +++ b/fpdfsdk/src/javascript/global.cpp @@ -168,19 +168,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(), FALSE); + return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_NUMBER, dData, false, "", v8::Local(), FALSE); } case VT_boolean: { bool bData; vp >> bData; - return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_BOOLEAN, 0, bData, "", v8::Handle(), FALSE); + return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_BOOLEAN, 0, bData, "", v8::Local(), FALSE); } case VT_string: { CFX_ByteString sData; vp >> sData; - return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_STRING, 0, false, sData, v8::Handle(), FALSE); + return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_STRING, 0, false, sData, v8::Local(), FALSE); } case VT_object: { @@ -190,7 +190,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(), FALSE); + return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_NULL, 0, false, "", v8::Local(), FALSE); } case VT_undefined: { @@ -225,7 +225,7 @@ FX_BOOL global_alternate::DoProperty(IFXJS_Context* cc, FX_LPCWSTR propname, CJS break; case JS_GLOBALDATA_TYPE_OBJECT: { - v8::Handle obj = v8::Local::New(vp.GetIsolate(),pData->pData); + v8::Local obj = v8::Local::New(vp.GetIsolate(),pData->pData); vp << obj; break; } @@ -295,17 +295,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(), pData->bPersistent == 1); + this->SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_NUMBER, pData->data.dData, false, "", v8::Local(), 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(), pData->bPersistent == 1); + this->SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_BOOLEAN, 0, (bool)(pData->data.bData == 1), "", v8::Local(), 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(), pData->bPersistent == 1); + this->SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_STRING, 0, false, pData->data.sData, v8::Local(), pData->bPersistent == 1); JS_PutObjectString(NULL, (JSFXObject)(*m_pJSObject), pData->data.sKey.UTF8Decode().c_str(), pData->data.sData.UTF8Decode().c_str()); @@ -313,7 +313,7 @@ void global_alternate::UpdateGlobalPersistentVariables() case JS_GLOBALDATA_TYPE_OBJECT: { IJS_Runtime* pRuntime = JS_GetRuntime((JSFXObject)(*m_pJSObject)); - v8::Handle pObj = JS_NewFxDynamicObj(pRuntime, NULL, -1); + v8::Local pObj = JS_NewFxDynamicObj(pRuntime, NULL, -1); PutObjectProperty(pObj, &pData->data); @@ -324,7 +324,7 @@ void global_alternate::UpdateGlobalPersistentVariables() } break; case JS_GLOBALDATA_TYPE_NULL: - this->SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_NULL, 0, false, "", v8::Handle(), pData->bPersistent == 1); + this->SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_NULL, 0, false, "", v8::Local(), pData->bPersistent == 1); JS_PutObjectNull(NULL,(JSFXObject)(*m_pJSObject), pData->data.sKey.UTF8Decode().c_str()); break; @@ -369,7 +369,7 @@ void global_alternate::CommitGlobalPersisitentVariables() //if (pData->pData) { CJS_GlobalVariableArray array; - v8::Handle obj = v8::Local::New(GetJSObject()->GetIsolate(),pData->pData); + v8::Local obj = v8::Local::New(GetJSObject()->GetIsolate(),pData->pData); ObjectToArray(obj, array); m_pGlobalData->SetGlobalVariableObject(name, array); m_pGlobalData->SetGlobalVariablePersistent(name, pData->bPersistent); @@ -385,11 +385,11 @@ void global_alternate::CommitGlobalPersisitentVariables() } } -void global_alternate::ObjectToArray(v8::Handle pObj, CJS_GlobalVariableArray& array) +void global_alternate::ObjectToArray(v8::Local pObj, CJS_GlobalVariableArray& array) { v8::Local context = pObj->CreationContext(); v8::Isolate* isolate = context->GetIsolate(); - v8::Handle pKeyList = JS_GetObjectElementNames(isolate, pObj); + v8::Local pKeyList = JS_GetObjectElementNames(isolate, pObj); int nObjElements = pKeyList->Length(); for (int i=0; i pObj, CJS_GlobalVari CFX_WideString ws = JS_ToString(isolate, JS_GetArrayElement(isolate, pKeyList, i)); CFX_ByteString sKey = ws.UTF8Encode(); - v8::Handle v = JS_GetObjectElement(isolate, pObj, ws.c_str()); + v8::Local v = JS_GetObjectElement(isolate, pObj, ws.c_str()); FXJSVALUETYPE vt = GET_VALUE_TYPE(v); switch (vt) { @@ -453,7 +453,7 @@ void global_alternate::ObjectToArray(v8::Handle pObj, CJS_GlobalVari } } -void global_alternate::PutObjectProperty(v8::Handle pObj, CJS_KeyValue* pData) +void global_alternate::PutObjectProperty(v8::Local pObj, CJS_KeyValue* pData) { ASSERT(pData != NULL); @@ -476,7 +476,7 @@ void global_alternate::PutObjectProperty(v8::Handle pObj, CJS_KeyVal case JS_GLOBALDATA_TYPE_OBJECT: { IJS_Runtime* pRuntime = JS_GetRuntime((JSFXObject)(*m_pJSObject)); - v8::Handle pNewObj = JS_NewFxDynamicObj(pRuntime, NULL, -1); + v8::Local pNewObj = JS_NewFxDynamicObj(pRuntime, NULL, -1); PutObjectProperty(pNewObj, pObjData); JS_PutObjectObject(NULL, (JSObject)pObj, pObjData->sKey.UTF8Decode().c_str(), (JSObject)pNewObj); } @@ -606,7 +606,7 @@ FX_BOOL global_alternate::SetGlobalVariables(FX_LPCSTR propname, int nType, return TRUE; } -FXJSVALUETYPE GET_VALUE_TYPE(v8::Handle p) +FXJSVALUETYPE GET_VALUE_TYPE(v8::Local p) { const unsigned int nHash = JS_CalcHash(JS_GetTypeof(p)); diff --git a/fpdfsdk/src/jsapi/fxjs_v8.cpp b/fpdfsdk/src/jsapi/fxjs_v8.cpp index b1adeb7112..0c0d8b5b1b 100644 --- a/fpdfsdk/src/jsapi/fxjs_v8.cpp +++ b/fpdfsdk/src/jsapi/fxjs_v8.cpp @@ -46,7 +46,7 @@ public: v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); - v8::Handle objTemplate = v8::ObjectTemplate::New(isolate); + v8::Local objTemplate = v8::ObjectTemplate::New(isolate); objTemplate->SetInternalFieldCount(2); m_objTemplate.Reset(isolate, objTemplate); @@ -70,8 +70,8 @@ public: unsigned m_bApplyNew; FX_BOOL m_bSetAsGlobalObject; - v8::Persistent m_objTemplate; - v8::Persistent m_StaticObj; + v8::Global m_objTemplate; + v8::Global m_StaticObj; }; int JS_DefineObj(IJS_Runtime* pJSRuntime, const wchar_t* sObjName, FXJSOBJTYPE eObjType, LP_CONSTRUCTOR pConstructor, LP_DESTRUCTOR pDestructor, unsigned bApplyNew) @@ -147,7 +147,7 @@ int JS_DefineObjAllProperties(IJS_Runtime* pJSRuntime, int nObjDefnID, v8::Named return 0; } -int JS_DefineObjConst(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sConstName, v8::Handle pDefault) +int JS_DefineObjConst(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sConstName, v8::Local pDefault) { v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; v8::Isolate::Scope isolate_scope(isolate); @@ -167,7 +167,7 @@ int JS_DefineObjConst(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sC return 0; } -static v8::Persistent& _getGlobalObjectTemplate(IJS_Runtime* pJSRuntime) +static v8::Global& _getGlobalObjectTemplate(IJS_Runtime* pJSRuntime) { v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; v8::Isolate::Scope isolate_scope(isolate); @@ -181,7 +181,7 @@ static v8::Persistent& _getGlobalObjectTemplate(IJS_Runtime* if(pObjDef->m_bSetAsGlobalObject) return pObjDef->m_objTemplate; } - static v8::Persistent gloabalObjectTemplate; + static v8::Global gloabalObjectTemplate; return gloabalObjectTemplate; } @@ -197,7 +197,7 @@ int JS_DefineGlobalMethod(IJS_Runtime* pJSRuntime, const wchar_t* sMethodName, v v8::Local funTempl = v8::FunctionTemplate::New(isolate, pMethodCall); v8::Local objTemp; - v8::Persistent& globalObjTemp = _getGlobalObjectTemplate(pJSRuntime); + v8::Global& globalObjTemp = _getGlobalObjectTemplate(pJSRuntime); if(globalObjTemp.IsEmpty()) objTemp = v8::ObjectTemplate::New(isolate); else @@ -209,7 +209,7 @@ int JS_DefineGlobalMethod(IJS_Runtime* pJSRuntime, const wchar_t* sMethodName, v return 0; } -int JS_DefineGlobalConst(IJS_Runtime* pJSRuntime, const wchar_t* sConstName, v8::Handle pDefault) +int JS_DefineGlobalConst(IJS_Runtime* pJSRuntime, const wchar_t* sConstName, v8::Local pDefault) { v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; v8::Isolate::Scope isolate_scope(isolate); @@ -220,7 +220,7 @@ int JS_DefineGlobalConst(IJS_Runtime* pJSRuntime, const wchar_t* sConstName, v8: v8::Local objTemp; - v8::Persistent& globalObjTemp = _getGlobalObjectTemplate(pJSRuntime); + v8::Global& globalObjTemp = _getGlobalObjectTemplate(pJSRuntime); if(globalObjTemp.IsEmpty()) objTemp = v8::ObjectTemplate::New(isolate); else @@ -233,17 +233,17 @@ int JS_DefineGlobalConst(IJS_Runtime* pJSRuntime, const wchar_t* sConstName, v8: } -void JS_InitialRuntime(IJS_Runtime* pJSRuntime,IFXJS_Runtime* pFXRuntime, IFXJS_Context* context, v8::Persistent& v8PersistentContext) +void JS_InitialRuntime(IJS_Runtime* pJSRuntime,IFXJS_Runtime* pFXRuntime, IFXJS_Context* context, v8::Global& v8PersistentContext) { v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); - v8::Persistent& globalObjTemp = _getGlobalObjectTemplate(pJSRuntime); - v8::Handle v8Context = v8::Context::New(isolate, NULL, v8::Local::New(isolate, globalObjTemp)); + v8::Global& globalObjTemp = _getGlobalObjectTemplate(pJSRuntime); + v8::Local v8Context = v8::Context::New(isolate, NULL, v8::Local::New(isolate, globalObjTemp)); v8::Context::Scope context_scope(v8Context); - v8::Handle ptr = v8::External::New(isolate, pFXRuntime); + v8::Local ptr = v8::External::New(isolate, pFXRuntime); v8Context->SetEmbedderData(1, ptr); CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); @@ -254,7 +254,7 @@ void JS_InitialRuntime(IJS_Runtime* pJSRuntime,IFXJS_Runtime* pFXRuntime, IFXJS_ CJS_ObjDefintion* pObjDef = (CJS_ObjDefintion*)pArray->GetAt(i); CFX_WideString ws = CFX_WideString(pObjDef->objName); CFX_ByteString bs = ws.UTF8Encode(); - v8::Handle objName = v8::String::NewFromUtf8(isolate, bs.c_str(), v8::NewStringType::kNormal, bs.GetLength()).ToLocalChecked(); + v8::Local objName = v8::String::NewFromUtf8(isolate, bs.c_str(), v8::NewStringType::kNormal, bs.GetLength()).ToLocalChecked(); if(pObjDef->objType == JS_DYNAMIC) @@ -274,7 +274,7 @@ void JS_InitialRuntime(IJS_Runtime* pJSRuntime,IFXJS_Runtime* pFXRuntime, IFXJS_ } else { - v8::Handle obj = JS_NewFxDynamicObj(pJSRuntime, context, i); + v8::Local obj = JS_NewFxDynamicObj(pJSRuntime, context, i); v8Context->Global()->Set(v8Context, objName, obj).FromJust(); pObjDef->m_StaticObj.Reset(isolate, obj); } @@ -282,7 +282,7 @@ void JS_InitialRuntime(IJS_Runtime* pJSRuntime,IFXJS_Runtime* pFXRuntime, IFXJS_ v8PersistentContext.Reset(isolate, v8Context); } -void JS_ReleaseRuntime(IJS_Runtime* pJSRuntime, v8::Persistent& v8PersistentContext) +void JS_ReleaseRuntime(IJS_Runtime* pJSRuntime, v8::Global& v8PersistentContext) { v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; v8::Isolate::Scope isolate_scope(isolate); @@ -351,7 +351,7 @@ int JS_Execute(IJS_Runtime* pJSRuntime, IFXJS_Context* pJSContext, const wchar_t return -1; } - v8::Handle result; + v8::Local result; if (!compiled_script->Run(context).ToLocal(&result)) { v8::String::Utf8Value error(try_catch.Exception()); return -1; @@ -359,7 +359,7 @@ int JS_Execute(IJS_Runtime* pJSRuntime, IFXJS_Context* pJSContext, const wchar_t return 0; } -v8::Handle JS_NewFxDynamicObj(IJS_Runtime* pJSRuntime, IFXJS_Context* pJSContext, int nObjDefnID) +v8::Local JS_NewFxDynamicObj(IJS_Runtime* pJSRuntime, IFXJS_Context* pJSContext, int nObjDefnID) { v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; v8::Isolate::Scope isolate_scope(isolate); @@ -369,14 +369,14 @@ v8::Handle JS_NewFxDynamicObj(IJS_Runtime* pJSRuntime, IFXJS_Context v8::Local objTempl = v8::ObjectTemplate::New(isolate); v8::Local obj; if (objTempl->NewInstance(context).ToLocal(&obj)) return obj; - return v8::Handle(); + return v8::Local(); } CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); - if(!pArray) return v8::Handle(); + if(!pArray) return v8::Local(); - if(nObjDefnID<0 || nObjDefnID>= pArray->GetSize()) return v8::Handle(); + if(nObjDefnID<0 || nObjDefnID>= pArray->GetSize()) return v8::Local(); CJS_ObjDefintion* pObjDef = (CJS_ObjDefintion*)pArray->GetAt(nObjDefnID); v8::Local objTemp = v8::Local::New(isolate, pObjDef->m_objTemplate); @@ -393,15 +393,15 @@ v8::Handle JS_NewFxDynamicObj(IJS_Runtime* pJSRuntime, IFXJS_Context return obj; } -v8::Handle JS_GetStaticObj(IJS_Runtime* pJSRuntime, int nObjDefnID) +v8::Local JS_GetStaticObj(IJS_Runtime* pJSRuntime, int nObjDefnID) { v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; v8::Isolate::Scope isolate_scope(isolate); CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); - if(!pArray) return v8::Handle(); + if(!pArray) return v8::Local(); - if(nObjDefnID<0 || nObjDefnID>= pArray->GetSize()) return v8::Handle(); + if(nObjDefnID<0 || nObjDefnID>= pArray->GetSize()) return v8::Local(); CJS_ObjDefintion* pObjDef = (CJS_ObjDefintion*)pArray->GetAt(nObjDefnID); v8::Local obj = v8::Local::New(isolate,pObjDef->m_StaticObj); return obj; @@ -411,20 +411,20 @@ void JS_SetThisObj(IJS_Runtime* pJSRuntime, int nThisObjID) { //Do nothing. } -v8::Handle JS_GetThisObj(IJS_Runtime * pJSRuntime) +v8::Local JS_GetThisObj(IJS_Runtime * pJSRuntime) { //Return the global object. v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; v8::Isolate::Scope isolate_scope(isolate); CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); - if(!pArray) return v8::Handle(); + if(!pArray) return v8::Local(); v8::Local context = isolate->GetCurrentContext(); return context->Global()->GetPrototype()->ToObject(context).ToLocalChecked(); } -int JS_GetObjDefnID(v8::Handle pObj) +int JS_GetObjDefnID(v8::Local pObj) { if(pObj.IsEmpty() || !pObj->InternalFieldCount()) return -1; CJS_PrivateData* pPrivateData = (CJS_PrivateData*)pObj->GetAlignedPointerFromInternalField(0); @@ -433,7 +433,7 @@ int JS_GetObjDefnID(v8::Handle pObj) return -1; } -IJS_Runtime* JS_GetRuntime(v8::Handle pObj) +IJS_Runtime* JS_GetRuntime(v8::Local pObj) { if(pObj.IsEmpty()) return NULL; v8::Local context = pObj->CreationContext(); @@ -478,7 +478,7 @@ unsigned JS_CalcHash(const wchar_t* main) { return (unsigned)FX_HashCode_String_GetW(main, FXSYS_wcslen(main)); } -const wchar_t* JS_GetTypeof(v8::Handle pObj) +const wchar_t* JS_GetTypeof(v8::Local pObj) { if(pObj.IsEmpty()) return NULL; if(pObj->IsString()) @@ -498,17 +498,17 @@ const wchar_t* JS_GetTypeof(v8::Handle pObj) return NULL; } -void JS_SetPrivate(v8::Handle pObj, void* p) +void JS_SetPrivate(v8::Local pObj, void* p) { JS_SetPrivate(NULL, pObj, p); } -void* JS_GetPrivate(v8::Handle pObj) +void* JS_GetPrivate(v8::Local pObj) { return JS_GetPrivate(NULL,pObj); } -void JS_SetPrivate(IJS_Runtime* pJSRuntime, v8::Handle pObj, void* p) +void JS_SetPrivate(IJS_Runtime* pJSRuntime, v8::Local pObj, void* p) { if(pObj.IsEmpty() || !pObj->InternalFieldCount()) return; CJS_PrivateData* pPrivateData = (CJS_PrivateData*)pObj->GetAlignedPointerFromInternalField(0); @@ -516,7 +516,7 @@ void JS_SetPrivate(IJS_Runtime* pJSRuntime, v8::Handle pObj, void* p pPrivateData->pPrivate = p; } -void* JS_GetPrivate(IJS_Runtime* pJSRuntime, v8::Handle pObj) +void* JS_GetPrivate(IJS_Runtime* pJSRuntime, v8::Local pObj) { if(pObj.IsEmpty()) return NULL; CJS_PrivateData* pPrivateData = NULL; @@ -540,7 +540,7 @@ void JS_FreePrivate(void* pPrivateData) delete (CJS_PrivateData*)pPrivateData; } -void JS_FreePrivate(v8::Handle pObj) +void JS_FreePrivate(v8::Local pObj) { if(pObj.IsEmpty() || !pObj->InternalFieldCount()) return; JS_FreePrivate(pObj->GetAlignedPointerFromInternalField(0)); @@ -548,12 +548,12 @@ void JS_FreePrivate(v8::Handle pObj) } -v8::Handle JS_GetObjectValue(v8::Handle pObj) +v8::Local JS_GetObjectValue(v8::Local pObj) { return pObj; } -v8::Handle WSToJSString(IJS_Runtime* pJSRuntime, const wchar_t* PropertyName, int Len = -1) +v8::Local WSToJSString(IJS_Runtime* pJSRuntime, const wchar_t* PropertyName, int Len = -1) { CFX_WideString ws = CFX_WideString(PropertyName,Len); CFX_ByteString bs = ws.UTF8Encode(); @@ -561,149 +561,149 @@ v8::Handle WSToJSString(IJS_Runtime* pJSRuntime, const wchar_t* Prop return v8::String::NewFromUtf8(pJSRuntime, bs.c_str(), v8::NewStringType::kNormal).ToLocalChecked(); } -v8::Handle JS_GetObjectElement(IJS_Runtime* pJSRuntime, v8::Handle pObj,const wchar_t* PropertyName) +v8::Local JS_GetObjectElement(IJS_Runtime* pJSRuntime, v8::Local pObj,const wchar_t* PropertyName) { - if(pObj.IsEmpty()) return v8::Handle(); + if(pObj.IsEmpty()) return v8::Local(); v8::Local val; - if (!pObj->Get(pJSRuntime->GetCurrentContext(), WSToJSString(pJSRuntime,PropertyName)).ToLocal(&val)) return v8::Handle(); + if (!pObj->Get(pJSRuntime->GetCurrentContext(), WSToJSString(pJSRuntime,PropertyName)).ToLocal(&val)) return v8::Local(); return val; } -v8::Handle JS_GetObjectElementNames(IJS_Runtime* pJSRuntime, v8::Handle pObj) +v8::Local JS_GetObjectElementNames(IJS_Runtime* pJSRuntime, v8::Local pObj) { - if(pObj.IsEmpty()) return v8::Handle(); + if(pObj.IsEmpty()) return v8::Local(); v8::Local val; if (!pObj->GetPropertyNames(pJSRuntime->GetCurrentContext()).ToLocal(&val)) return v8::Local(); return val; } -void JS_PutObjectString(IJS_Runtime* pJSRuntime,v8::Handle pObj, const wchar_t* PropertyName, const wchar_t* sValue) //VT_string +void JS_PutObjectString(IJS_Runtime* pJSRuntime,v8::Local pObj, const wchar_t* PropertyName, const wchar_t* sValue) //VT_string { if(pObj.IsEmpty()) return; pObj->Set(pJSRuntime->GetCurrentContext(), WSToJSString(pJSRuntime, PropertyName), WSToJSString(pJSRuntime, sValue)).FromJust(); } -void JS_PutObjectNumber(IJS_Runtime* pJSRuntime,v8::Handle pObj, const wchar_t* PropertyName, int nValue) +void JS_PutObjectNumber(IJS_Runtime* pJSRuntime,v8::Local pObj, const wchar_t* PropertyName, int nValue) { if(pObj.IsEmpty()) return; pObj->Set(pJSRuntime->GetCurrentContext(), WSToJSString(pJSRuntime,PropertyName),v8::Int32::New(pJSRuntime, nValue)).FromJust(); } -void JS_PutObjectNumber(IJS_Runtime* pJSRuntime,v8::Handle pObj, const wchar_t* PropertyName, float fValue) +void JS_PutObjectNumber(IJS_Runtime* pJSRuntime,v8::Local pObj, const wchar_t* PropertyName, float fValue) { if(pObj.IsEmpty()) return; pObj->Set(pJSRuntime->GetCurrentContext(), WSToJSString(pJSRuntime,PropertyName),v8::Number::New(pJSRuntime, (double)fValue)).FromJust(); } -void JS_PutObjectNumber(IJS_Runtime* pJSRuntime,v8::Handle pObj, const wchar_t* PropertyName, double dValue) +void JS_PutObjectNumber(IJS_Runtime* pJSRuntime,v8::Local pObj, const wchar_t* PropertyName, double dValue) { if(pObj.IsEmpty()) return; pObj->Set(pJSRuntime->GetCurrentContext(), WSToJSString(pJSRuntime,PropertyName),v8::Number::New(pJSRuntime, (double)dValue)).FromJust(); } -void JS_PutObjectBoolean(IJS_Runtime* pJSRuntime,v8::Handle pObj, const wchar_t* PropertyName, bool bValue) +void JS_PutObjectBoolean(IJS_Runtime* pJSRuntime,v8::Local pObj, const wchar_t* PropertyName, bool bValue) { if(pObj.IsEmpty()) return; pObj->Set(pJSRuntime->GetCurrentContext(), WSToJSString(pJSRuntime,PropertyName),v8::Boolean::New(pJSRuntime, bValue)).FromJust(); } -void JS_PutObjectObject(IJS_Runtime* pJSRuntime,v8::Handle pObj, const wchar_t* PropertyName, v8::Handle pPut) +void JS_PutObjectObject(IJS_Runtime* pJSRuntime,v8::Local pObj, const wchar_t* PropertyName, v8::Local pPut) { if(pObj.IsEmpty()) return; pObj->Set(pJSRuntime->GetCurrentContext(), WSToJSString(pJSRuntime,PropertyName),pPut).FromJust(); } -void JS_PutObjectNull(IJS_Runtime* pJSRuntime,v8::Handle pObj, const wchar_t* PropertyName) +void JS_PutObjectNull(IJS_Runtime* pJSRuntime,v8::Local pObj, const wchar_t* PropertyName) { if(pObj.IsEmpty()) return; - pObj->Set(pJSRuntime->GetCurrentContext(), WSToJSString(pJSRuntime,PropertyName),v8::Handle()).FromJust(); + pObj->Set(pJSRuntime->GetCurrentContext(), WSToJSString(pJSRuntime,PropertyName),v8::Local()).FromJust(); } -v8::Handle JS_NewArray(IJS_Runtime* pJSRuntime) +v8::Local JS_NewArray(IJS_Runtime* pJSRuntime) { return v8::Array::New(pJSRuntime); } -unsigned JS_PutArrayElement(IJS_Runtime* pJSRuntime, v8::Handle pArray,unsigned index,v8::Handle pValue,FXJSVALUETYPE eType) +unsigned JS_PutArrayElement(IJS_Runtime* pJSRuntime, v8::Local pArray,unsigned index,v8::Local pValue,FXJSVALUETYPE eType) { if(pArray.IsEmpty()) return 0; if (pArray->Set(pJSRuntime->GetCurrentContext(), index, pValue).IsNothing()) return 0; return 1; } -v8::Handle JS_GetArrayElement(IJS_Runtime* pJSRuntime, v8::Handle pArray,unsigned index) +v8::Local JS_GetArrayElement(IJS_Runtime* pJSRuntime, v8::Local pArray,unsigned index) { - if(pArray.IsEmpty()) return v8::Handle(); + if(pArray.IsEmpty()) return v8::Local(); v8::Local val; if (pArray->Get(pJSRuntime->GetCurrentContext(), index).ToLocal(&val)) return v8::Local(); return val; } -unsigned JS_GetArrayLength(v8::Handle pArray) +unsigned JS_GetArrayLength(v8::Local pArray) { if(pArray.IsEmpty()) return 0; return pArray->Length(); } -v8::Handle JS_NewNumber(IJS_Runtime* pJSRuntime,int number) +v8::Local JS_NewNumber(IJS_Runtime* pJSRuntime,int number) { return v8::Int32::New(pJSRuntime, number); } -v8::Handle JS_NewNumber(IJS_Runtime* pJSRuntime,double number) +v8::Local JS_NewNumber(IJS_Runtime* pJSRuntime,double number) { return v8::Number::New(pJSRuntime, number); } -v8::Handle JS_NewNumber(IJS_Runtime* pJSRuntime,float number) +v8::Local JS_NewNumber(IJS_Runtime* pJSRuntime,float number) { return v8::Number::New(pJSRuntime, (float)number); } -v8::Handle JS_NewBoolean(IJS_Runtime* pJSRuntime,bool b) +v8::Local JS_NewBoolean(IJS_Runtime* pJSRuntime,bool b) { return v8::Boolean::New(pJSRuntime, b); } -v8::Handle JS_NewObject(IJS_Runtime* pJSRuntime,v8::Handle pObj) +v8::Local JS_NewObject(IJS_Runtime* pJSRuntime,v8::Local pObj) { - if(pObj.IsEmpty()) return v8::Handle(); + if(pObj.IsEmpty()) return v8::Local(); return pObj->Clone(); } -v8::Handle JS_NewObject2(IJS_Runtime* pJSRuntime,v8::Handle pObj) +v8::Local JS_NewObject2(IJS_Runtime* pJSRuntime,v8::Local pObj) { - if(pObj.IsEmpty()) return v8::Handle(); + if(pObj.IsEmpty()) return v8::Local(); return pObj->Clone(); } -v8::Handle JS_NewString(IJS_Runtime* pJSRuntime,const wchar_t* string) +v8::Local JS_NewString(IJS_Runtime* pJSRuntime,const wchar_t* string) { return WSToJSString(pJSRuntime, string); } -v8::Handle JS_NewString(IJS_Runtime* pJSRuntime,const wchar_t* string, unsigned nLen) +v8::Local JS_NewString(IJS_Runtime* pJSRuntime,const wchar_t* string, unsigned nLen) { return WSToJSString(pJSRuntime, string, nLen); } -v8::Handle JS_NewNull() +v8::Local JS_NewNull() { - return v8::Handle(); + return v8::Local(); } -v8::Handle JS_NewDate(IJS_Runtime* pJSRuntime,double d) +v8::Local JS_NewDate(IJS_Runtime* pJSRuntime,double d) { return v8::Date::New(pJSRuntime->GetCurrentContext(), d).ToLocalChecked(); } -v8::Handle JS_NewValue(IJS_Runtime* pJSRuntime) +v8::Local JS_NewValue(IJS_Runtime* pJSRuntime) { - return v8::Handle(); + return v8::Local(); } -v8::Handle JS_GetListValue(IJS_Runtime* pJSRuntime, v8::Handle pList, int index) +v8::Local JS_GetListValue(IJS_Runtime* pJSRuntime, v8::Local pList, int index) { v8::Local context = pJSRuntime->GetCurrentContext(); @@ -716,38 +716,38 @@ v8::Handle JS_GetListValue(IJS_Runtime* pJSRuntime, v8::HandleGet(context, index).ToLocal(&val)) return val; } } - return v8::Handle(); + return v8::Local(); } -int JS_ToInt32(IJS_Runtime* pJSRuntime, v8::Handle pValue) +int JS_ToInt32(IJS_Runtime* pJSRuntime, v8::Local pValue) { if(pValue.IsEmpty()) return 0; v8::Local context = pJSRuntime->GetCurrentContext(); return pValue->ToInt32(context).ToLocalChecked()->Value(); } -bool JS_ToBoolean(IJS_Runtime* pJSRuntime, v8::Handle pValue) +bool JS_ToBoolean(IJS_Runtime* pJSRuntime, v8::Local pValue) { if(pValue.IsEmpty()) return false; v8::Local context = pJSRuntime->GetCurrentContext(); return pValue->ToBoolean(context).ToLocalChecked()->Value(); } -double JS_ToNumber(IJS_Runtime* pJSRuntime, v8::Handle pValue) +double JS_ToNumber(IJS_Runtime* pJSRuntime, v8::Local pValue) { if(pValue.IsEmpty()) return 0.0; v8::Local context = pJSRuntime->GetCurrentContext(); return pValue->ToNumber(context).ToLocalChecked()->Value(); } -v8::Handle JS_ToObject(IJS_Runtime* pJSRuntime, v8::Handle pValue) +v8::Local JS_ToObject(IJS_Runtime* pJSRuntime, v8::Local pValue) { - if(pValue.IsEmpty()) return v8::Handle(); + if(pValue.IsEmpty()) return v8::Local(); v8::Local context = pJSRuntime->GetCurrentContext(); return pValue->ToObject(context).ToLocalChecked(); } -CFX_WideString JS_ToString(IJS_Runtime* pJSRuntime, v8::Handle pValue) +CFX_WideString JS_ToString(IJS_Runtime* pJSRuntime, v8::Local pValue) { if(pValue.IsEmpty()) return L""; v8::Local context = pJSRuntime->GetCurrentContext(); @@ -755,14 +755,14 @@ CFX_WideString JS_ToString(IJS_Runtime* pJSRuntime, v8::Handle pValue return CFX_WideString::FromUTF8(*s, s.length()); } -v8::Handle JS_ToArray(IJS_Runtime* pJSRuntime, v8::Handle pValue) +v8::Local JS_ToArray(IJS_Runtime* pJSRuntime, v8::Local pValue) { - if(pValue.IsEmpty()) return v8::Handle(); + if(pValue.IsEmpty()) return v8::Local(); v8::Local context = pJSRuntime->GetCurrentContext(); - return v8::Handle::Cast(pValue->ToObject(context).ToLocalChecked()); + return v8::Local::Cast(pValue->ToObject(context).ToLocalChecked()); } -void JS_ValueCopy(v8::Handle& pTo, v8::Handle pFrom) +void JS_ValueCopy(v8::Local& pTo, v8::Local pFrom) { pTo = pFrom; } @@ -1000,11 +1000,11 @@ double JS_DateParse(const wchar_t* string) v = o->Get(context,v8::String::NewFromUtf8(pIsolate, "parse", v8::NewStringType::kNormal).ToLocalChecked()).ToLocalChecked(); if(v->IsFunction()) { - v8::Local funC = v8::Handle::Cast(v); + v8::Local funC = v8::Local::Cast(v); const int argc = 1; v8::Local timeStr = WSToJSString(pIsolate, string); - v8::Handle argv[argc] = {timeStr}; + v8::Local argv[argc] = {timeStr}; v = funC->Call(context, context->Global(), argc, argv).ToLocalChecked(); if(v->IsNumber()) { -- cgit v1.2.3