diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-10-08 12:04:40 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-10-08 12:04:40 -0700 |
commit | 287b63d9ab410783d71cf37291f09fd57d3059b4 (patch) | |
tree | f7694e057d86f98833830ea1a34c2a2bbdca8399 /fpdfsdk/src/javascript/JS_Define.h | |
parent | 4fa0e27ba39f49ba92fb4c160ab836a6f1dd2893 (diff) | |
download | pdfium-287b63d9ab410783d71cf37291f09fd57d3059b4.tar.xz |
Wean CJS_Value off of v8::Isolate.
CJS_Values should belong to CJS_Runtimes so that we may
eventually cram much of the v8 dependencies down into fxjs.
This is a first step; the remaining split in this code between
isolate and CJS_Runtime goes away when fxjs provides a CFXJS_Runtime
object, and the CJS_Runtime is-a/has-a CFXJS_Runtime. But that can't
happen until this is resolved.
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1394103002 .
Diffstat (limited to 'fpdfsdk/src/javascript/JS_Define.h')
-rw-r--r-- | fpdfsdk/src/javascript/JS_Define.h | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/fpdfsdk/src/javascript/JS_Define.h b/fpdfsdk/src/javascript/JS_Define.h index 766bf4baba..cb39841c53 100644 --- a/fpdfsdk/src/javascript/JS_Define.h +++ b/fpdfsdk/src/javascript/JS_Define.h @@ -79,14 +79,15 @@ void JSPropGetter(const char* prop_name_string, v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value>& info) { v8::Isolate* isolate = info.GetIsolate(); - IJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); + CJS_Runtime* pRuntime = + static_cast<CJS_Runtime*>(FXJS_GetRuntimeFromIsolate(isolate)); if (!pRuntime) return; IJS_Context* pContext = pRuntime->GetCurrentContext(); CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder()); C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); CFX_WideString sError; - CJS_PropValue value(isolate); + CJS_PropValue value(pRuntime); value.StartGetting(); if (!(pObj->*M)(pContext, value, sError)) { FXJS_Error(isolate, JSFormatErrorString(class_name_string, prop_name_string, @@ -105,14 +106,15 @@ void JSPropSetter(const char* prop_name_string, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) { v8::Isolate* isolate = info.GetIsolate(); - IJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); + CJS_Runtime* pRuntime = + static_cast<CJS_Runtime*>(FXJS_GetRuntimeFromIsolate(isolate)); if (!pRuntime) return; IJS_Context* pContext = pRuntime->GetCurrentContext(); CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder()); C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); CFX_WideString sError; - CJS_PropValue propValue(CJS_Value(isolate, value, CJS_Value::VT_unknown)); + CJS_PropValue propValue(CJS_Value(pRuntime, value, CJS_Value::VT_unknown)); propValue.StartSetting(); if (!(pObj->*M)(pContext, propValue, sError)) { FXJS_Error(isolate, JSFormatErrorString(class_name_string, prop_name_string, @@ -143,15 +145,16 @@ void JSMethod(const char* method_name_string, const char* class_name_string, const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Isolate* isolate = info.GetIsolate(); - IJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); + CJS_Runtime* pRuntime = + static_cast<CJS_Runtime*>(FXJS_GetRuntimeFromIsolate(isolate)); if (!pRuntime) return; IJS_Context* cc = pRuntime->GetCurrentContext(); CJS_Parameters parameters; for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) { - parameters.push_back(CJS_Value(isolate, info[i], CJS_Value::VT_unknown)); + parameters.push_back(CJS_Value(pRuntime, info[i], CJS_Value::VT_unknown)); } - CJS_Value valueRes(isolate); + CJS_Value valueRes(pRuntime); CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder()); C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); CFX_WideString sError; @@ -365,7 +368,8 @@ void JSSpecialPropGet(const char* class_name, v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value>& info) { v8::Isolate* isolate = info.GetIsolate(); - IJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); + CJS_Runtime* pRuntime = + static_cast<CJS_Runtime*>(FXJS_GetRuntimeFromIsolate(isolate)); if (!pRuntime) return; IJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); @@ -376,7 +380,7 @@ void JSSpecialPropGet(const char* class_name, CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_value.length()); CFX_WideString sError; - CJS_PropValue value(isolate); + CJS_PropValue value(pRuntime); value.StartGetting(); if (!pObj->DoProperty(pRuntimeContext, propname.c_str(), value, sError)) { FXJS_Error(isolate, JSFormatErrorString(class_name, "GetProperty", sError)); @@ -391,7 +395,8 @@ void JSSpecialPropPut(const char* class_name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info) { v8::Isolate* isolate = info.GetIsolate(); - IJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); + CJS_Runtime* pRuntime = + static_cast<CJS_Runtime*>(FXJS_GetRuntimeFromIsolate(isolate)); if (!pRuntime) return; IJS_Context* pRuntimeContext = pRuntime->GetCurrentContext(); @@ -402,7 +407,7 @@ void JSSpecialPropPut(const char* class_name, CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_value.length()); CFX_WideString sError; - CJS_PropValue PropValue(CJS_Value(isolate, value, CJS_Value::VT_unknown)); + CJS_PropValue PropValue(CJS_Value(pRuntime, value, CJS_Value::VT_unknown)); PropValue.StartSetting(); if (!pObj->DoProperty(pRuntimeContext, propname.c_str(), PropValue, sError)) { FXJS_Error(isolate, JSFormatErrorString(class_name, "PutProperty", sError)); @@ -438,19 +443,20 @@ template <FX_BOOL (*F)(IJS_Context* cc, CFX_WideString& sError)> void JSGlobalFunc(const char* func_name_string, const v8::FunctionCallbackInfo<v8::Value>& info) { - v8::Isolate* isolate = info.GetIsolate(); - IJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); + CJS_Runtime* pRuntime = + static_cast<CJS_Runtime*>(FXJS_GetRuntimeFromIsolate(info.GetIsolate())); if (!pRuntime) return; IJS_Context* cc = pRuntime->GetCurrentContext(); CJS_Parameters parameters; for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) { - parameters.push_back(CJS_Value(isolate, info[i], CJS_Value::VT_unknown)); + parameters.push_back(CJS_Value(pRuntime, info[i], CJS_Value::VT_unknown)); } - CJS_Value valueRes(isolate); + CJS_Value valueRes(pRuntime); CFX_WideString sError; if (!(*F)(cc, parameters, valueRes, sError)) { - FXJS_Error(isolate, JSFormatErrorString(func_name_string, nullptr, sError)); + FXJS_Error(pRuntime->GetIsolate(), + JSFormatErrorString(func_name_string, nullptr, sError)); return; } info.GetReturnValue().Set(valueRes.ToV8Value()); |