From a4941914bb4411dc4e9053cb344e0349db388007 Mon Sep 17 00:00:00 2001 From: tsepez Date: Mon, 15 Aug 2016 11:40:12 -0700 Subject: Move some v8 objects from CJS back into FXJS Create a new class to hold these, CFXJS_Engine (could have been called Runtime, but there are too many "Runtimes" already). In a subsequent patch, all the FXJS_*() functions that take an isolate as the first argument can become methods on the engine. CJS_ must still manage the isolates; this happens outside the engine. The IJS_Runtime abstraction moves up to fpdfsdk/javascript; it remains to allow for either a real JS library or a stubb one to be linked (for non-js builds). Review-Url: https://codereview.chromium.org/2241483004 --- fpdfsdk/javascript/JS_Define.h | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'fpdfsdk/javascript/JS_Define.h') diff --git a/fpdfsdk/javascript/JS_Define.h b/fpdfsdk/javascript/JS_Define.h index 4c24a4de7b..b9ae1408f6 100644 --- a/fpdfsdk/javascript/JS_Define.h +++ b/fpdfsdk/javascript/JS_Define.h @@ -78,7 +78,7 @@ void JSPropGetter(const char* prop_name_string, const v8::PropertyCallbackInfo& info) { v8::Isolate* isolate = info.GetIsolate(); CJS_Runtime* pRuntime = - static_cast(FXJS_GetRuntimeFromIsolate(isolate)); + static_cast(FXJS_GetCurrentEngineFromIsolate(isolate)); if (!pRuntime) return; IJS_Context* pContext = pRuntime->GetCurrentContext(); @@ -104,7 +104,7 @@ void JSPropSetter(const char* prop_name_string, const v8::PropertyCallbackInfo& info) { v8::Isolate* isolate = info.GetIsolate(); CJS_Runtime* pRuntime = - static_cast(FXJS_GetRuntimeFromIsolate(isolate)); + static_cast(FXJS_GetCurrentEngineFromIsolate(isolate)); if (!pRuntime) return; IJS_Context* pContext = pRuntime->GetCurrentContext(); @@ -143,7 +143,7 @@ void JSMethod(const char* method_name_string, const v8::FunctionCallbackInfo& info) { v8::Isolate* isolate = info.GetIsolate(); CJS_Runtime* pRuntime = - static_cast(FXJS_GetRuntimeFromIsolate(isolate)); + static_cast(FXJS_GetCurrentEngineFromIsolate(isolate)); if (!pRuntime) return; IJS_Context* pContext = pRuntime->GetCurrentContext(); @@ -245,7 +245,7 @@ void JSMethod(const char* method_name_string, } #define DECLARE_JS_CLASS_RICH_PART() \ - static void JSConstructor(IJS_Runtime* pRuntime, v8::Local obj); \ + static void JSConstructor(CFXJS_Engine* pEngine, v8::Local obj); \ static void JSDestructor(v8::Local obj); \ static void DefineProps(v8::Isolate* pIsoalte); \ static void DefineMethods(v8::Isolate* pIsoalte); \ @@ -254,12 +254,12 @@ void JSMethod(const char* method_name_string, #define IMPLEMENT_JS_CLASS_RICH_PART(js_class_name, class_alternate, \ class_name) \ - void js_class_name::JSConstructor(IJS_Runtime* pIRuntime, \ + void js_class_name::JSConstructor(CFXJS_Engine* pEngine, \ v8::Local obj) { \ CJS_Object* pObj = new js_class_name(obj); \ pObj->SetEmbedObject(new class_alternate(pObj)); \ FXJS_SetPrivate(nullptr, obj, (void*)pObj); \ - pObj->InitInstance(pIRuntime); \ + pObj->InitInstance(static_cast(pEngine)); \ } \ void js_class_name::JSDestructor(v8::Local obj) { \ js_class_name* pObj = (js_class_name*)FXJS_GetPrivate(nullptr, obj); \ @@ -366,7 +366,7 @@ void JSSpecialPropGet(const char* class_name, const v8::PropertyCallbackInfo& info) { v8::Isolate* isolate = info.GetIsolate(); CJS_Runtime* pRuntime = - static_cast(FXJS_GetRuntimeFromIsolate(isolate)); + static_cast(FXJS_GetCurrentEngineFromIsolate(isolate)); if (!pRuntime) return; IJS_Context* pContext = pRuntime->GetCurrentContext(); @@ -393,7 +393,7 @@ void JSSpecialPropPut(const char* class_name, const v8::PropertyCallbackInfo& info) { v8::Isolate* isolate = info.GetIsolate(); CJS_Runtime* pRuntime = - static_cast(FXJS_GetRuntimeFromIsolate(isolate)); + static_cast(FXJS_GetCurrentEngineFromIsolate(isolate)); if (!pRuntime) return; IJS_Context* pContext = pRuntime->GetCurrentContext(); @@ -416,7 +416,8 @@ void JSSpecialPropDel(const char* class_name, v8::Local property, const v8::PropertyCallbackInfo& info) { v8::Isolate* isolate = info.GetIsolate(); - IJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate); + CJS_Runtime* pRuntime = + static_cast(FXJS_GetCurrentEngineFromIsolate(isolate)); if (!pRuntime) return; IJS_Context* pContext = pRuntime->GetCurrentContext(); @@ -440,8 +441,8 @@ template void JSGlobalFunc(const char* func_name_string, const v8::FunctionCallbackInfo& info) { - CJS_Runtime* pRuntime = - static_cast(FXJS_GetRuntimeFromIsolate(info.GetIsolate())); + CJS_Runtime* pRuntime = static_cast( + FXJS_GetCurrentEngineFromIsolate(info.GetIsolate())); if (!pRuntime) return; IJS_Context* pContext = pRuntime->GetCurrentContext(); -- cgit v1.2.3