From b4694249b336d1c0bea9222880b49dcf9284791d Mon Sep 17 00:00:00 2001 From: tsepez Date: Mon, 15 Aug 2016 16:44:55 -0700 Subject: Push v8::Isolate into CFXJS_Engine class Nearly all the "loose" functions in FXJS become methods on the CFJXS_Engine. This is the "missing link" wrt some layering violatons that have been around forever. We can stop passing &m_ variables from CJS_ down into FXJS Initialization as a result. Review-Url: https://codereview.chromium.org/2245863002 --- fpdfsdk/javascript/Consts.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'fpdfsdk/javascript/Consts.cpp') diff --git a/fpdfsdk/javascript/Consts.cpp b/fpdfsdk/javascript/Consts.cpp index 19988a61ea..c224ad0de8 100644 --- a/fpdfsdk/javascript/Consts.cpp +++ b/fpdfsdk/javascript/Consts.cpp @@ -99,11 +99,12 @@ JS_STATIC_CONST_ENTRY_STRING(L"refW", L"ReflowWidth") END_JS_STATIC_CONST() IMPLEMENT_JS_CLASS_CONST(CJS_Zoomtype, zoomtype) -#define GLOBAL_STRING(rt, name, value) \ - FXJS_DefineGlobalConst( \ - (rt)->GetIsolate(), (name), \ - [](const v8::FunctionCallbackInfo& info) { \ - info.GetReturnValue().Set(FXJS_NewString(info.GetIsolate(), (value))); \ +#define GLOBAL_STRING(rt, name, value) \ + (rt)->DefineGlobalConst( \ + (name), [](const v8::FunctionCallbackInfo& info) { \ + info.GetReturnValue().Set( \ + CFXJS_Engine::CurrentEngineFromIsolate(info.GetIsolate()) \ + ->NewString(value)); \ }) void CJS_GlobalConsts::DefineJSObjects(CJS_Runtime* pRuntime) { @@ -137,21 +138,20 @@ void CJS_GlobalConsts::DefineJSObjects(CJS_Runtime* pRuntime) { GLOBAL_STRING(pRuntime, L"IDS_STARTUP_CONSOLE_MSG", L"** ^ _ ^ **"); } -#define GLOBAL_ARRAY(rt, name, ...) \ - { \ - const FX_WCHAR* values[] = {__VA_ARGS__}; \ - v8::Local array = FXJS_NewArray((rt)->GetIsolate()); \ - for (size_t i = 0; i < FX_ArraySize(values); ++i) \ - array->Set(i, FXJS_NewString((rt)->GetIsolate(), values[i])); \ - rt->SetConstArray(name, array); \ - FXJS_DefineGlobalConst( \ - (rt)->GetIsolate(), (name), \ - [](const v8::FunctionCallbackInfo& info) { \ - CJS_Runtime* pLocalRuntime = static_cast( \ - FXJS_GetCurrentEngineFromIsolate(info.GetIsolate())); \ - if (pLocalRuntime) \ - info.GetReturnValue().Set(pLocalRuntime->GetConstArray(name)); \ - }); \ +#define GLOBAL_ARRAY(rt, name, ...) \ + { \ + const FX_WCHAR* values[] = {__VA_ARGS__}; \ + v8::Local array = (rt)->NewArray(); \ + for (size_t i = 0; i < FX_ArraySize(values); ++i) \ + array->Set(i, (rt)->NewString(values[i])); \ + (rt)->SetConstArray((name), array); \ + (rt)->DefineGlobalConst( \ + (name), [](const v8::FunctionCallbackInfo& info) { \ + CJS_Runtime* pCurrentRuntime = \ + CJS_Runtime::CurrentRuntimeFromIsolate(info.GetIsolate()); \ + if (pCurrentRuntime) \ + info.GetReturnValue().Set(pCurrentRuntime->GetConstArray(name)); \ + }); \ } void CJS_GlobalArrays::DefineJSObjects(CJS_Runtime* pRuntime) { -- cgit v1.2.3