Index: fpdfsdk/src/jsapi/fxjs_v8.cpp |
diff --git a/fpdfsdk/src/jsapi/fxjs_v8.cpp b/fpdfsdk/src/jsapi/fxjs_v8.cpp |
index 7adfc2696df17c45f34d6dee275e6148d01fafea..feed779f172b898e842a479f1733649bb90cf4ae 100644 |
--- a/fpdfsdk/src/jsapi/fxjs_v8.cpp |
+++ b/fpdfsdk/src/jsapi/fxjs_v8.cpp |
@@ -26,6 +26,7 @@ static double GetNan() |
{ |
return *(double*)g_nan; |
} |
+static unsigned int g_embedderDataSlot = 0u; |
class CJS_PrivateData |
@@ -79,11 +80,11 @@ int JS_DefineObj(IJS_Runtime* pJSRuntime, const wchar_t* sObjName, FXJSOBJTYPE e |
v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; |
v8::Isolate::Scope isolate_scope(isolate); |
v8::HandleScope handle_scope(isolate); |
- CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); |
+ CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(g_embedderDataSlot); |
if(!pArray) |
{ |
pArray = new CFX_PtrArray(); |
- isolate->SetData(0, pArray); |
+ isolate->SetData(g_embedderDataSlot, pArray); |
} |
CJS_ObjDefintion* pObjDef = new CJS_ObjDefintion(isolate, sObjName, eObjType, pConstructor, pDestructor, bApplyNew); |
pArray->Add(pObjDef); |
@@ -99,7 +100,7 @@ int JS_DefineObjMethod(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* s |
CFX_WideString ws = CFX_WideString(sMethodName); |
CFX_ByteString bsMethodName = ws.UTF8Encode(); |
- CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); |
+ CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(g_embedderDataSlot); |
if(!pArray) return 0; |
if(nObjDefnID<0 || nObjDefnID>= pArray->GetSize()) return 0; |
@@ -119,7 +120,7 @@ int JS_DefineObjProperty(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* |
CFX_WideString ws = CFX_WideString(sPropName); |
CFX_ByteString bsPropertyName = ws.UTF8Encode(); |
- CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); |
+ CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(g_embedderDataSlot); |
if(!pArray) return 0; |
if(nObjDefnID<0 || nObjDefnID>= pArray->GetSize()) return 0; |
@@ -136,7 +137,7 @@ int JS_DefineObjAllProperties(IJS_Runtime* pJSRuntime, int nObjDefnID, v8::Named |
v8::Isolate::Scope isolate_scope(isolate); |
v8::HandleScope handle_scope(isolate); |
- CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); |
+ CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(g_embedderDataSlot); |
if(!pArray) return 0; |
if(nObjDefnID<0 || nObjDefnID>= pArray->GetSize()) return 0; |
@@ -153,7 +154,7 @@ int JS_DefineObjConst(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sC |
v8::Isolate::Scope isolate_scope(isolate); |
v8::HandleScope handle_scope(isolate); |
- CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); |
+ CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(g_embedderDataSlot); |
if(!pArray) return 0; |
CFX_WideString ws = CFX_WideString(sConstName); |
@@ -173,7 +174,7 @@ static v8::Global<v8::ObjectTemplate>& _getGlobalObjectTemplate(IJS_Runtime* pJS |
v8::Isolate::Scope isolate_scope(isolate); |
v8::HandleScope handle_scope(isolate); |
- CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); |
+ CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(g_embedderDataSlot); |
ASSERT(pArray != NULL); |
for(int i=0; i<pArray->GetSize(); i++) |
{ |
@@ -246,7 +247,7 @@ void JS_InitialRuntime(IJS_Runtime* pJSRuntime,IFXJS_Runtime* pFXRuntime, IFXJS_ |
v8::Local<v8::External> ptr = v8::External::New(isolate, pFXRuntime); |
v8Context->SetEmbedderData(1, ptr); |
- CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); |
+ CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(g_embedderDataSlot); |
if(!pArray) return; |
for(int i=0; i<pArray->GetSize(); i++) |
@@ -290,7 +291,7 @@ void JS_ReleaseRuntime(IJS_Runtime* pJSRuntime, v8::Global<v8::Context>& v8Persi |
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); |
+ CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(g_embedderDataSlot); |
if(!pArray) return ; |
for(int i=0; i<pArray->GetSize(); i++) |
@@ -306,11 +307,12 @@ void JS_ReleaseRuntime(IJS_Runtime* pJSRuntime, v8::Global<v8::Context>& v8Persi |
delete pObjDef; |
} |
delete pArray; |
- isolate->SetData(0,NULL); |
+ isolate->SetData(g_embedderDataSlot,NULL); |
} |
-void JS_Initial() |
+void JS_Initial(unsigned int embedderDataSlot) |
{ |
+ g_embedderDataSlot = embedderDataSlot; |
} |
void JS_Release() |
{ |
@@ -372,7 +374,7 @@ v8::Local<v8::Object> JS_NewFxDynamicObj(IJS_Runtime* pJSRuntime, IFXJS_Context* |
return v8::Local<v8::Object>(); |
} |
- CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); |
+ CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(g_embedderDataSlot); |
if(!pArray) return v8::Local<v8::Object>(); |
@@ -398,7 +400,7 @@ v8::Local<v8::Object> 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); |
+ CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(g_embedderDataSlot); |
if(!pArray) return v8::Local<v8::Object>(); |
if(nObjDefnID<0 || nObjDefnID>= pArray->GetSize()) return v8::Local<v8::Object>(); |
@@ -417,7 +419,7 @@ v8::Local<v8::Object> JS_GetThisObj(IJS_Runtime * pJSRuntime) |
v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; |
v8::Isolate::Scope isolate_scope(isolate); |
- CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); |
+ CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(g_embedderDataSlot); |
if(!pArray) return v8::Local<v8::Object>(); |
v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
@@ -446,7 +448,7 @@ int JS_GetObjDefnID(IJS_Runtime * pJSRuntime, const wchar_t* pObjName) |
v8::Isolate* isolate = (v8::Isolate*)pJSRuntime; |
v8::Isolate::Scope isolate_scope(isolate); |
- CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(0); |
+ CFX_PtrArray* pArray = (CFX_PtrArray*)isolate->GetData(g_embedderDataSlot); |
if(!pArray) return -1; |
for(int i=0; i<pArray->GetSize(); i++) |