Remove pointer to isolate from CFXJSE_Value Task #1 from the referenced bug. Bug: pdfium:1610 Change-Id: I44a6347e9384216f08baeaa879fd774587816f15 Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/75870 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Daniel Hosseinian <dhoss@chromium.org>
diff --git a/fxjs/xfa/cfxjse_class.cpp b/fxjs/xfa/cfxjse_class.cpp index 86512c5..21c4258 100644 --- a/fxjs/xfa/cfxjse_class.cpp +++ b/fxjs/xfa/cfxjse_class.cpp
@@ -122,10 +122,10 @@ int32_t nPropType = lpClass->dynPropTypeGetter == nullptr ? FXJSE_ClassPropType_Property - : lpClass->dynPropTypeGetter(pObject, szPropName, false); + : lpClass->dynPropTypeGetter(pIsolate, pObject, szPropName, false); if (nPropType == FXJSE_ClassPropType_Property) { if (lpClass->dynPropGetter) - lpClass->dynPropGetter(pObject, szPropName, pValue); + lpClass->dynPropGetter(pIsolate, pObject, szPropName, pValue); } else if (nPropType == FXJSE_ClassPropType_Method) { if (lpClass->dynMethodCall && pValue) { v8::HandleScope hscope(pIsolate); @@ -140,6 +140,7 @@ hCallBackInfo->SetInternalField( 1, fxv8::NewStringHelper(pIsolate, szPropName)); pValue->ForceSetValue( + pIsolate, v8::Function::New(pIsolate->GetCurrentContext(), DynPropGetterAdapter_MethodCallback, hCallBackInfo, 0, v8::ConstructorBehavior::kThrow) @@ -148,7 +149,8 @@ } } -void DynPropSetterAdapter(const FXJSE_CLASS_DESCRIPTOR* lpClass, +void DynPropSetterAdapter(v8::Isolate* pIsolate, + const FXJSE_CLASS_DESCRIPTOR* lpClass, CFXJSE_Value* pObject, ByteStringView szPropName, CFXJSE_Value* pValue) { @@ -156,21 +158,22 @@ int32_t nPropType = lpClass->dynPropTypeGetter == nullptr ? FXJSE_ClassPropType_Property - : lpClass->dynPropTypeGetter(pObject, szPropName, false); + : lpClass->dynPropTypeGetter(pIsolate, pObject, szPropName, false); if (nPropType != FXJSE_ClassPropType_Method) { if (lpClass->dynPropSetter) - lpClass->dynPropSetter(pObject, szPropName, pValue); + lpClass->dynPropSetter(pIsolate, pObject, szPropName, pValue); } } -bool DynPropQueryAdapter(const FXJSE_CLASS_DESCRIPTOR* lpClass, +bool DynPropQueryAdapter(v8::Isolate* pIsolate, + const FXJSE_CLASS_DESCRIPTOR* lpClass, CFXJSE_Value* pObject, ByteStringView szPropName) { ASSERT(lpClass); int32_t nPropType = lpClass->dynPropTypeGetter == nullptr ? FXJSE_ClassPropType_Property - : lpClass->dynPropTypeGetter(pObject, szPropName, true); + : lpClass->dynPropTypeGetter(pIsolate, pObject, szPropName, true); return nPropType != FXJSE_ClassPropType_None; } @@ -187,8 +190,9 @@ v8::String::Utf8Value szPropName(info.GetIsolate(), property); ByteStringView szFxPropName(*szPropName, szPropName.length()); auto lpThisValue = std::make_unique<CFXJSE_Value>(info.GetIsolate()); - lpThisValue->ForceSetValue(thisObject); - if (DynPropQueryAdapter(lpClass, lpThisValue.get(), szFxPropName)) { + lpThisValue->ForceSetValue(info.GetIsolate(), thisObject); + if (DynPropQueryAdapter(info.GetIsolate(), lpClass, lpThisValue.get(), + szFxPropName)) { info.GetReturnValue().Set(v8::DontDelete); return; } @@ -208,7 +212,7 @@ v8::String::Utf8Value szPropName(info.GetIsolate(), property); ByteStringView szFxPropName(*szPropName, szPropName.length()); auto lpThisValue = std::make_unique<CFXJSE_Value>(info.GetIsolate()); - lpThisValue->ForceSetValue(thisObject); + lpThisValue->ForceSetValue(info.GetIsolate(), thisObject); auto lpNewValue = std::make_unique<CFXJSE_Value>(info.GetIsolate()); DynPropGetterAdapter(info.GetIsolate(), lpClass, lpThisValue.get(), szFxPropName, lpNewValue.get()); @@ -228,11 +232,11 @@ v8::String::Utf8Value szPropName(info.GetIsolate(), property); ByteStringView szFxPropName(*szPropName, szPropName.length()); auto lpThisValue = std::make_unique<CFXJSE_Value>(info.GetIsolate()); - lpThisValue->ForceSetValue(thisObject); + lpThisValue->ForceSetValue(info.GetIsolate(), thisObject); auto lpNewValue = std::make_unique<CFXJSE_Value>(info.GetIsolate()); - lpNewValue->ForceSetValue(value); - DynPropSetterAdapter(lpClass, lpThisValue.get(), szFxPropName, - lpNewValue.get()); + lpNewValue->ForceSetValue(info.GetIsolate(), value); + DynPropSetterAdapter(info.GetIsolate(), lpClass, lpThisValue.get(), + szFxPropName, lpNewValue.get()); info.GetReturnValue().Set(value); }
diff --git a/fxjs/xfa/cfxjse_context.cpp b/fxjs/xfa/cfxjse_context.cpp index 27196b4..54fd290 100644 --- a/fxjs/xfa/cfxjse_context.cpp +++ b/fxjs/xfa/cfxjse_context.cpp
@@ -224,7 +224,7 @@ v8::Local<v8::Context>::New(GetIsolate(), m_hContext); v8::Local<v8::Object> hGlobalObject = hContext->Global()->GetPrototype().As<v8::Object>(); - pValue->ForceSetValue(hGlobalObject); + pValue->ForceSetValue(GetIsolate(), hGlobalObject); return pValue; } @@ -266,12 +266,13 @@ if (hScript->Run(hContext).ToLocal(&hValue)) { ASSERT(!trycatch.HasCaught()); if (lpRetValue) - lpRetValue->ForceSetValue(hValue); + lpRetValue->ForceSetValue(GetIsolate(), hValue); return true; } } if (lpRetValue) - lpRetValue->ForceSetValue(CreateReturnValue(GetIsolate(), &trycatch)); + lpRetValue->ForceSetValue(GetIsolate(), + CreateReturnValue(GetIsolate(), &trycatch)); return false; } @@ -292,7 +293,7 @@ .ToLocal(&hValue)) { ASSERT(!trycatch.HasCaught()); if (lpRetValue) - lpRetValue->ForceSetValue(hValue); + lpRetValue->ForceSetValue(GetIsolate(), hValue); return true; } } @@ -311,7 +312,9 @@ } #endif // NDEBUG - if (lpRetValue) - lpRetValue->ForceSetValue(CreateReturnValue(GetIsolate(), &trycatch)); + if (lpRetValue) { + lpRetValue->ForceSetValue(GetIsolate(), + CreateReturnValue(GetIsolate(), &trycatch)); + } return false; }
diff --git a/fxjs/xfa/cfxjse_engine.cpp b/fxjs/xfa/cfxjse_engine.cpp index 46ed7bf..7764232 100644 --- a/fxjs/xfa/cfxjse_engine.cpp +++ b/fxjs/xfa/cfxjse_engine.cpp
@@ -77,11 +77,12 @@ // static CXFA_Object* CFXJSE_Engine::ToObject( const v8::FunctionCallbackInfo<v8::Value>& info) { - return ToObject(info.Holder()); + return ToObject(info.GetIsolate(), info.Holder()); } // static -CXFA_Object* CFXJSE_Engine::ToObject(v8::Local<v8::Value> value) { +CXFA_Object* CFXJSE_Engine::ToObject(v8::Isolate* pIsolate, + v8::Local<v8::Value> value) { if (!value->IsObject()) return nullptr; @@ -89,8 +90,9 @@ } // static. -CXFA_Object* CFXJSE_Engine::ToObject(CFXJSE_Value* pValue) { - return ToObject(pValue->ToHostObject()); +CXFA_Object* CFXJSE_Engine::ToObject(v8::Isolate* pIsolate, + CFXJSE_Value* pValue) { + return ToObject(pValue->ToHostObject(pIsolate)); } // static @@ -125,7 +127,7 @@ // This is what ensures that the v8 object bound to a CJX_Object // no longer retains that binding since it will outlive that object. for (const auto& pair : m_mapObjectToValue) - pair.second->ClearHostObject(); + pair.second->ClearHostObject(GetIsolate()); } bool CFXJSE_Engine::RunScript(CXFA_Script::Type eScriptType, @@ -143,7 +145,7 @@ Optional<CFX_WideTextBuf> wsJavaScript = CFXJSE_FormCalcContext::Translate(m_pDocument->GetHeap(), wsScript); if (!wsJavaScript.has_value()) { - hRetValue->SetUndefined(); + hRetValue->SetUndefined(GetIsolate()); return false; } btScript = FX_UTF8Encode(wsJavaScript.value().AsStringView()); @@ -171,24 +173,26 @@ if (!ResolveObjects(refNode, propname, &resolveRs, dwFlag, nullptr)) return false; if (resolveRs.dwFlags == XFA_ResolveNodeRS::Type::kNodes) { - pValue->Assign( - GetOrCreateJSBindingFromMap(resolveRs.objects.front().Get())); + pValue->Assign(GetIsolate(), GetOrCreateJSBindingFromMap( + resolveRs.objects.front().Get())); return true; } if (resolveRs.dwFlags == XFA_ResolveNodeRS::Type::kAttribute && resolveRs.script_attribute.callback) { CJX_Object* jsObject = resolveRs.objects.front()->JSObject(); (*resolveRs.script_attribute.callback)( - jsObject, pValue, bSetting, resolveRs.script_attribute.attribute); + GetIsolate(), jsObject, pValue, bSetting, + resolveRs.script_attribute.attribute); } return true; } // static -void CFXJSE_Engine::GlobalPropertySetter(CFXJSE_Value* pObject, +void CFXJSE_Engine::GlobalPropertySetter(v8::Isolate* pIsolate, + CFXJSE_Value* pObject, ByteStringView szPropName, CFXJSE_Value* pValue) { - CXFA_Object* lpOrginalNode = ToObject(pObject); + CXFA_Object* lpOrginalNode = ToObject(pIsolate, pObject); CXFA_Document* pDoc = lpOrginalNode->GetDocument(); CFXJSE_Engine* lpScriptContext = pDoc->GetScriptContext(); CXFA_Node* pRefNode = ToNode(lpScriptContext->GetThisObject()); @@ -204,8 +208,8 @@ true)) { return; } - if (lpOrginalNode->IsThisProxy() && pValue && pValue->IsUndefined()) { - pObject->DeleteObjectProperty(szPropName); + if (lpOrginalNode->IsThisProxy() && pValue && pValue->IsUndefined(pIsolate)) { + pObject->DeleteObjectProperty(lpScriptContext->GetIsolate(), szPropName); return; } CXFA_FFNotify* pNotify = pDoc->GetNotify(); @@ -225,15 +229,16 @@ } // static -void CFXJSE_Engine::GlobalPropertyGetter(CFXJSE_Value* pObject, +void CFXJSE_Engine::GlobalPropertyGetter(v8::Isolate* pIsolate, + CFXJSE_Value* pObject, ByteStringView szPropName, CFXJSE_Value* pValue) { - CXFA_Object* pOriginalObject = ToObject(pObject); + CXFA_Object* pOriginalObject = ToObject(pIsolate, pObject); CXFA_Document* pDoc = pOriginalObject->GetDocument(); CFXJSE_Engine* lpScriptContext = pDoc->GetScriptContext(); WideString wsPropName = WideString::FromUTF8(szPropName); - pValue->SetUndefined(); // Assume failure. + pValue->SetUndefined(pIsolate); // Assume failure. if (lpScriptContext->GetType() == CXFA_Script::Type::Formcalc) { if (szPropName == kFormCalcRuntime) { lpScriptContext->m_FM2JSContext->GlobalPropertyGetter(pValue); @@ -245,7 +250,8 @@ CXFA_Object* pObj = lpScriptContext->GetDocument()->GetXFAObject(uHashCode); if (pObj) { - pValue->Assign(lpScriptContext->GetOrCreateJSBindingFromMap(pObj)); + pValue->Assign(pIsolate, + lpScriptContext->GetOrCreateJSBindingFromMap(pObj)); return; } } @@ -293,13 +299,15 @@ if (temp_value.IsEmpty()) return; - pValue->ForceSetValue(temp_value); + pValue->ForceSetValue(pIsolate, temp_value); } -int32_t CFXJSE_Engine::GlobalPropTypeGetter(CFXJSE_Value* pOriginalValue, +// static +int32_t CFXJSE_Engine::GlobalPropTypeGetter(v8::Isolate* pIsolate, + CFXJSE_Value* pOriginalValue, ByteStringView szPropName, bool bQueryIn) { - CXFA_Object* pObject = ToObject(pOriginalValue); + CXFA_Object* pObject = ToObject(pIsolate, pOriginalValue); if (!pObject) return FXJSE_ClassPropType_None; @@ -313,11 +321,12 @@ } // static -void CFXJSE_Engine::NormalPropertyGetter(CFXJSE_Value* pOriginalValue, +void CFXJSE_Engine::NormalPropertyGetter(v8::Isolate* pIsolate, + CFXJSE_Value* pOriginalValue, ByteStringView szPropName, CFXJSE_Value* pReturnValue) { - pReturnValue->SetUndefined(); // Assume failure. - CXFA_Object* pOriginalObject = ToObject(pOriginalValue); + pReturnValue->SetUndefined(pIsolate); // Assume failure. + CXFA_Object* pOriginalObject = ToObject(pIsolate, pOriginalValue); if (!pOriginalObject) return; @@ -328,7 +337,7 @@ if (wsPropName.EqualsASCII("xfa")) { CFXJSE_Value* pValue = lpScriptContext->GetOrCreateJSBindingFromMap( lpScriptContext->GetDocument()->GetRoot()); - pReturnValue->Assign(pValue); + pReturnValue->Assign(pIsolate, pValue); return; } @@ -364,7 +373,7 @@ pObject->GetElementType(), wsPropName.AsStringView()); if (info.has_value()) { CJX_Object* jsObject = pObject->JSObject(); - (*info.value().callback)(jsObject, pReturnValue, false, + (*info.value().callback)(pIsolate, jsObject, pReturnValue, false, info.value().attribute); return; } @@ -387,14 +396,15 @@ if (temp_local.IsEmpty()) return; - pReturnValue->ForceSetValue(temp_local); + pReturnValue->ForceSetValue(lpScriptContext->GetIsolate(), temp_local); } // static -void CFXJSE_Engine::NormalPropertySetter(CFXJSE_Value* pOriginalValue, +void CFXJSE_Engine::NormalPropertySetter(v8::Isolate* pIsolate, + CFXJSE_Value* pOriginalValue, ByteStringView szPropName, CFXJSE_Value* pReturnValue) { - CXFA_Object* pOriginalObject = ToObject(pOriginalValue); + CXFA_Object* pOriginalObject = ToObject(pIsolate, pOriginalValue); if (!pOriginalObject) return; @@ -407,7 +417,7 @@ XFA_GetScriptAttributeByName(pObject->GetElementType(), wsPropNameView); if (info.has_value()) { CJX_Object* jsObject = pObject->JSObject(); - (*info.value().callback)(jsObject, pReturnValue, true, + (*info.value().callback)(pIsolate, jsObject, pReturnValue, true, info.value().attribute); return; } @@ -430,8 +440,8 @@ info = XFA_GetScriptAttributeByName(pPropOrChild->GetElementType(), L"{default}"); if (info.has_value()) { - pPropOrChild->JSObject()->ScriptSomDefaultValue(pReturnValue, true, - XFA_Attribute::Unknown); + pPropOrChild->JSObject()->ScriptSomDefaultValue( + pIsolate, pReturnValue, true, XFA_Attribute::Unknown); return; } } @@ -445,10 +455,11 @@ } } -int32_t CFXJSE_Engine::NormalPropTypeGetter(CFXJSE_Value* pOriginalValue, +int32_t CFXJSE_Engine::NormalPropTypeGetter(v8::Isolate* pIsolate, + CFXJSE_Value* pOriginalValue, ByteStringView szPropName, bool bQueryIn) { - CXFA_Object* pObject = ToObject(pOriginalValue); + CXFA_Object* pObject = ToObject(pIsolate, pOriginalValue); if (!pObject) return FXJSE_ClassPropType_None; @@ -573,20 +584,20 @@ std::unique_ptr<CFXJSE_Value> pObject = pVariableContext->GetGlobalObject(); auto hVariableValue = std::make_unique<CFXJSE_Value>(GetIsolate()); if (!bGetter) { - pObject->SetObjectOwnProperty(szPropName, pValue); + pObject->SetObjectOwnProperty(GetIsolate(), szPropName, pValue); return true; } - if (!pObject->HasObjectOwnProperty(szPropName, false)) + if (!pObject->HasObjectOwnProperty(GetIsolate(), szPropName, false)) return false; - pObject->GetObjectProperty(szPropName, hVariableValue.get()); - if (hVariableValue->IsFunction()) - pValue->SetFunctionBind(hVariableValue.get(), pObject.get()); + pObject->GetObjectProperty(GetIsolate(), szPropName, hVariableValue.get()); + if (hVariableValue->IsFunction(GetIsolate())) + pValue->SetFunctionBind(GetIsolate(), hVariableValue.get(), pObject.get()); else if (bGetter) - pValue->Assign(hVariableValue.get()); + pValue->Assign(GetIsolate(), hVariableValue.get()); else - hVariableValue.get()->Assign(pValue); + hVariableValue.get()->Assign(GetIsolate(), pValue); return true; } @@ -595,8 +606,8 @@ std::unique_ptr<CFXJSE_Value> pObject = pContext->GetGlobalObject(); auto hProp = std::make_unique<CFXJSE_Value>(GetIsolate()); for (const auto& obj : kObjNames) { - if (pObject->GetObjectProperty(obj, hProp.get())) - pObject->DeleteObjectProperty(obj); + if (pObject->GetObjectProperty(GetIsolate(), obj, hProp.get())) + pObject->DeleteObjectProperty(GetIsolate(), obj); } } @@ -685,7 +696,7 @@ rndFind.m_CurObject = findObjects[i++].Get(); rndFind.m_nLevel = nLevel; rndFind.m_dwFlag = XFA_ResolveNodeRS::Type::kNodes; - if (!m_ResolveProcessor->Resolve(rndFind)) + if (!m_ResolveProcessor->Resolve(GetIsolate(), rndFind)) continue; if (rndFind.m_dwFlag == XFA_ResolveNodeRS::Type::kAttribute && @@ -695,9 +706,10 @@ auto pValue = std::make_unique<CFXJSE_Value>(GetIsolate()); CJX_Object* jsObject = rndFind.m_Objects.front()->JSObject(); (*rndFind.m_ScriptAttribute.callback)( - jsObject, pValue.get(), false, rndFind.m_ScriptAttribute.attribute); + GetIsolate(), jsObject, pValue.get(), false, + rndFind.m_ScriptAttribute.attribute); if (!pValue->IsEmpty()) - rndFind.m_Objects.front() = ToObject(pValue.get()); + rndFind.m_Objects.front() = ToObject(GetIsolate(), pValue.get()); } if (!m_upObjectArray.empty()) m_upObjectArray.pop_back(); @@ -777,7 +789,7 @@ return iter->second.get(); auto jsValue = std::make_unique<CFXJSE_Value>(GetIsolate()); - jsValue->SetHostObject(pCJXObject, m_pJsClass.Get()); + jsValue->SetHostObject(GetIsolate(), pCJXObject, m_pJsClass.Get()); CFXJSE_Value* pValue = jsValue.get(); m_mapObjectToValue[pCJXObject] = std::move(jsValue);
diff --git a/fxjs/xfa/cfxjse_engine.h b/fxjs/xfa/cfxjse_engine.h index ba3c2a8..19e5225 100644 --- a/fxjs/xfa/cfxjse_engine.h +++ b/fxjs/xfa/cfxjse_engine.h
@@ -43,28 +43,35 @@ class CFXJSE_Engine final : public CFX_V8 { public: static CXFA_Object* ToObject(const v8::FunctionCallbackInfo<v8::Value>& info); - static CXFA_Object* ToObject(v8::Local<v8::Value> value); - static CXFA_Object* ToObject(CFXJSE_Value* pValue); + static CXFA_Object* ToObject(v8::Isolate* pIsolate, + v8::Local<v8::Value> value); + static CXFA_Object* ToObject(v8::Isolate* pIsolate, CFXJSE_Value* pValue); static CXFA_Object* ToObject(CFXJSE_HostObject* pHostObj); - static void GlobalPropertyGetter(CFXJSE_Value* pObject, + static void GlobalPropertyGetter(v8::Isolate* pIsolate, + CFXJSE_Value* pObject, ByteStringView szPropName, CFXJSE_Value* pValue); - static void GlobalPropertySetter(CFXJSE_Value* pObject, + static void GlobalPropertySetter(v8::Isolate* pIsolate, + CFXJSE_Value* pObject, ByteStringView szPropName, CFXJSE_Value* pValue); - static void NormalPropertyGetter(CFXJSE_Value* pObject, + static void NormalPropertyGetter(v8::Isolate* pIsolate, + CFXJSE_Value* pObject, ByteStringView szPropName, CFXJSE_Value* pValue); - static void NormalPropertySetter(CFXJSE_Value* pObject, + static void NormalPropertySetter(v8::Isolate* pIsolate, + CFXJSE_Value* pObject, ByteStringView szPropName, CFXJSE_Value* pValue); static CJS_Result NormalMethodCall( const v8::FunctionCallbackInfo<v8::Value>& info, const WideString& functionName); - static int32_t NormalPropTypeGetter(CFXJSE_Value* pObject, + static int32_t NormalPropTypeGetter(v8::Isolate* pIsolate, + CFXJSE_Value* pObject, ByteStringView szPropName, bool bQueryIn); - static int32_t GlobalPropTypeGetter(CFXJSE_Value* pObject, + static int32_t GlobalPropTypeGetter(v8::Isolate* pIsolate, + CFXJSE_Value* pObject, ByteStringView szPropName, bool bQueryIn);
diff --git a/fxjs/xfa/cfxjse_formcalc_context.cpp b/fxjs/xfa/cfxjse_formcalc_context.cpp index ea79b20..0052af5 100644 --- a/fxjs/xfa/cfxjse_formcalc_context.cpp +++ b/fxjs/xfa/cfxjse_formcalc_context.cpp
@@ -1319,22 +1319,26 @@ return ByteString(strBuf); } -void GetObjectDefaultValue(CFXJSE_Value* pValue, CFXJSE_Value* pDefaultValue) { - CXFA_Node* pNode = ToNode(CFXJSE_Engine::ToObject(pValue)); +void GetObjectDefaultValue(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, + CFXJSE_Value* pDefaultValue) { + CXFA_Node* pNode = ToNode(CFXJSE_Engine::ToObject(pIsolate, pValue)); if (!pNode) { - pDefaultValue->SetNull(); + pDefaultValue->SetNull(pIsolate); return; } - pNode->JSObject()->ScriptSomDefaultValue(pDefaultValue, false, + pNode->JSObject()->ScriptSomDefaultValue(pIsolate, pDefaultValue, false, XFA_Attribute::Unknown); } -bool SetObjectDefaultValue(CFXJSE_Value* pValue, CFXJSE_Value* hNewValue) { - CXFA_Node* pNode = ToNode(CFXJSE_Engine::ToObject(pValue)); +bool SetObjectDefaultValue(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, + CFXJSE_Value* hNewValue) { + CXFA_Node* pNode = ToNode(CFXJSE_Engine::ToObject(pIsolate, pValue)); if (!pNode) return false; - pNode->JSObject()->ScriptSomDefaultValue(hNewValue, true, + pNode->JSObject()->ScriptSomDefaultValue(pIsolate, hNewValue, true, XFA_Attribute::Unknown); return true; } @@ -1362,7 +1366,7 @@ } auto argOne = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[0]); - if (ValueIsNull(pThis, argOne.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argOne.get())) { info.GetReturnValue().SetNull(); return; } @@ -1383,35 +1387,36 @@ return; } - v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetScriptRuntime(); + v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetIsolate(); uint32_t uCount = 0; double dSum = 0.0; for (int32_t i = 0; i < argc; i++) { auto argValue = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[i]); - if (argValue->IsNull()) + if (argValue->IsNull(pIsolate)) continue; - if (!argValue->IsArray()) { + if (!argValue->IsArray(pIsolate)) { dSum += ValueToDouble(pThis, argValue.get()); uCount++; continue; } auto lengthValue = std::make_unique<CFXJSE_Value>(pIsolate); - argValue->GetObjectProperty("length", lengthValue.get()); - int32_t iLength = lengthValue->ToInteger(); + argValue->GetObjectProperty(pIsolate, "length", lengthValue.get()); + int32_t iLength = lengthValue->ToInteger(pIsolate); if (iLength > 2) { auto propertyValue = std::make_unique<CFXJSE_Value>(pIsolate); - argValue->GetObjectPropertyByIdx(1, propertyValue.get()); + argValue->GetObjectPropertyByIdx(pIsolate, 1, propertyValue.get()); auto jsObjectValue = std::make_unique<CFXJSE_Value>(pIsolate); - if (propertyValue->IsNull()) { + if (propertyValue->IsNull(pIsolate)) { for (int32_t j = 2; j < iLength; j++) { - argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); + argValue->GetObjectPropertyByIdx(pIsolate, j, jsObjectValue.get()); auto defaultPropValue = std::make_unique<CFXJSE_Value>(pIsolate); - GetObjectDefaultValue(jsObjectValue.get(), defaultPropValue.get()); - if (defaultPropValue->IsNull()) + GetObjectDefaultValue(pIsolate, jsObjectValue.get(), + defaultPropValue.get()); + if (defaultPropValue->IsNull(pIsolate)) continue; dSum += ValueToDouble(pThis, defaultPropValue.get()); @@ -1419,11 +1424,12 @@ } } else { for (int32_t j = 2; j < iLength; j++) { - argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); + argValue->GetObjectPropertyByIdx(pIsolate, j, jsObjectValue.get()); auto newPropertyValue = std::make_unique<CFXJSE_Value>(pIsolate); jsObjectValue->GetObjectProperty( - propertyValue->ToString().AsStringView(), newPropertyValue.get()); - if (newPropertyValue->IsNull()) + pIsolate, propertyValue->ToString(pIsolate).AsStringView(), + newPropertyValue.get()); + if (newPropertyValue->IsNull(pIsolate)) continue; dSum += ValueToDouble(pThis, newPropertyValue.get()); @@ -1450,7 +1456,7 @@ } std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, info, 0); - if (ValueIsNull(pThis, argValue.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argValue.get())) { info.GetReturnValue().SetNull(); return; } @@ -1463,18 +1469,18 @@ CFXJSE_HostObject* pThis, const v8::FunctionCallbackInfo<v8::Value>& info) { CFXJSE_FormCalcContext* pContext = ToFormCalcContext(pThis); - v8::Isolate* pIsolate = pContext->GetScriptRuntime(); + v8::Isolate* pIsolate = pContext->GetIsolate(); int32_t iCount = 0; for (int32_t i = 0; i < info.Length(); i++) { auto argValue = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[i]); - if (argValue->IsNull()) + if (argValue->IsNull(pIsolate)) continue; - if (argValue->IsArray()) { + if (argValue->IsArray(pIsolate)) { auto lengthValue = std::make_unique<CFXJSE_Value>(pIsolate); - argValue->GetObjectProperty("length", lengthValue.get()); + argValue->GetObjectProperty(pIsolate, "length", lengthValue.get()); - int32_t iLength = lengthValue->ToInteger(); + int32_t iLength = lengthValue->ToInteger(pIsolate); if (iLength <= 2) { pContext->ThrowArgumentMismatchException(); return; @@ -1483,27 +1489,29 @@ auto propertyValue = std::make_unique<CFXJSE_Value>(pIsolate); auto jsObjectValue = std::make_unique<CFXJSE_Value>(pIsolate); auto newPropertyValue = std::make_unique<CFXJSE_Value>(pIsolate); - argValue->GetObjectPropertyByIdx(1, propertyValue.get()); - argValue->GetObjectPropertyByIdx(2, jsObjectValue.get()); - if (propertyValue->IsNull()) { + argValue->GetObjectPropertyByIdx(pIsolate, 1, propertyValue.get()); + argValue->GetObjectPropertyByIdx(pIsolate, 2, jsObjectValue.get()); + if (propertyValue->IsNull(pIsolate)) { for (int32_t j = 2; j < iLength; j++) { - argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); - GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); - if (!newPropertyValue->IsNull()) + argValue->GetObjectPropertyByIdx(pIsolate, j, jsObjectValue.get()); + GetObjectDefaultValue(pIsolate, jsObjectValue.get(), + newPropertyValue.get()); + if (!newPropertyValue->IsNull(pIsolate)) iCount++; } } else { for (int32_t j = 2; j < iLength; j++) { - argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); + argValue->GetObjectPropertyByIdx(pIsolate, j, jsObjectValue.get()); jsObjectValue->GetObjectProperty( - propertyValue->ToString().AsStringView(), newPropertyValue.get()); - iCount += newPropertyValue->IsNull() ? 0 : 1; + pIsolate, propertyValue->ToString(pIsolate).AsStringView(), + newPropertyValue.get()); + iCount += newPropertyValue->IsNull(pIsolate) ? 0 : 1; } } - } else if (argValue->IsObject()) { + } else if (argValue->IsObject(pIsolate)) { auto newPropertyValue = std::make_unique<CFXJSE_Value>(pIsolate); - GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); - if (!newPropertyValue->IsNull()) + GetObjectDefaultValue(pIsolate, argValue.get(), newPropertyValue.get()); + if (!newPropertyValue->IsNull(pIsolate)) iCount++; } else { iCount++; @@ -1522,7 +1530,7 @@ } std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, info, 0); - if (ValueIsNull(pThis, argValue.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argValue.get())) { info.GetReturnValue().SetNull(); return; } @@ -1535,18 +1543,19 @@ CFXJSE_HostObject* pThis, const v8::FunctionCallbackInfo<v8::Value>& info) { CFXJSE_FormCalcContext* pContext = ToFormCalcContext(pThis); - v8::Isolate* pIsolate = pContext->GetScriptRuntime(); + v8::Isolate* pIsolate = pContext->GetIsolate(); uint32_t uCount = 0; double dMaxValue = 0.0; for (int32_t i = 0; i < info.Length(); i++) { auto argValue = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[i]); - if (argValue->IsNull()) + if (argValue->IsNull(info.GetIsolate())) continue; - if (argValue->IsArray()) { + if (argValue->IsArray(info.GetIsolate())) { auto lengthValue = std::make_unique<CFXJSE_Value>(pIsolate); - argValue->GetObjectProperty("length", lengthValue.get()); - int32_t iLength = lengthValue->ToInteger(); + argValue->GetObjectProperty(info.GetIsolate(), "length", + lengthValue.get()); + int32_t iLength = lengthValue->ToInteger(info.GetIsolate()); if (iLength <= 2) { pContext->ThrowArgumentMismatchException(); return; @@ -1555,13 +1564,14 @@ auto propertyValue = std::make_unique<CFXJSE_Value>(pIsolate); auto jsObjectValue = std::make_unique<CFXJSE_Value>(pIsolate); auto newPropertyValue = std::make_unique<CFXJSE_Value>(pIsolate); - argValue->GetObjectPropertyByIdx(1, propertyValue.get()); - argValue->GetObjectPropertyByIdx(2, jsObjectValue.get()); - if (propertyValue->IsNull()) { + argValue->GetObjectPropertyByIdx(pIsolate, 1, propertyValue.get()); + argValue->GetObjectPropertyByIdx(pIsolate, 2, jsObjectValue.get()); + if (propertyValue->IsNull(pIsolate)) { for (int32_t j = 2; j < iLength; j++) { - argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); - GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); - if (newPropertyValue->IsNull()) + argValue->GetObjectPropertyByIdx(pIsolate, j, jsObjectValue.get()); + GetObjectDefaultValue(pIsolate, jsObjectValue.get(), + newPropertyValue.get()); + if (newPropertyValue->IsNull(pIsolate)) continue; uCount++; @@ -1570,10 +1580,11 @@ } } else { for (int32_t j = 2; j < iLength; j++) { - argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); + argValue->GetObjectPropertyByIdx(pIsolate, j, jsObjectValue.get()); jsObjectValue->GetObjectProperty( - propertyValue->ToString().AsStringView(), newPropertyValue.get()); - if (newPropertyValue->IsNull()) + pIsolate, propertyValue->ToString(pIsolate).AsStringView(), + newPropertyValue.get()); + if (newPropertyValue->IsNull(pIsolate)) continue; uCount++; @@ -1581,10 +1592,10 @@ dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); } } - } else if (argValue->IsObject()) { + } else if (argValue->IsObject(pIsolate)) { auto newPropertyValue = std::make_unique<CFXJSE_Value>(pIsolate); - GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); - if (newPropertyValue->IsNull()) + GetObjectDefaultValue(pIsolate, argValue.get(), newPropertyValue.get()); + if (newPropertyValue->IsNull(pIsolate)) continue; uCount++; @@ -1608,18 +1619,18 @@ CFXJSE_HostObject* pThis, const v8::FunctionCallbackInfo<v8::Value>& info) { CFXJSE_FormCalcContext* pContext = ToFormCalcContext(pThis); - v8::Isolate* pIsolate = pContext->GetScriptRuntime(); + v8::Isolate* pIsolate = pContext->GetIsolate(); uint32_t uCount = 0; double dMinValue = 0.0; for (int32_t i = 0; i < info.Length(); i++) { auto argValue = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[i]); - if (argValue->IsNull()) + if (argValue->IsNull(pIsolate)) continue; - if (argValue->IsArray()) { + if (argValue->IsArray(pIsolate)) { auto lengthValue = std::make_unique<CFXJSE_Value>(pIsolate); - argValue->GetObjectProperty("length", lengthValue.get()); - int32_t iLength = lengthValue->ToInteger(); + argValue->GetObjectProperty(pIsolate, "length", lengthValue.get()); + int32_t iLength = lengthValue->ToInteger(pIsolate); if (iLength <= 2) { pContext->ThrowArgumentMismatchException(); return; @@ -1628,13 +1639,14 @@ auto propertyValue = std::make_unique<CFXJSE_Value>(pIsolate); auto jsObjectValue = std::make_unique<CFXJSE_Value>(pIsolate); auto newPropertyValue = std::make_unique<CFXJSE_Value>(pIsolate); - argValue->GetObjectPropertyByIdx(1, propertyValue.get()); - argValue->GetObjectPropertyByIdx(2, jsObjectValue.get()); - if (propertyValue->IsNull()) { + argValue->GetObjectPropertyByIdx(pIsolate, 1, propertyValue.get()); + argValue->GetObjectPropertyByIdx(pIsolate, 2, jsObjectValue.get()); + if (propertyValue->IsNull(pIsolate)) { for (int32_t j = 2; j < iLength; j++) { - argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); - GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); - if (newPropertyValue->IsNull()) + argValue->GetObjectPropertyByIdx(pIsolate, j, jsObjectValue.get()); + GetObjectDefaultValue(pIsolate, jsObjectValue.get(), + newPropertyValue.get()); + if (newPropertyValue->IsNull(pIsolate)) continue; uCount++; @@ -1643,10 +1655,11 @@ } } else { for (int32_t j = 2; j < iLength; j++) { - argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); + argValue->GetObjectPropertyByIdx(pIsolate, j, jsObjectValue.get()); jsObjectValue->GetObjectProperty( - propertyValue->ToString().AsStringView(), newPropertyValue.get()); - if (newPropertyValue->IsNull()) + pIsolate, propertyValue->ToString(pIsolate).AsStringView(), + newPropertyValue.get()); + if (newPropertyValue->IsNull(pIsolate)) continue; uCount++; @@ -1654,10 +1667,10 @@ dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue); } } - } else if (argValue->IsObject()) { + } else if (argValue->IsObject(pIsolate)) { auto newPropertyValue = std::make_unique<CFXJSE_Value>(pIsolate); - GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); - if (newPropertyValue->IsNull()) + GetObjectDefaultValue(pIsolate, argValue.get(), newPropertyValue.get()); + if (newPropertyValue->IsNull(pIsolate)) continue; uCount++; @@ -1689,7 +1702,7 @@ auto argOne = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[0]); auto argTwo = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[1]); - if (argOne->IsNull() || argTwo->IsNull()) { + if (argOne->IsNull(info.GetIsolate()) || argTwo->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } @@ -1724,7 +1737,7 @@ } auto argOne = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[0]); - if (argOne->IsNull()) { + if (argOne->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } @@ -1739,7 +1752,7 @@ uint8_t uPrecision = 0; if (argc > 1) { auto argTwo = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[1]); - if (argTwo->IsNull()) { + if (argTwo->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } @@ -1769,32 +1782,35 @@ } CFXJSE_FormCalcContext* pContext = ToFormCalcContext(pThis); - v8::Isolate* pIsolate = pContext->GetScriptRuntime(); uint32_t uCount = 0; double dSum = 0.0; for (int32_t i = 0; i < argc; i++) { auto argValue = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[i]); - if (argValue->IsNull()) + if (argValue->IsNull(info.GetIsolate())) continue; - if (argValue->IsArray()) { - auto lengthValue = std::make_unique<CFXJSE_Value>(pIsolate); - argValue->GetObjectProperty("length", lengthValue.get()); - int32_t iLength = lengthValue->ToInteger(); + if (argValue->IsArray(info.GetIsolate())) { + auto lengthValue = std::make_unique<CFXJSE_Value>(info.GetIsolate()); + argValue->GetObjectProperty(info.GetIsolate(), "length", + lengthValue.get()); + int32_t iLength = lengthValue->ToInteger(info.GetIsolate()); if (iLength <= 2) { pContext->ThrowArgumentMismatchException(); return; } - auto propertyValue = std::make_unique<CFXJSE_Value>(pIsolate); - argValue->GetObjectPropertyByIdx(1, propertyValue.get()); - auto jsObjectValue = std::make_unique<CFXJSE_Value>(pIsolate); - auto newPropertyValue = std::make_unique<CFXJSE_Value>(pIsolate); - if (propertyValue->IsNull()) { + auto propertyValue = std::make_unique<CFXJSE_Value>(info.GetIsolate()); + argValue->GetObjectPropertyByIdx(info.GetIsolate(), 1, + propertyValue.get()); + auto jsObjectValue = std::make_unique<CFXJSE_Value>(info.GetIsolate()); + auto newPropertyValue = std::make_unique<CFXJSE_Value>(info.GetIsolate()); + if (propertyValue->IsNull(info.GetIsolate())) { for (int32_t j = 2; j < iLength; j++) { - argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); - GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); - if (newPropertyValue->IsNull()) + argValue->GetObjectPropertyByIdx(info.GetIsolate(), j, + jsObjectValue.get()); + GetObjectDefaultValue(info.GetIsolate(), jsObjectValue.get(), + newPropertyValue.get()); + if (newPropertyValue->IsNull(info.GetIsolate())) continue; dSum += ValueToDouble(pThis, jsObjectValue.get()); @@ -1802,20 +1818,24 @@ } } else { for (int32_t j = 2; j < iLength; j++) { - argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); + argValue->GetObjectPropertyByIdx(info.GetIsolate(), j, + jsObjectValue.get()); jsObjectValue->GetObjectProperty( - propertyValue->ToString().AsStringView(), newPropertyValue.get()); - if (newPropertyValue->IsNull()) + info.GetIsolate(), + propertyValue->ToString(info.GetIsolate()).AsStringView(), + newPropertyValue.get()); + if (newPropertyValue->IsNull(info.GetIsolate())) continue; dSum += ValueToDouble(pThis, newPropertyValue.get()); uCount++; } } - } else if (argValue->IsObject()) { - auto newPropertyValue = std::make_unique<CFXJSE_Value>(pIsolate); - GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); - if (newPropertyValue->IsNull()) + } else if (argValue->IsObject(info.GetIsolate())) { + auto newPropertyValue = std::make_unique<CFXJSE_Value>(info.GetIsolate()); + GetObjectDefaultValue(info.GetIsolate(), argValue.get(), + newPropertyValue.get()); + if (newPropertyValue->IsNull(info.GetIsolate())) continue; dSum += ValueToDouble(pThis, argValue.get()); @@ -1863,30 +1883,30 @@ } std::unique_ptr<CFXJSE_Value> dateValue = GetSimpleValue(pThis, info, 0); - if (ValueIsNull(pThis, dateValue.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, dateValue.get())) { info.GetReturnValue().SetNull(); return; } - ByteString bsDate = ValueToUTF8String(dateValue.get()); + ByteString bsDate = ValueToUTF8String(pThis, dateValue.get()); ByteString bsFormat; if (argc > 1) { std::unique_ptr<CFXJSE_Value> formatValue = GetSimpleValue(pThis, info, 1); - if (ValueIsNull(pThis, formatValue.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, formatValue.get())) { info.GetReturnValue().SetNull(); return; } - bsFormat = ValueToUTF8String(formatValue.get()); + bsFormat = ValueToUTF8String(pThis, formatValue.get()); } ByteString bsLocale; if (argc > 2) { std::unique_ptr<CFXJSE_Value> localeValue = GetSimpleValue(pThis, info, 2); - if (ValueIsNull(pThis, localeValue.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, localeValue.get())) { info.GetReturnValue().SetNull(); return; } - bsLocale = ValueToUTF8String(localeValue.get()); + bsLocale = ValueToUTF8String(pThis, localeValue.get()); } ByteString bsIsoDate = @@ -1908,7 +1928,7 @@ int32_t iStyle = 0; if (argc > 0) { std::unique_ptr<CFXJSE_Value> infotyle = GetSimpleValue(pThis, info, 0); - if (infotyle->IsNull()) { + if (infotyle->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } @@ -1921,11 +1941,11 @@ ByteString bsLocale; if (argc > 1) { std::unique_ptr<CFXJSE_Value> argLocale = GetSimpleValue(pThis, info, 1); - if (argLocale->IsNull()) { + if (argLocale->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } - bsLocale = ValueToUTF8String(argLocale.get()); + bsLocale = ValueToUTF8String(pThis, argLocale.get()); } ByteString bsFormat = @@ -1943,11 +1963,11 @@ return; } std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); - if (argOne->IsNull()) { + if (argOne->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } - ByteString bsArg = ValueToUTF8String(argOne.get()); + ByteString bsArg = ValueToUTF8String(pThis, argOne.get()); info.GetReturnValue().Set(DateString2Num(bsArg.AsStringView())); } @@ -1962,14 +1982,14 @@ } std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); - if (ValueIsNull(pThis, argOne.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argOne.get())) { info.GetReturnValue().SetNull(); return; } CXFA_Document* pDoc = pContext->GetDocument(); CXFA_LocaleMgr* pMgr = pDoc->GetLocaleMgr(); - ByteString bsArg = ValueToUTF8String(argOne.get()); + ByteString bsArg = ValueToUTF8String(pThis, argOne.get()); auto pos = bsArg.Find('T', 0); if (!pos.has_value() || pos.value() == bsArg.GetLength() - 1) { info.GetReturnValue().Set(0); @@ -2018,7 +2038,7 @@ int32_t iStyle = 0; if (argc > 0) { std::unique_ptr<CFXJSE_Value> infotyle = GetSimpleValue(pThis, info, 0); - if (infotyle->IsNull()) { + if (infotyle->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } @@ -2030,11 +2050,11 @@ ByteString bsLocale; if (argc > 1) { std::unique_ptr<CFXJSE_Value> argLocale = GetSimpleValue(pThis, info, 1); - if (argLocale->IsNull()) { + if (argLocale->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } - bsLocale = ValueToUTF8String(argLocale.get()); + bsLocale = ValueToUTF8String(pThis, argLocale.get()); } ByteString bsFormat = @@ -2056,7 +2076,7 @@ int32_t iStyle = 0; if (argc > 0) { std::unique_ptr<CFXJSE_Value> infotyle = GetSimpleValue(pThis, info, 0); - if (infotyle->IsNull()) { + if (infotyle->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } @@ -2068,11 +2088,11 @@ ByteString bsLocale; if (argc > 1) { std::unique_ptr<CFXJSE_Value> argLocale = GetSimpleValue(pThis, info, 1); - if (argLocale->IsNull()) { + if (argLocale->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } - bsLocale = ValueToUTF8String(argLocale.get()); + bsLocale = ValueToUTF8String(pThis, argLocale.get()); } ByteString bsFormat = @@ -2092,7 +2112,7 @@ } std::unique_ptr<CFXJSE_Value> dateValue = GetSimpleValue(pThis, info, 0); - if (ValueIsNull(pThis, dateValue.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, dateValue.get())) { info.GetReturnValue().SetNull(); return; } @@ -2105,21 +2125,21 @@ ByteString bsFormat; if (argc > 1) { std::unique_ptr<CFXJSE_Value> formatValue = GetSimpleValue(pThis, info, 1); - if (ValueIsNull(pThis, formatValue.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, formatValue.get())) { info.GetReturnValue().SetNull(); return; } - bsFormat = ValueToUTF8String(formatValue.get()); + bsFormat = ValueToUTF8String(pThis, formatValue.get()); } ByteString bsLocale; if (argc > 2) { std::unique_ptr<CFXJSE_Value> localeValue = GetSimpleValue(pThis, info, 2); - if (ValueIsNull(pThis, localeValue.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, localeValue.get())) { info.GetReturnValue().SetNull(); return; } - bsLocale = ValueToUTF8String(localeValue.get()); + bsLocale = ValueToUTF8String(pThis, localeValue.get()); } int32_t iYear = 1900; @@ -2233,7 +2253,7 @@ } std::unique_ptr<CFXJSE_Value> timeValue = GetSimpleValue(pThis, info, 0); - if (timeValue->IsNull()) { + if (timeValue->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } @@ -2246,21 +2266,21 @@ ByteString bsFormat; if (argc > 1) { std::unique_ptr<CFXJSE_Value> formatValue = GetSimpleValue(pThis, info, 1); - if (formatValue->IsNull()) { + if (formatValue->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } - bsFormat = ValueToUTF8String(formatValue.get()); + bsFormat = ValueToUTF8String(pThis, formatValue.get()); } ByteString bsLocale; if (argc > 2) { std::unique_ptr<CFXJSE_Value> localeValue = GetSimpleValue(pThis, info, 2); - if (localeValue->IsNull()) { + if (localeValue->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } - bsLocale = ValueToUTF8String(localeValue.get()); + bsLocale = ValueToUTF8String(pThis, localeValue.get()); } ByteString bsGMTTime = Num2AllTime(pThis, iTime, bsFormat.AsStringView(), @@ -2280,7 +2300,7 @@ } std::unique_ptr<CFXJSE_Value> timeValue = GetSimpleValue(pThis, info, 0); - if (timeValue->IsNull()) { + if (timeValue->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } @@ -2293,21 +2313,21 @@ ByteString bsFormat; if (argc > 1) { std::unique_ptr<CFXJSE_Value> formatValue = GetSimpleValue(pThis, info, 1); - if (formatValue->IsNull()) { + if (formatValue->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } - bsFormat = ValueToUTF8String(formatValue.get()); + bsFormat = ValueToUTF8String(pThis, formatValue.get()); } ByteString bsLocale; if (argc > 2) { std::unique_ptr<CFXJSE_Value> localeValue = GetSimpleValue(pThis, info, 2); - if (localeValue->IsNull()) { + if (localeValue->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } - bsLocale = ValueToUTF8String(localeValue.get()); + bsLocale = ValueToUTF8String(pThis, localeValue.get()); } ByteString bsLocalTime = @@ -2345,30 +2365,30 @@ ByteString bsTime; std::unique_ptr<CFXJSE_Value> timeValue = GetSimpleValue(pThis, info, 0); - if (ValueIsNull(pThis, timeValue.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, timeValue.get())) { info.GetReturnValue().SetNull(); return; } - bsTime = ValueToUTF8String(timeValue.get()); + bsTime = ValueToUTF8String(pThis, timeValue.get()); ByteString bsFormat; if (argc > 1) { std::unique_ptr<CFXJSE_Value> formatValue = GetSimpleValue(pThis, info, 1); - if (ValueIsNull(pThis, formatValue.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, formatValue.get())) { info.GetReturnValue().SetNull(); return; } - bsFormat = ValueToUTF8String(formatValue.get()); + bsFormat = ValueToUTF8String(pThis, formatValue.get()); } ByteString bsLocale; if (argc > 2) { std::unique_ptr<CFXJSE_Value> localeValue = GetSimpleValue(pThis, info, 2); - if (ValueIsNull(pThis, localeValue.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, localeValue.get())) { info.GetReturnValue().SetNull(); return; } - bsLocale = ValueToUTF8String(localeValue.get()); + bsLocale = ValueToUTF8String(pThis, localeValue.get()); } CXFA_Document* pDoc = ToFormCalcContext(pThis)->GetDocument(); @@ -2431,7 +2451,7 @@ int32_t iStyle = 0; if (argc > 0) { std::unique_ptr<CFXJSE_Value> infotyle = GetSimpleValue(pThis, info, 0); - if (infotyle->IsNull()) { + if (infotyle->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } @@ -2443,11 +2463,11 @@ ByteString bsLocale; if (argc > 1) { std::unique_ptr<CFXJSE_Value> argLocale = GetSimpleValue(pThis, info, 1); - if (argLocale->IsNull()) { + if (argLocale->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } - bsLocale = ValueToUTF8String(argLocale.get()); + bsLocale = ValueToUTF8String(pThis, argLocale.get()); } ByteString bsFormat = @@ -2607,8 +2627,9 @@ std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, info, 1); std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, info, 2); - if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || - ValueIsNull(pThis, argThree.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argOne.get()) || + ValueIsNull(info.GetIsolate(), pThis, argTwo.get()) || + ValueIsNull(info.GetIsolate(), pThis, argThree.get())) { info.GetReturnValue().SetNull(); return; } @@ -2660,8 +2681,9 @@ std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, info, 1); std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, info, 2); - if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || - ValueIsNull(pThis, argThree.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argOne.get()) || + ValueIsNull(info.GetIsolate(), pThis, argTwo.get()) || + ValueIsNull(info.GetIsolate(), pThis, argThree.get())) { info.GetReturnValue().SetNull(); return; } @@ -2691,8 +2713,9 @@ std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, info, 1); std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, info, 2); - if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || - ValueIsNull(pThis, argThree.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argOne.get()) || + ValueIsNull(info.GetIsolate(), pThis, argTwo.get()) || + ValueIsNull(info.GetIsolate(), pThis, argThree.get())) { info.GetReturnValue().SetNull(); return; } @@ -2734,9 +2757,11 @@ std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, info, 2); std::unique_ptr<CFXJSE_Value> argFour = GetSimpleValue(pThis, info, 3); std::unique_ptr<CFXJSE_Value> argFive = GetSimpleValue(pThis, info, 4); - if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || - ValueIsNull(pThis, argThree.get()) || ValueIsNull(pThis, argFour.get()) || - ValueIsNull(pThis, argFive.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argOne.get()) || + ValueIsNull(info.GetIsolate(), pThis, argTwo.get()) || + ValueIsNull(info.GetIsolate(), pThis, argThree.get()) || + ValueIsNull(info.GetIsolate(), pThis, argFour.get()) || + ValueIsNull(info.GetIsolate(), pThis, argFive.get())) { info.GetReturnValue().SetNull(); return; } @@ -2788,7 +2813,7 @@ } std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, info, 0); - if (ValueIsNull(pThis, argValue.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argValue.get())) { info.GetReturnValue().SetNull(); return; } @@ -2802,7 +2827,7 @@ std::vector<double> data; for (int32_t i = 1; i < argc; i++) { argValue = GetSimpleValue(pThis, info, i); - if (ValueIsNull(pThis, argValue.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argValue.get())) { info.GetReturnValue().SetNull(); return; } @@ -2832,8 +2857,9 @@ std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, info, 1); std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, info, 2); - if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || - ValueIsNull(pThis, argThree.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argOne.get()) || + ValueIsNull(info.GetIsolate(), pThis, argTwo.get()) || + ValueIsNull(info.GetIsolate(), pThis, argThree.get())) { info.GetReturnValue().SetNull(); return; } @@ -2869,9 +2895,11 @@ std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, info, 2); std::unique_ptr<CFXJSE_Value> argFour = GetSimpleValue(pThis, info, 3); std::unique_ptr<CFXJSE_Value> argFive = GetSimpleValue(pThis, info, 4); - if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || - ValueIsNull(pThis, argThree.get()) || ValueIsNull(pThis, argFour.get()) || - ValueIsNull(pThis, argFive.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argOne.get()) || + ValueIsNull(info.GetIsolate(), pThis, argTwo.get()) || + ValueIsNull(info.GetIsolate(), pThis, argThree.get()) || + ValueIsNull(info.GetIsolate(), pThis, argFour.get()) || + ValueIsNull(info.GetIsolate(), pThis, argFive.get())) { info.GetReturnValue().SetNull(); return; } @@ -2925,8 +2953,9 @@ std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, info, 1); std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, info, 2); - if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || - ValueIsNull(pThis, argThree.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argOne.get()) || + ValueIsNull(info.GetIsolate(), pThis, argTwo.get()) || + ValueIsNull(info.GetIsolate(), pThis, argThree.get())) { info.GetReturnValue().SetNull(); return; } @@ -2960,8 +2989,9 @@ std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, info, 1); std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, info, 2); - if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || - ValueIsNull(pThis, argThree.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argOne.get()) || + ValueIsNull(info.GetIsolate(), pThis, argTwo.get()) || + ValueIsNull(info.GetIsolate(), pThis, argThree.get())) { info.GetReturnValue().SetNull(); return; } @@ -2991,8 +3021,9 @@ std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, info, 1); std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, info, 2); - if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || - ValueIsNull(pThis, argThree.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argOne.get()) || + ValueIsNull(info.GetIsolate(), pThis, argTwo.get()) || + ValueIsNull(info.GetIsolate(), pThis, argThree.get())) { info.GetReturnValue().SetNull(); return; } @@ -3021,7 +3052,7 @@ } auto argOne = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[0]); - if (ValueIsNull(pThis, argOne.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argOne.get())) { info.GetReturnValue().SetNull(); return; } @@ -3036,14 +3067,15 @@ bool bStopCounterFlags = false; int32_t iArgIndex = 1; int32_t iValueIndex = 0; - v8::Isolate* pIsolate = pContext->GetScriptRuntime(); + v8::Isolate* pIsolate = pContext->GetIsolate(); while (!bFound && !bStopCounterFlags && (iArgIndex < argc)) { auto argIndexValue = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[iArgIndex]); - if (argIndexValue->IsArray()) { + if (argIndexValue->IsArray(info.GetIsolate())) { auto lengthValue = std::make_unique<CFXJSE_Value>(pIsolate); - argIndexValue->GetObjectProperty("length", lengthValue.get()); - int32_t iLength = lengthValue->ToInteger(); + argIndexValue->GetObjectProperty(info.GetIsolate(), "length", + lengthValue.get()); + int32_t iLength = lengthValue->ToInteger(info.GetIsolate()); if (iLength > 3) bStopCounterFlags = true; @@ -3052,16 +3084,21 @@ auto propertyValue = std::make_unique<CFXJSE_Value>(pIsolate); auto jsObjectValue = std::make_unique<CFXJSE_Value>(pIsolate); auto newPropertyValue = std::make_unique<CFXJSE_Value>(pIsolate); - argIndexValue->GetObjectPropertyByIdx(1, propertyValue.get()); + argIndexValue->GetObjectPropertyByIdx(info.GetIsolate(), 1, + propertyValue.get()); argIndexValue->GetObjectPropertyByIdx( - (iLength - 1) - (iValueIndex - iIndex), jsObjectValue.get()); - if (propertyValue->IsNull()) { - GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); + info.GetIsolate(), (iLength - 1) - (iValueIndex - iIndex), + jsObjectValue.get()); + if (propertyValue->IsNull(info.GetIsolate())) { + GetObjectDefaultValue(info.GetIsolate(), jsObjectValue.get(), + newPropertyValue.get()); } else { jsObjectValue->GetObjectProperty( - propertyValue->ToString().AsStringView(), newPropertyValue.get()); + info.GetIsolate(), + propertyValue->ToString(info.GetIsolate()).AsStringView(), + newPropertyValue.get()); } - ByteString bsChosen = ValueToUTF8String(newPropertyValue.get()); + ByteString bsChosen = ValueToUTF8String(pThis, newPropertyValue.get()); info.GetReturnValue().Set( fxv8::NewStringHelper(info.GetIsolate(), bsChosen.AsStringView())); bFound = true; @@ -3069,7 +3106,7 @@ } else { iValueIndex++; if (iValueIndex == iIndex) { - ByteString bsChosen = ValueToUTF8String(argIndexValue.get()); + ByteString bsChosen = ValueToUTF8String(pThis, argIndexValue.get()); info.GetReturnValue().Set( fxv8::NewStringHelper(info.GetIsolate(), bsChosen.AsStringView())); bFound = true; @@ -3090,7 +3127,8 @@ return; } auto temp = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[0]); - info.GetReturnValue().Set(static_cast<int>(temp->IsObject())); + info.GetReturnValue().Set( + static_cast<int>(temp->IsObject(info.GetIsolate()))); } // static @@ -3103,13 +3141,14 @@ } std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); - if (!argOne->IsString()) { + if (!argOne->IsString(info.GetIsolate())) { info.GetReturnValue().Set( - static_cast<int>(argOne->IsNumber() || argOne->IsBoolean())); + static_cast<int>(argOne->IsNumber(info.GetIsolate()) || + argOne->IsBoolean(info.GetIsolate()))); return; } - ByteString bsValue = argOne->ToString(); + ByteString bsValue = argOne->ToString(info.GetIsolate()); bsValue.TrimLeft(); info.GetReturnValue().Set(static_cast<int>(!bsValue.IsEmpty())); } @@ -3143,14 +3182,14 @@ } std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); - if (argOne->IsNull()) { + if (argOne->IsNull(info.GetIsolate())) { info.GetReturnValue().SetUndefined(); return; } std::unique_ptr<CFXJSE_Value> argLow = GetSimpleValue(pThis, info, 1); std::unique_ptr<CFXJSE_Value> argHigh = GetSimpleValue(pThis, info, 2); - if (argOne->IsNumber()) { + if (argOne->IsNumber(info.GetIsolate())) { float oneNumber = ValueToFloat(pThis, argOne.get()); float lowNumber = ValueToFloat(pThis, argLow.get()); float heightNumber = ValueToFloat(pThis, argHigh.get()); @@ -3159,9 +3198,9 @@ return; } - ByteString bsOne = ValueToUTF8String(argOne.get()); - ByteString bsLow = ValueToUTF8String(argLow.get()); - ByteString bsHeight = ValueToUTF8String(argHigh.get()); + ByteString bsOne = ValueToUTF8String(pThis, argOne.get()); + ByteString bsLow = ValueToUTF8String(pThis, argLow.get()); + ByteString bsHeight = ValueToUTF8String(pThis, argHigh.get()); info.GetReturnValue().Set( static_cast<int>((bsOne.Compare(bsLow.AsStringView()) >= 0) && (bsOne.Compare(bsHeight.AsStringView()) <= 0))); @@ -3177,7 +3216,7 @@ } std::unique_ptr<CFXJSE_Value> value = - GetSimpleValue(pThis, info, 0)->ToBoolean() + GetSimpleValue(pThis, info, 0)->ToBoolean(info.GetIsolate()) ? GetSimpleValue(pThis, info, 1) : GetSimpleValue(pThis, info, 2); @@ -3194,9 +3233,9 @@ return; } - v8::Isolate* pIsolate = pContext->GetScriptRuntime(); + v8::Isolate* pIsolate = pContext->GetIsolate(); std::unique_ptr<CFXJSE_Value> scriptValue = GetSimpleValue(pThis, info, 0); - ByteString bsUtf8Script = ValueToUTF8String(scriptValue.get()); + ByteString bsUtf8Script = ValueToUTF8String(pThis, scriptValue.get()); if (bsUtf8Script.IsEmpty()) { info.GetReturnValue().SetNull(); return; @@ -3226,20 +3265,26 @@ CFXJSE_HostObject* pThis, const v8::FunctionCallbackInfo<v8::Value>& info) { CFXJSE_FormCalcContext* pContext = ToFormCalcContext(pThis); - v8::Isolate* pIsolate = pContext->GetScriptRuntime(); + v8::Isolate* pIsolate = pContext->GetIsolate(); if (info.Length() != 1) { pContext->ThrowParamCountMismatchException(L"Ref"); return; } auto argOne = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[0]); - if (!argOne->IsArray() && !argOne->IsObject() && !argOne->IsBoolean() && - !argOne->IsString() && !argOne->IsNull() && !argOne->IsNumber()) { + if (!argOne->IsArray(info.GetIsolate()) && + !argOne->IsObject(info.GetIsolate()) && + !argOne->IsBoolean(info.GetIsolate()) && + !argOne->IsString(info.GetIsolate()) && + !argOne->IsNull(info.GetIsolate()) && + !argOne->IsNumber(info.GetIsolate())) { pContext->ThrowArgumentMismatchException(); return; } - if (argOne->IsBoolean() || argOne->IsString() || argOne->IsNumber()) { + if (argOne->IsBoolean(info.GetIsolate()) || + argOne->IsString(info.GetIsolate()) || + argOne->IsNumber(info.GetIsolate())) { info.GetReturnValue().Set(argOne->DirectGetValue()); return; } @@ -3249,36 +3294,37 @@ values.push_back(std::make_unique<CFXJSE_Value>(pIsolate)); int intVal = 3; - if (argOne->IsNull()) { + if (argOne->IsNull(info.GetIsolate())) { // TODO(dsinclair): Why is this 4 when the others are all 3? intVal = 4; - values[2]->SetNull(); - } else if (argOne->IsArray()) { + values[2]->SetNull(info.GetIsolate()); + } else if (argOne->IsArray(info.GetIsolate())) { #ifndef NDEBUG auto lengthValue = std::make_unique<CFXJSE_Value>(pIsolate); - argOne->GetObjectProperty("length", lengthValue.get()); - ASSERT(lengthValue->ToInteger() >= 3); + argOne->GetObjectProperty(info.GetIsolate(), "length", lengthValue.get()); + ASSERT(lengthValue->ToInteger(info.GetIsolate()) >= 3); #endif auto propertyValue = std::make_unique<CFXJSE_Value>(pIsolate); auto jsObjectValue = std::make_unique<CFXJSE_Value>(pIsolate); - argOne->GetObjectPropertyByIdx(1, propertyValue.get()); - argOne->GetObjectPropertyByIdx(2, jsObjectValue.get()); - if (!propertyValue->IsNull() || jsObjectValue->IsNull()) { + argOne->GetObjectPropertyByIdx(info.GetIsolate(), 1, propertyValue.get()); + argOne->GetObjectPropertyByIdx(info.GetIsolate(), 2, jsObjectValue.get()); + if (!propertyValue->IsNull(info.GetIsolate()) || + jsObjectValue->IsNull(info.GetIsolate())) { pContext->ThrowArgumentMismatchException(); return; } - values[2]->Assign(jsObjectValue.get()); - } else if (argOne->IsObject()) { - values[2]->Assign(argOne.get()); + values[2]->Assign(info.GetIsolate(), jsObjectValue.get()); + } else if (argOne->IsObject(info.GetIsolate())) { + values[2]->Assign(info.GetIsolate(), argOne.get()); } - values[0]->SetInteger(intVal); - values[1]->SetNull(); + values[0]->SetInteger(info.GetIsolate(), intVal); + values[1]->SetNull(info.GetIsolate()); auto temp = std::make_unique<CFXJSE_Value>(info.GetIsolate()); - temp->SetArray(values); + temp->SetArray(info.GetIsolate(), values); info.GetReturnValue().Set(temp->DirectGetValue()); } @@ -3292,12 +3338,12 @@ } std::unique_ptr<CFXJSE_Value> unitspanValue = GetSimpleValue(pThis, info, 0); - if (unitspanValue->IsNull()) { + if (unitspanValue->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } - ByteString bsUnitspan = ValueToUTF8String(unitspanValue.get()); + ByteString bsUnitspan = ValueToUTF8String(pThis, unitspanValue.get()); if (bsUnitspan.IsEmpty()) { info.GetReturnValue().SetEmptyString(); return; @@ -3400,12 +3446,12 @@ } std::unique_ptr<CFXJSE_Value> unitspanValue = GetSimpleValue(pThis, info, 0); - if (unitspanValue->IsNull()) { + if (unitspanValue->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } - ByteString bsUnitspan = ValueToUTF8String(unitspanValue.get()); + ByteString bsUnitspan = ValueToUTF8String(pThis, unitspanValue.get()); const char* pData = bsUnitspan.c_str(); if (!pData) { info.GetReturnValue().Set(0); @@ -3441,7 +3487,7 @@ ByteString bsUnit; if (argc > 1) { std::unique_ptr<CFXJSE_Value> unitValue = GetSimpleValue(pThis, info, 1); - ByteString bsUnitTemp = ValueToUTF8String(unitValue.get()); + ByteString bsUnitTemp = ValueToUTF8String(pThis, unitValue.get()); const char* pChar = bsUnitTemp.c_str(); size_t uVal = 0; while (IsWhitespace(pChar[uVal])) @@ -3539,18 +3585,19 @@ std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, info, 1); - if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argOne.get()) || + ValueIsNull(info.GetIsolate(), pThis, argTwo.get())) { info.GetReturnValue().SetNull(); return; } - ByteString stringTwo = ValueToUTF8String(argTwo.get()); + ByteString stringTwo = ValueToUTF8String(pThis, argTwo.get()); if (stringTwo.IsEmpty()) { info.GetReturnValue().Set(1); return; } - ByteString stringOne = ValueToUTF8String(argOne.get()); + ByteString stringOne = ValueToUTF8String(pThis, argOne.get()); auto pos = stringOne.Find(stringTwo.AsStringView()); info.GetReturnValue().Set( static_cast<int>(pos.has_value() ? pos.value() + 1 : 0)); @@ -3570,11 +3617,11 @@ bool bAllNull = true; for (int32_t i = 0; i < argc; i++) { std::unique_ptr<CFXJSE_Value> value = GetSimpleValue(pThis, info, i); - if (ValueIsNull(pThis, value.get())) + if (ValueIsNull(info.GetIsolate(), pThis, value.get())) continue; bAllNull = false; - bsResult += ValueToUTF8String(value.get()); + bsResult += ValueToUTF8String(pThis, value.get()); } if (bAllNull) { @@ -3597,13 +3644,13 @@ if (argc == 1) { std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); - if (ValueIsNull(pThis, argOne.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argOne.get())) { info.GetReturnValue().SetNull(); return; } - WideString decoded = DecodeURL( - WideString::FromUTF8(ValueToUTF8String(argOne.get()).AsStringView())); + WideString decoded = DecodeURL(WideString::FromUTF8( + ValueToUTF8String(pThis, argOne.get()).AsStringView())); auto result = FX_UTF8Encode(decoded.AsStringView()); info.GetReturnValue().Set( fxv8::NewStringHelper(info.GetIsolate(), result.AsStringView())); @@ -3612,13 +3659,14 @@ std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, info, 1); - if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argOne.get()) || + ValueIsNull(info.GetIsolate(), pThis, argTwo.get())) { info.GetReturnValue().SetNull(); return; } - ByteString bsToDecode = ValueToUTF8String(argOne.get()); - ByteString bsIdentify = ValueToUTF8String(argTwo.get()); + ByteString bsToDecode = ValueToUTF8String(pThis, argOne.get()); + ByteString bsIdentify = ValueToUTF8String(pThis, argTwo.get()); WideString decoded; WideString wsToDecode = WideString::FromUTF8(bsToDecode.AsStringView()); @@ -3647,11 +3695,11 @@ if (argc == 1) { std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); - if (ValueIsNull(pThis, argOne.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argOne.get())) { info.GetReturnValue().SetNull(); return; } - WideString encoded = EncodeURL(ValueToUTF8String(argOne.get())); + WideString encoded = EncodeURL(ValueToUTF8String(pThis, argOne.get())); auto result = FX_UTF8Encode(encoded.AsStringView()); info.GetReturnValue().Set( fxv8::NewStringHelper(info.GetIsolate(), result.AsStringView())); @@ -3660,13 +3708,14 @@ std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, info, 1); - if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argOne.get()) || + ValueIsNull(info.GetIsolate(), pThis, argTwo.get())) { info.GetReturnValue().SetNull(); return; } - ByteString bsToEncode = ValueToUTF8String(argOne.get()); - ByteString bsIdentify = ValueToUTF8String(argTwo.get()); + ByteString bsToEncode = ValueToUTF8String(pThis, argOne.get()); + ByteString bsIdentify = ValueToUTF8String(pThis, argTwo.get()); WideString encoded; if (bsIdentify.EqualNoCase("html")) encoded = EncodeHTML(bsToEncode); @@ -3691,10 +3740,10 @@ } std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); - ByteString bsPattern = ValueToUTF8String(argOne.get()); + ByteString bsPattern = ValueToUTF8String(pThis, argOne.get()); std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, info, 1); - ByteString bsValue = ValueToUTF8String(argTwo.get()); + ByteString bsValue = ValueToUTF8String(pThis, argTwo.get()); CXFA_Document* pDoc = pContext->GetDocument(); CXFA_LocaleMgr* pMgr = pDoc->GetLocaleMgr(); @@ -3771,13 +3820,13 @@ std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, info, 1); - if ((ValueIsNull(pThis, argOne.get())) || - (ValueIsNull(pThis, argTwo.get()))) { + if ((ValueIsNull(info.GetIsolate(), pThis, argOne.get())) || + (ValueIsNull(info.GetIsolate(), pThis, argTwo.get()))) { info.GetReturnValue().SetNull(); return; } - ByteString bsSource = ValueToUTF8String(argOne.get()); + ByteString bsSource = ValueToUTF8String(pThis, argOne.get()); int32_t count = std::max(0, ValueToInteger(pThis, argTwo.get())); info.GetReturnValue().Set(fxv8::NewStringHelper( info.GetIsolate(), bsSource.First(count).AsStringView())); @@ -3793,12 +3842,12 @@ } std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); - if (ValueIsNull(pThis, argOne.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argOne.get())) { info.GetReturnValue().SetNull(); return; } - ByteString bsSource = ValueToUTF8String(argOne.get()); + ByteString bsSource = ValueToUTF8String(pThis, argOne.get()); info.GetReturnValue().Set(static_cast<int>(bsSource.GetLength())); } @@ -3813,13 +3862,13 @@ } std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); - if (ValueIsNull(pThis, argOne.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argOne.get())) { info.GetReturnValue().SetNull(); return; } CFX_WideTextBuf szLowBuf; - ByteString bsArg = ValueToUTF8String(argOne.get()); + ByteString bsArg = ValueToUTF8String(pThis, argOne.get()); WideString wsArg = WideString::FromUTF8(bsArg.AsStringView()); for (wchar_t ch : wsArg) { if ((ch >= 0x41 && ch <= 0x5A) || (ch >= 0xC0 && ch <= 0xDE)) @@ -3843,12 +3892,12 @@ } std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); - if (ValueIsNull(pThis, argOne.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argOne.get())) { info.GetReturnValue().SetNull(); return; } - ByteString bsSource = ValueToUTF8String(argOne.get()); + ByteString bsSource = ValueToUTF8String(pThis, argOne.get()); bsSource.TrimLeft(); info.GetReturnValue().Set( fxv8::NewStringHelper(info.GetIsolate(), bsSource.AsStringView())); @@ -3866,13 +3915,13 @@ std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, info, 1); - if (ValueIsNull(pThis, argTwo.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argTwo.get())) { info.GetReturnValue().SetNull(); return; } - ByteString bsPattern = ValueToUTF8String(argOne.get()); - ByteString bsValue = ValueToUTF8String(argTwo.get()); + ByteString bsPattern = ValueToUTF8String(pThis, argOne.get()); + ByteString bsValue = ValueToUTF8String(pThis, argTwo.get()); CXFA_Document* pDoc = pContext->GetDocument(); CXFA_LocaleMgr* pMgr = pDoc->GetLocaleMgr(); CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); @@ -4012,15 +4061,16 @@ std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, info, 1); ByteString bsOne; ByteString bsTwo; - if (!ValueIsNull(pThis, argOne.get()) && !ValueIsNull(pThis, argTwo.get())) { - bsOne = ValueToUTF8String(argOne.get()); - bsTwo = ValueToUTF8String(argTwo.get()); + if (!ValueIsNull(info.GetIsolate(), pThis, argOne.get()) && + !ValueIsNull(info.GetIsolate(), pThis, argTwo.get())) { + bsOne = ValueToUTF8String(pThis, argOne.get()); + bsTwo = ValueToUTF8String(pThis, argTwo.get()); } ByteString bsThree; if (argc > 2) { std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, info, 2); - bsThree = ValueToUTF8String(argThree.get()); + bsThree = ValueToUTF8String(pThis, argThree.get()); } bsOne.Replace(bsTwo.AsStringView(), bsThree.AsStringView()); @@ -4039,13 +4089,13 @@ std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, info, 1); - if ((ValueIsNull(pThis, argOne.get())) || - (ValueIsNull(pThis, argTwo.get()))) { + if ((ValueIsNull(info.GetIsolate(), pThis, argOne.get())) || + (ValueIsNull(info.GetIsolate(), pThis, argTwo.get()))) { info.GetReturnValue().SetNull(); return; } - ByteString bsSource = ValueToUTF8String(argOne.get()); + ByteString bsSource = ValueToUTF8String(pThis, argOne.get()); int32_t count = std::max(0, ValueToInteger(pThis, argTwo.get())); info.GetReturnValue().Set(fxv8::NewStringHelper( info.GetIsolate(), bsSource.Last(count).AsStringView())); @@ -4061,12 +4111,12 @@ } std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); - if (ValueIsNull(pThis, argOne.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argOne.get())) { info.GetReturnValue().SetNull(); return; } - ByteString bsSource = ValueToUTF8String(argOne.get()); + ByteString bsSource = ValueToUTF8String(pThis, argOne.get()); bsSource.TrimRight(); info.GetReturnValue().Set( fxv8::NewStringHelper(info.GetIsolate(), bsSource.AsStringView())); @@ -4082,7 +4132,7 @@ } std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); - if (argOne->IsNull()) { + if (argOne->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } @@ -4110,7 +4160,7 @@ } std::unique_ptr<CFXJSE_Value> numberValue = GetSimpleValue(pThis, info, 0); - if (numberValue->IsNull()) { + if (numberValue->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } @@ -4235,9 +4285,10 @@ std::unique_ptr<CFXJSE_Value> sourceValue = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> startValue = GetSimpleValue(pThis, info, 1); std::unique_ptr<CFXJSE_Value> deleteValue = GetSimpleValue(pThis, info, 2); - if (!sourceValue->IsNull() && !startValue->IsNull() && - !deleteValue->IsNull()) { - bsSource = ValueToUTF8String(sourceValue.get()); + if (!sourceValue->IsNull(info.GetIsolate()) && + !startValue->IsNull(info.GetIsolate()) && + !deleteValue->IsNull(info.GetIsolate())) { + bsSource = ValueToUTF8String(pThis, sourceValue.get()); iLength = bsSource.GetLength(); iStart = pdfium::clamp( static_cast<int32_t>(ValueToFloat(pThis, startValue.get())), 1, @@ -4248,7 +4299,7 @@ if (argc > 3) { std::unique_ptr<CFXJSE_Value> insertValue = GetSimpleValue(pThis, info, 3); - bsInsert = ValueToUTF8String(insertValue.get()); + bsInsert = ValueToUTF8String(pThis, insertValue.get()); } --iStart; @@ -4281,14 +4332,14 @@ std::unique_ptr<CFXJSE_Value> string_value = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> start_value = GetSimpleValue(pThis, info, 1); std::unique_ptr<CFXJSE_Value> end_value = GetSimpleValue(pThis, info, 2); - if (ValueIsNull(pThis, string_value.get()) || - ValueIsNull(pThis, start_value.get()) || - ValueIsNull(pThis, end_value.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, string_value.get()) || + ValueIsNull(info.GetIsolate(), pThis, start_value.get()) || + ValueIsNull(info.GetIsolate(), pThis, end_value.get())) { info.GetReturnValue().SetNull(); return; } - ByteString bsSource = ValueToUTF8String(string_value.get()); + ByteString bsSource = ValueToUTF8String(pThis, string_value.get()); size_t iLength = bsSource.GetLength(); if (iLength == 0) { info.GetReturnValue().SetEmptyString(); @@ -4340,13 +4391,13 @@ } std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); - if (ValueIsNull(pThis, argOne.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argOne.get())) { info.GetReturnValue().SetNull(); return; } CFX_WideTextBuf upperStringBuf; - ByteString bsArg = ValueToUTF8String(argOne.get()); + ByteString bsArg = ValueToUTF8String(pThis, argOne.get()); WideString wsArg = WideString::FromUTF8(bsArg.AsStringView()); const wchar_t* pData = wsArg.c_str(); size_t i = 0; @@ -4376,7 +4427,7 @@ } std::unique_ptr<CFXJSE_Value> numberValue = GetSimpleValue(pThis, info, 0); - if (numberValue->IsNull()) { + if (numberValue->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } @@ -4386,7 +4437,7 @@ if (argc > 1) { std::unique_ptr<CFXJSE_Value> identifierValue = GetSimpleValue(pThis, info, 1); - if (identifierValue->IsNull()) { + if (identifierValue->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } @@ -4397,11 +4448,11 @@ ByteString bsLocale; if (argc > 2) { std::unique_ptr<CFXJSE_Value> localeValue = GetSimpleValue(pThis, info, 2); - if (localeValue->IsNull()) { + if (localeValue->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } - bsLocale = ValueToUTF8String(localeValue.get()); + bsLocale = ValueToUTF8String(pThis, localeValue.get()); } if (std::isnan(fNumber) || fNumber < 0.0f || @@ -4434,7 +4485,7 @@ return; std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); - ByteString bsUrl = ValueToUTF8String(argOne.get()); + ByteString bsUrl = ValueToUTF8String(pThis, argOne.get()); RetainPtr<IFX_SeekableReadStream> pFile = pAppProvider->DownloadURL(WideString::FromUTF8(bsUrl.AsStringView())); if (!pFile) @@ -4467,27 +4518,27 @@ return; std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); - ByteString bsURL = ValueToUTF8String(argOne.get()); + ByteString bsURL = ValueToUTF8String(pThis, argOne.get()); std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, info, 1); - ByteString bsData = ValueToUTF8String(argTwo.get()); + ByteString bsData = ValueToUTF8String(pThis, argTwo.get()); ByteString bsContentType; if (argc > 2) { std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, info, 2); - bsContentType = ValueToUTF8String(argThree.get()); + bsContentType = ValueToUTF8String(pThis, argThree.get()); } ByteString bsEncode; if (argc > 3) { std::unique_ptr<CFXJSE_Value> argFour = GetSimpleValue(pThis, info, 3); - bsEncode = ValueToUTF8String(argFour.get()); + bsEncode = ValueToUTF8String(pThis, argFour.get()); } ByteString bsHeader; if (argc > 4) { std::unique_ptr<CFXJSE_Value> argFive = GetSimpleValue(pThis, info, 4); - bsHeader = ValueToUTF8String(argFive.get()); + bsHeader = ValueToUTF8String(pThis, argFive.get()); } WideString decodedResponse; @@ -4524,15 +4575,15 @@ return; std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); - ByteString bsURL = ValueToUTF8String(argOne.get()); + ByteString bsURL = ValueToUTF8String(pThis, argOne.get()); std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, info, 1); - ByteString bsData = ValueToUTF8String(argTwo.get()); + ByteString bsData = ValueToUTF8String(pThis, argTwo.get()); ByteString bsEncode; if (argc > 2) { std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, info, 2); - bsEncode = ValueToUTF8String(argThree.get()); + bsEncode = ValueToUTF8String(pThis, argThree.get()); } if (!pAppProvider->PutRequestURL( WideString::FromUTF8(bsURL.AsStringView()), @@ -4556,31 +4607,35 @@ ByteStringView bsFuncName("asgn_val_op"); auto lValue = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[0]); std::unique_ptr<CFXJSE_Value> rValue = GetSimpleValue(pThis, info, 1); - if (lValue->IsArray()) { - v8::Isolate* pIsolate = pContext->GetScriptRuntime(); + if (lValue->IsArray(info.GetIsolate())) { + v8::Isolate* pIsolate = pContext->GetIsolate(); auto leftLengthValue = std::make_unique<CFXJSE_Value>(pIsolate); - lValue->GetObjectProperty("length", leftLengthValue.get()); - int32_t iLeftLength = leftLengthValue->ToInteger(); + lValue->GetObjectProperty(info.GetIsolate(), "length", + leftLengthValue.get()); + int32_t iLeftLength = leftLengthValue->ToInteger(info.GetIsolate()); auto jsObjectValue = std::make_unique<CFXJSE_Value>(pIsolate); auto propertyValue = std::make_unique<CFXJSE_Value>(pIsolate); - lValue->GetObjectPropertyByIdx(1, propertyValue.get()); - if (propertyValue->IsNull()) { + lValue->GetObjectPropertyByIdx(info.GetIsolate(), 1, propertyValue.get()); + if (propertyValue->IsNull(info.GetIsolate())) { for (int32_t i = 2; i < iLeftLength; i++) { - lValue->GetObjectPropertyByIdx(i, jsObjectValue.get()); - if (!SetObjectDefaultValue(jsObjectValue.get(), rValue.get())) { + lValue->GetObjectPropertyByIdx(info.GetIsolate(), i, + jsObjectValue.get()); + if (!SetObjectDefaultValue(info.GetIsolate(), jsObjectValue.get(), + rValue.get())) { pContext->ThrowNoDefaultPropertyException(bsFuncName); return; } } } else { for (int32_t i = 2; i < iLeftLength; i++) { - lValue->GetObjectPropertyByIdx(i, jsObjectValue.get()); + lValue->GetObjectPropertyByIdx(pIsolate, i, jsObjectValue.get()); jsObjectValue->SetObjectProperty( - propertyValue->ToString().AsStringView(), rValue.get()); + info.GetIsolate(), propertyValue->ToString(pIsolate).AsStringView(), + rValue.get()); } } - } else if (lValue->IsObject()) { - if (!SetObjectDefaultValue(lValue.get(), rValue.get())) { + } else if (lValue->IsObject(info.GetIsolate())) { + if (!SetObjectDefaultValue(info.GetIsolate(), lValue.get(), rValue.get())) { pContext->ThrowNoDefaultPropertyException(bsFuncName); return; } @@ -4599,7 +4654,8 @@ std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> infoecond = GetSimpleValue(pThis, info, 1); - if (argFirst->IsNull() && infoecond->IsNull()) { + if (argFirst->IsNull(info.GetIsolate()) && + infoecond->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } @@ -4620,7 +4676,8 @@ std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> infoecond = GetSimpleValue(pThis, info, 1); - if (argFirst->IsNull() && infoecond->IsNull()) { + if (argFirst->IsNull(info.GetIsolate()) && + infoecond->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } @@ -4646,15 +4703,19 @@ std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> infoecond = GetSimpleValue(pThis, info, 1); - if (argFirst->IsNull() || infoecond->IsNull()) { + if (argFirst->IsNull(info.GetIsolate()) || + infoecond->IsNull(info.GetIsolate())) { info.GetReturnValue().Set( - static_cast<int>(argFirst->IsNull() && infoecond->IsNull())); + static_cast<int>(argFirst->IsNull(info.GetIsolate()) && + infoecond->IsNull(info.GetIsolate()))); return; } - if (argFirst->IsString() && infoecond->IsString()) { + if (argFirst->IsString(info.GetIsolate()) && + infoecond->IsString(info.GetIsolate())) { info.GetReturnValue().Set( - static_cast<int>(argFirst->ToString() == infoecond->ToString())); + static_cast<int>(argFirst->ToString(info.GetIsolate()) == + infoecond->ToString(info.GetIsolate()))); return; } @@ -4679,15 +4740,19 @@ std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> infoecond = GetSimpleValue(pThis, info, 1); - if (argFirst->IsNull() || infoecond->IsNull()) { + if (argFirst->IsNull(info.GetIsolate()) || + infoecond->IsNull(info.GetIsolate())) { info.GetReturnValue().Set( - static_cast<int>(!argFirst->IsNull() || !infoecond->IsNull())); + static_cast<int>(!argFirst->IsNull(info.GetIsolate()) || + !infoecond->IsNull(info.GetIsolate()))); return; } - if (argFirst->IsString() && infoecond->IsString()) { + if (argFirst->IsString(info.GetIsolate()) && + infoecond->IsString(info.GetIsolate())) { info.GetReturnValue().Set( - static_cast<int>(argFirst->ToString() != infoecond->ToString())); + static_cast<int>(argFirst->ToString(info.GetIsolate()) != + infoecond->ToString(info.GetIsolate()))); return; } @@ -4702,25 +4767,29 @@ const v8::FunctionCallbackInfo<v8::Value>& info) { auto argFirst = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[0]); auto argSecond = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[1]); - if (!argFirst->IsArray() || !argSecond->IsArray()) + if (!argFirst->IsArray(info.GetIsolate()) || + !argSecond->IsArray(info.GetIsolate())) return false; - v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetScriptRuntime(); - auto firstFlagValue = std::make_unique<CFXJSE_Value>(pIsolate); - auto secondFlagValue = std::make_unique<CFXJSE_Value>(pIsolate); - argFirst->GetObjectPropertyByIdx(0, firstFlagValue.get()); - argSecond->GetObjectPropertyByIdx(0, secondFlagValue.get()); - if (firstFlagValue->ToInteger() != 3 || secondFlagValue->ToInteger() != 3) + auto firstFlagValue = std::make_unique<CFXJSE_Value>(info.GetIsolate()); + auto secondFlagValue = std::make_unique<CFXJSE_Value>(info.GetIsolate()); + argFirst->GetObjectPropertyByIdx(info.GetIsolate(), 0, firstFlagValue.get()); + argSecond->GetObjectPropertyByIdx(info.GetIsolate(), 0, + secondFlagValue.get()); + if (firstFlagValue->ToInteger(info.GetIsolate()) != 3 || + secondFlagValue->ToInteger(info.GetIsolate()) != 3) return false; - auto firstJSObject = std::make_unique<CFXJSE_Value>(pIsolate); - auto secondJSObject = std::make_unique<CFXJSE_Value>(pIsolate); - argFirst->GetObjectPropertyByIdx(2, firstJSObject.get()); - argSecond->GetObjectPropertyByIdx(2, secondJSObject.get()); - if (firstJSObject->IsNull() || secondJSObject->IsNull()) + auto firstJSObject = std::make_unique<CFXJSE_Value>(info.GetIsolate()); + auto secondJSObject = std::make_unique<CFXJSE_Value>(info.GetIsolate()); + argFirst->GetObjectPropertyByIdx(info.GetIsolate(), 2, firstJSObject.get()); + argSecond->GetObjectPropertyByIdx(info.GetIsolate(), 2, secondJSObject.get()); + if (firstJSObject->IsNull(info.GetIsolate()) || + secondJSObject->IsNull(info.GetIsolate())) return false; - return firstJSObject->ToHostObject() == secondJSObject->ToHostObject(); + return firstJSObject->ToHostObject(info.GetIsolate()) == + secondJSObject->ToHostObject(info.GetIsolate()); } // static @@ -4734,14 +4803,17 @@ std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, info, 1); - if (argFirst->IsNull() || argSecond->IsNull()) { + if (argFirst->IsNull(info.GetIsolate()) || + argSecond->IsNull(info.GetIsolate())) { info.GetReturnValue().Set(0); return; } - if (argFirst->IsString() && argSecond->IsString()) { + if (argFirst->IsString(info.GetIsolate()) && + argSecond->IsString(info.GetIsolate())) { int result = - argFirst->ToString().Compare(argSecond->ToString().AsStringView()) < 0; + argFirst->ToString(info.GetIsolate()) + .Compare(argSecond->ToString(info.GetIsolate()).AsStringView()) < 0; info.GetReturnValue().Set(result); return; } @@ -4762,15 +4834,20 @@ std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, info, 1); - if (argFirst->IsNull() || argSecond->IsNull()) { + if (argFirst->IsNull(info.GetIsolate()) || + argSecond->IsNull(info.GetIsolate())) { info.GetReturnValue().Set( - static_cast<int>(argFirst->IsNull() && argSecond->IsNull())); + static_cast<int>(argFirst->IsNull(info.GetIsolate()) && + argSecond->IsNull(info.GetIsolate()))); return; } - if (argFirst->IsString() && argSecond->IsString()) { + if (argFirst->IsString(info.GetIsolate()) && + argSecond->IsString(info.GetIsolate())) { int result = - argFirst->ToString().Compare(argSecond->ToString().AsStringView()) <= 0; + argFirst->ToString(info.GetIsolate()) + .Compare(argSecond->ToString(info.GetIsolate()).AsStringView()) <= + 0; info.GetReturnValue().Set(result); return; } @@ -4791,14 +4868,17 @@ std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, info, 1); - if (argFirst->IsNull() || argSecond->IsNull()) { + if (argFirst->IsNull(info.GetIsolate()) || + argSecond->IsNull(info.GetIsolate())) { info.GetReturnValue().Set(0); return; } - if (argFirst->IsString() && argSecond->IsString()) { + if (argFirst->IsString(info.GetIsolate()) && + argSecond->IsString(info.GetIsolate())) { int result = - argFirst->ToString().Compare(argSecond->ToString().AsStringView()) > 0; + argFirst->ToString(info.GetIsolate()) + .Compare(argSecond->ToString(info.GetIsolate()).AsStringView()) > 0; info.GetReturnValue().Set(result); return; } @@ -4819,15 +4899,20 @@ std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, info, 1); - if (argFirst->IsNull() || argSecond->IsNull()) { + if (argFirst->IsNull(info.GetIsolate()) || + argSecond->IsNull(info.GetIsolate())) { info.GetReturnValue().Set( - static_cast<int>(argFirst->IsNull() && argSecond->IsNull())); + static_cast<int>(argFirst->IsNull(info.GetIsolate()) && + argSecond->IsNull(info.GetIsolate()))); return; } - if (argFirst->IsString() && argSecond->IsString()) { + if (argFirst->IsString(info.GetIsolate()) && + argSecond->IsString(info.GetIsolate())) { int result = - argFirst->ToString().Compare(argSecond->ToString().AsStringView()) >= 0; + argFirst->ToString(info.GetIsolate()) + .Compare(argSecond->ToString(info.GetIsolate()).AsStringView()) >= + 0; info.GetReturnValue().Set(result); return; } @@ -4848,8 +4933,8 @@ auto argFirst = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[0]); auto argSecond = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[1]); - if (ValueIsNull(pThis, argFirst.get()) && - ValueIsNull(pThis, argSecond.get())) { + if (ValueIsNull(info.GetIsolate(), pThis, argFirst.get()) && + ValueIsNull(info.GetIsolate(), pThis, argSecond.get())) { info.GetReturnValue().SetNull(); return; } @@ -4870,7 +4955,8 @@ std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, info, 1); - if (argFirst->IsNull() && argSecond->IsNull()) { + if (argFirst->IsNull(info.GetIsolate()) && + argSecond->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } @@ -4891,7 +4977,8 @@ std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, info, 1); - if (argFirst->IsNull() && argSecond->IsNull()) { + if (argFirst->IsNull(info.GetIsolate()) && + argSecond->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } @@ -4913,7 +5000,8 @@ std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, info, 0); std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, info, 1); - if (argFirst->IsNull() && argSecond->IsNull()) { + if (argFirst->IsNull(info.GetIsolate()) && + argSecond->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } @@ -4938,7 +5026,7 @@ } std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); - if (argOne->IsNull()) { + if (argOne->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } @@ -4955,7 +5043,7 @@ } std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); - if (argOne->IsNull()) { + if (argOne->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } @@ -4972,7 +5060,7 @@ } std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); - if (argOne->IsNull()) { + if (argOne->IsNull(info.GetIsolate())) { info.GetReturnValue().SetNull(); return; } @@ -5006,7 +5094,7 @@ } std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, info, 0); - ByteString bsArg = ValueToUTF8String(argOne.get()); + ByteString bsArg = ValueToUTF8String(pThis, argOne.get()); if (bsArg.IsEmpty()) { pContext->ThrowArgumentMismatchException(); return; @@ -5034,7 +5122,7 @@ } auto argOne = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[0]); - info.GetReturnValue().Set(argOne->IsObject()); + info.GetReturnValue().Set(argOne->IsObject(info.GetIsolate())); } // static @@ -5047,7 +5135,7 @@ } auto argOne = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[0]); - info.GetReturnValue().Set(argOne->IsArray()); + info.GetReturnValue().Set(argOne->IsArray(info.GetIsolate())); } // static @@ -5061,29 +5149,32 @@ } auto argOne = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[0]); - if (argOne->IsArray()) { - v8::Isolate* pIsolate = pContext->GetScriptRuntime(); + if (argOne->IsArray(info.GetIsolate())) { + v8::Isolate* pIsolate = pContext->GetIsolate(); auto propertyValue = std::make_unique<CFXJSE_Value>(pIsolate); auto jsObjectValue = std::make_unique<CFXJSE_Value>(pIsolate); - argOne->GetObjectPropertyByIdx(1, propertyValue.get()); - argOne->GetObjectPropertyByIdx(2, jsObjectValue.get()); - if (propertyValue->IsNull()) { + argOne->GetObjectPropertyByIdx(info.GetIsolate(), 1, propertyValue.get()); + argOne->GetObjectPropertyByIdx(info.GetIsolate(), 2, jsObjectValue.get()); + if (propertyValue->IsNull(info.GetIsolate())) { auto pReturn = std::make_unique<CFXJSE_Value>(info.GetIsolate()); - GetObjectDefaultValue(jsObjectValue.get(), pReturn.get()); + GetObjectDefaultValue(info.GetIsolate(), jsObjectValue.get(), + pReturn.get()); info.GetReturnValue().Set(pReturn->DirectGetValue()); return; } auto pReturn = std::make_unique<CFXJSE_Value>(info.GetIsolate()); - jsObjectValue->GetObjectProperty(propertyValue->ToString().AsStringView(), - pReturn.get()); + jsObjectValue->GetObjectProperty( + info.GetIsolate(), + propertyValue->ToString(info.GetIsolate()).AsStringView(), + pReturn.get()); info.GetReturnValue().Set(pReturn->DirectGetValue()); return; } - if (argOne->IsObject()) { + if (argOne->IsObject(info.GetIsolate())) { auto pReturn = std::make_unique<CFXJSE_Value>(info.GetIsolate()); - GetObjectDefaultValue(argOne.get(), pReturn.get()); + GetObjectDefaultValue(info.GetIsolate(), argOne.get(), pReturn.get()); info.GetReturnValue().Set(pReturn->DirectGetValue()); return; } @@ -5101,21 +5192,21 @@ } auto argOne = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[0]); - if (!argOne->IsArray()) { + if (!argOne->IsArray(info.GetIsolate())) { info.GetReturnValue().Set(argOne->DirectGetValue()); return; } #ifndef NDEBUG CFXJSE_FormCalcContext* pContext = ToFormCalcContext(pThis); - v8::Isolate* pIsolate = pContext->GetScriptRuntime(); + v8::Isolate* pIsolate = pContext->GetIsolate(); auto lengthValue = std::make_unique<CFXJSE_Value>(pIsolate); - argOne->GetObjectProperty("length", lengthValue.get()); - ASSERT(lengthValue->ToInteger() >= 3); + argOne->GetObjectProperty(info.GetIsolate(), "length", lengthValue.get()); + ASSERT(lengthValue->ToInteger(info.GetIsolate()) >= 3); #endif auto pReturn = std::make_unique<CFXJSE_Value>(info.GetIsolate()); - argOne->GetObjectPropertyByIdx(2, pReturn.get()); + argOne->GetObjectPropertyByIdx(info.GetIsolate(), 2, pReturn.get()); info.GetReturnValue().Set(pReturn->DirectGetValue()); } @@ -5129,9 +5220,9 @@ return; } - v8::Isolate* pIsolate = pContext->GetScriptRuntime(); + v8::Isolate* pIsolate = pContext->GetIsolate(); auto argOne = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[0]); - if (!argOne->IsArray()) { + if (!argOne->IsArray(info.GetIsolate())) { std::unique_ptr<CFXJSE_Value> simpleValue = GetSimpleValue(pThis, info, 0); info.GetReturnValue().Set(simpleValue->DirectGetValue()); return; @@ -5139,13 +5230,13 @@ #ifndef NDEBUG auto lengthValue = std::make_unique<CFXJSE_Value>(pIsolate); - argOne->GetObjectProperty("length", lengthValue.get()); - ASSERT(lengthValue->ToInteger() >= 3); + argOne->GetObjectProperty(info.GetIsolate(), "length", lengthValue.get()); + ASSERT(lengthValue->ToInteger(info.GetIsolate()) >= 3); #endif auto flagsValue = std::make_unique<CFXJSE_Value>(pIsolate); - argOne->GetObjectPropertyByIdx(0, flagsValue.get()); - int32_t iFlags = flagsValue->ToInteger(); + argOne->GetObjectPropertyByIdx(info.GetIsolate(), 0, flagsValue.get()); + int32_t iFlags = flagsValue->ToInteger(info.GetIsolate()); if (iFlags != 3 && iFlags != 4) { std::unique_ptr<CFXJSE_Value> simpleValue = GetSimpleValue(pThis, info, 0); info.GetReturnValue().Set(simpleValue->DirectGetValue()); @@ -5157,18 +5248,18 @@ for (int32_t i = 0; i < 3; i++) values.push_back(std::make_unique<CFXJSE_Value>(pIsolate)); - values[0]->SetInteger(3); - values[1]->SetNull(); - values[2]->SetNull(); + values[0]->SetInteger(info.GetIsolate(), 3); + values[1]->SetNull(info.GetIsolate()); + values[2]->SetNull(info.GetIsolate()); auto pResult = std::make_unique<CFXJSE_Value>(info.GetIsolate()); - pResult->SetArray(values); + pResult->SetArray(info.GetIsolate(), values); info.GetReturnValue().Set(pResult->DirectGetValue()); return; } auto objectValue = std::make_unique<CFXJSE_Value>(pIsolate); - argOne->GetObjectPropertyByIdx(2, objectValue.get()); - if (objectValue->IsNull()) { + argOne->GetObjectPropertyByIdx(info.GetIsolate(), 2, objectValue.get()); + if (objectValue->IsNull(info.GetIsolate())) { pContext->ThrowCompilerErrorException(); return; } @@ -5179,24 +5270,26 @@ void CFXJSE_FormCalcContext::concat_fm_object( CFXJSE_HostObject* pThis, const v8::FunctionCallbackInfo<v8::Value>& info) { - v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetScriptRuntime(); + v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetIsolate(); std::vector<std::unique_ptr<CFXJSE_Value>> returnValues; for (int32_t i = 0; i < info.Length(); ++i) { auto argValue = std::make_unique<CFXJSE_Value>(pIsolate, info[i]); - if (argValue->IsArray()) { + if (argValue->IsArray(info.GetIsolate())) { auto lengthValue = std::make_unique<CFXJSE_Value>(pIsolate); - argValue->GetObjectProperty("length", lengthValue.get()); - int32_t length = lengthValue->ToInteger(); + argValue->GetObjectProperty(info.GetIsolate(), "length", + lengthValue.get()); + int32_t length = lengthValue->ToInteger(info.GetIsolate()); for (int32_t j = 2; j < length; j++) { returnValues.push_back(std::make_unique<CFXJSE_Value>(pIsolate)); - argValue->GetObjectPropertyByIdx(j, returnValues.back().get()); + argValue->GetObjectPropertyByIdx(info.GetIsolate(), j, + returnValues.back().get()); } } returnValues.push_back(std::make_unique<CFXJSE_Value>(pIsolate)); - returnValues.back()->Assign(argValue.get()); + returnValues.back()->Assign(info.GetIsolate(), argValue.get()); } auto pReturn = std::make_unique<CFXJSE_Value>(info.GetIsolate()); - pReturn->SetArray(returnValues); + pReturn->SetArray(info.GetIsolate(), returnValues); info.GetReturnValue().Set(pReturn->DirectGetValue()); } @@ -5205,90 +5298,95 @@ CFXJSE_HostObject* pThis, const v8::FunctionCallbackInfo<v8::Value>& info, uint32_t index) { - v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetScriptRuntime(); + v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetIsolate(); ASSERT(index < (uint32_t)info.Length()); auto argIndex = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[index]); - if (!argIndex->IsArray() && !argIndex->IsObject()) + if (!argIndex->IsArray(info.GetIsolate()) && + !argIndex->IsObject(info.GetIsolate())) return argIndex; - if (argIndex->IsArray()) { + if (argIndex->IsArray(info.GetIsolate())) { auto lengthValue = std::make_unique<CFXJSE_Value>(pIsolate); - argIndex->GetObjectProperty("length", lengthValue.get()); - int32_t iLength = lengthValue->ToInteger(); + argIndex->GetObjectProperty(info.GetIsolate(), "length", lengthValue.get()); + int32_t iLength = lengthValue->ToInteger(info.GetIsolate()); auto simpleValue = std::make_unique<CFXJSE_Value>(pIsolate); if (iLength < 3) { - simpleValue.get()->SetUndefined(); + simpleValue.get()->SetUndefined(info.GetIsolate()); return simpleValue; } auto propertyValue = std::make_unique<CFXJSE_Value>(pIsolate); auto jsObjectValue = std::make_unique<CFXJSE_Value>(pIsolate); - argIndex->GetObjectPropertyByIdx(1, propertyValue.get()); - argIndex->GetObjectPropertyByIdx(2, jsObjectValue.get()); - if (propertyValue->IsNull()) { - GetObjectDefaultValue(jsObjectValue.get(), simpleValue.get()); + argIndex->GetObjectPropertyByIdx(info.GetIsolate(), 1, propertyValue.get()); + argIndex->GetObjectPropertyByIdx(info.GetIsolate(), 2, jsObjectValue.get()); + if (propertyValue->IsNull(info.GetIsolate())) { + GetObjectDefaultValue(info.GetIsolate(), jsObjectValue.get(), + simpleValue.get()); return simpleValue; } - jsObjectValue->GetObjectProperty(propertyValue->ToString().AsStringView(), - simpleValue.get()); + jsObjectValue->GetObjectProperty( + info.GetIsolate(), + propertyValue->ToString(info.GetIsolate()).AsStringView(), + simpleValue.get()); return simpleValue; } auto defaultValue = std::make_unique<CFXJSE_Value>(pIsolate); - GetObjectDefaultValue(argIndex.get(), defaultValue.get()); + GetObjectDefaultValue(info.GetIsolate(), argIndex.get(), defaultValue.get()); return defaultValue; } // static -bool CFXJSE_FormCalcContext::ValueIsNull(CFXJSE_HostObject* pThis, +bool CFXJSE_FormCalcContext::ValueIsNull(v8::Isolate* pIsolate, + CFXJSE_HostObject* pThis, CFXJSE_Value* arg) { - if (!arg || arg->IsNull()) + if (!arg || arg->IsNull(pIsolate)) return true; - if (!arg->IsArray() && !arg->IsObject()) + if (!arg->IsArray(pIsolate) && !arg->IsObject(pIsolate)) return false; - v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetScriptRuntime(); - if (arg->IsArray()) { + if (arg->IsArray(pIsolate)) { int32_t iLength = hvalue_get_array_length(pThis, arg); if (iLength < 3) return true; auto propertyValue = std::make_unique<CFXJSE_Value>(pIsolate); auto jsObjectValue = std::make_unique<CFXJSE_Value>(pIsolate); - arg->GetObjectPropertyByIdx(1, propertyValue.get()); - arg->GetObjectPropertyByIdx(2, jsObjectValue.get()); - if (propertyValue->IsNull()) { + arg->GetObjectPropertyByIdx(pIsolate, 1, propertyValue.get()); + arg->GetObjectPropertyByIdx(pIsolate, 2, jsObjectValue.get()); + if (propertyValue->IsNull(pIsolate)) { auto defaultValue = std::make_unique<CFXJSE_Value>(pIsolate); - GetObjectDefaultValue(jsObjectValue.get(), defaultValue.get()); - return defaultValue->IsNull(); + GetObjectDefaultValue(pIsolate, jsObjectValue.get(), defaultValue.get()); + return defaultValue->IsNull(pIsolate); } auto newPropertyValue = std::make_unique<CFXJSE_Value>(pIsolate); - jsObjectValue->GetObjectProperty(propertyValue->ToString().AsStringView(), - newPropertyValue.get()); - return newPropertyValue->IsNull(); + jsObjectValue->GetObjectProperty( + pIsolate, propertyValue->ToString(pIsolate).AsStringView(), + newPropertyValue.get()); + return newPropertyValue->IsNull(pIsolate); } auto defaultValue = std::make_unique<CFXJSE_Value>(pIsolate); - GetObjectDefaultValue(arg, defaultValue.get()); - return defaultValue->IsNull(); + GetObjectDefaultValue(pIsolate, arg, defaultValue.get()); + return defaultValue->IsNull(pIsolate); } // static int32_t CFXJSE_FormCalcContext::hvalue_get_array_length( CFXJSE_HostObject* pThis, CFXJSE_Value* arg) { - if (!arg || !arg->IsArray()) + v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetIsolate(); + if (!arg || !arg->IsArray(pIsolate)) return 0; - v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetScriptRuntime(); auto lengthValue = std::make_unique<CFXJSE_Value>(pIsolate); - arg->GetObjectProperty("length", lengthValue.get()); - return lengthValue->ToInteger(); + arg->GetObjectProperty(pIsolate, "length", lengthValue.get()); + return lengthValue->ToInteger(pIsolate); } // static @@ -5298,20 +5396,22 @@ if (!firstValue) return false; - if (firstValue->IsString()) { - ByteString bsFirst = ValueToUTF8String(firstValue); - ByteString bsSecond = ValueToUTF8String(secondValue); + v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetIsolate(); + if (firstValue->IsString(pIsolate)) { + ByteString bsFirst = ValueToUTF8String(pThis, firstValue); + ByteString bsSecond = ValueToUTF8String(pThis, secondValue); return bsFirst == bsSecond; } - if (firstValue->IsNumber()) { + if (firstValue->IsNumber(pIsolate)) { float first = ValueToFloat(pThis, firstValue); float second = ValueToFloat(pThis, secondValue); return first == second; } - if (firstValue->IsBoolean()) - return firstValue->ToBoolean() == secondValue->ToBoolean(); + if (firstValue->IsBoolean(pIsolate)) + return firstValue->ToBoolean(pIsolate) == secondValue->ToBoolean(pIsolate); - return firstValue->IsNull() && secondValue && secondValue->IsNull(); + return firstValue->IsNull(pIsolate) && secondValue && + secondValue->IsNull(pIsolate); } // static @@ -5319,36 +5419,38 @@ CFXJSE_HostObject* pThis, const v8::FunctionCallbackInfo<v8::Value>& info) { std::vector<std::unique_ptr<CFXJSE_Value>> results; - v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetScriptRuntime(); + v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetIsolate(); for (int32_t i = 1; i < info.Length(); ++i) { auto arg = std::make_unique<CFXJSE_Value>(pIsolate, info[i]); - if (arg->IsArray()) { + if (arg->IsArray(pIsolate)) { auto lengthValue = std::make_unique<CFXJSE_Value>(pIsolate); - arg->GetObjectProperty("length", lengthValue.get()); - int32_t iLength = lengthValue->ToInteger(); + arg->GetObjectProperty(pIsolate, "length", lengthValue.get()); + int32_t iLength = lengthValue->ToInteger(pIsolate); if (iLength < 3) continue; auto propertyValue = std::make_unique<CFXJSE_Value>(pIsolate); - arg->GetObjectPropertyByIdx(1, propertyValue.get()); + arg->GetObjectPropertyByIdx(pIsolate, 1, propertyValue.get()); for (int32_t j = 2; j < iLength; j++) { auto jsObjectValue = std::make_unique<CFXJSE_Value>(pIsolate); - arg->GetObjectPropertyByIdx(j, jsObjectValue.get()); + arg->GetObjectPropertyByIdx(pIsolate, j, jsObjectValue.get()); results.push_back(std::make_unique<CFXJSE_Value>(pIsolate)); - if (propertyValue->IsNull()) { - GetObjectDefaultValue(jsObjectValue.get(), results.back().get()); + if (propertyValue->IsNull(pIsolate)) { + GetObjectDefaultValue(pIsolate, jsObjectValue.get(), + results.back().get()); } else { jsObjectValue->GetObjectProperty( - propertyValue->ToString().AsStringView(), results.back().get()); + pIsolate, propertyValue->ToString(pIsolate).AsStringView(), + results.back().get()); } } - } else if (arg->IsObject()) { + } else if (arg->IsObject(pIsolate)) { results.push_back(std::make_unique<CFXJSE_Value>(pIsolate)); - GetObjectDefaultValue(arg.get(), results.back().get()); + GetObjectDefaultValue(pIsolate, arg.get(), results.back().get()); } else { results.push_back(std::make_unique<CFXJSE_Value>(pIsolate)); - results.back()->Assign(arg.get()); + results.back()->Assign(pIsolate, arg.get()); } } return results; @@ -5401,8 +5503,9 @@ WideString::FromUTF8(bsAccessorName).AsStringView(), &resolveNodeRS, dwFlags, nullptr); if (bRet && resolveNodeRS.dwFlags == XFA_ResolveNodeRS::Type::kNodes) { - accessorValue->Assign(pScriptContext->GetOrCreateJSBindingFromMap( - resolveNodeRS.objects.front().Get())); + v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetIsolate(); + accessorValue->Assign(pIsolate, pScriptContext->GetOrCreateJSBindingFromMap( + resolveNodeRS.objects.front().Get())); return true; } return false; @@ -5419,16 +5522,17 @@ if (!pDoc) return false; + v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetIsolate(); WideString wsSomExpression = WideString::FromUTF8(bsSomExp); CFXJSE_Engine* pScriptContext = pDoc->GetScriptContext(); CXFA_Object* pNode = nullptr; uint32_t dFlags = 0UL; if (bDotAccessor) { - if (pRefValue && pRefValue->IsNull()) { + if (pRefValue && pRefValue->IsNull(pIsolate)) { pNode = pScriptContext->GetThisObject(); dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; } else { - pNode = CFXJSE_Engine::ToObject(pRefValue); + pNode = CFXJSE_Engine::ToObject(pIsolate, pRefValue); if (!pNode) return false; @@ -5453,7 +5557,7 @@ } } } else { - pNode = CFXJSE_Engine::ToObject(pRefValue); + pNode = CFXJSE_Engine::ToObject(pIsolate, pRefValue); dFlags = XFA_RESOLVENODE_AnyChild; } return pScriptContext->ResolveObjects(pNode, wsSomExpression.AsStringView(), @@ -5472,7 +5576,7 @@ resultValues->clear(); CFXJSE_FormCalcContext* pContext = ToFormCalcContext(pThis); - v8::Isolate* pIsolate = pContext->GetScriptRuntime(); + v8::Isolate* pIsolate = pContext->GetIsolate(); if (resolveNodeRS.dwFlags == XFA_ResolveNodeRS::Type::kNodes) { *bAttribute = false; @@ -5480,7 +5584,7 @@ for (auto& pObject : resolveNodeRS.objects) { resultValues->push_back(std::make_unique<CFXJSE_Value>(pIsolate)); resultValues->back()->Assign( - pScriptContext->GetOrCreateJSBindingFromMap(pObject.Get())); + pIsolate, pScriptContext->GetOrCreateJSBindingFromMap(pObject.Get())); } return; } @@ -5492,7 +5596,7 @@ auto pValue = std::make_unique<CFXJSE_Value>(pIsolate); CJX_Object* jsObject = pObject->JSObject(); (*resolveNodeRS.script_attribute.callback)( - jsObject, pValue.get(), false, + pIsolate, jsObject, pValue.get(), false, resolveNodeRS.script_attribute.attribute); resultValues->push_back(std::move(pValue)); *bAttribute = false; @@ -5500,11 +5604,11 @@ } if (!*bAttribute) return; - if (!pParentValue || !pParentValue->IsObject()) + if (!pParentValue || !pParentValue->IsObject(pIsolate)) return; resultValues->push_back(std::make_unique<CFXJSE_Value>(pIsolate)); - resultValues->back()->Assign(pParentValue); + resultValues->back()->Assign(pIsolate, pParentValue); } // static @@ -5513,30 +5617,32 @@ if (!pValue || pValue->IsEmpty()) return 0; - v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetScriptRuntime(); - if (pValue->IsArray()) { + v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetIsolate(); + if (pValue->IsArray(pIsolate)) { auto propertyValue = std::make_unique<CFXJSE_Value>(pIsolate); auto jsObjectValue = std::make_unique<CFXJSE_Value>(pIsolate); auto newPropertyValue = std::make_unique<CFXJSE_Value>(pIsolate); - pValue->GetObjectPropertyByIdx(1, propertyValue.get()); - pValue->GetObjectPropertyByIdx(2, jsObjectValue.get()); - if (propertyValue->IsNull()) { - GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); + pValue->GetObjectPropertyByIdx(pIsolate, 1, propertyValue.get()); + pValue->GetObjectPropertyByIdx(pIsolate, 2, jsObjectValue.get()); + if (propertyValue->IsNull(pIsolate)) { + GetObjectDefaultValue(pIsolate, jsObjectValue.get(), + newPropertyValue.get()); return ValueToInteger(pThis, newPropertyValue.get()); } - jsObjectValue->GetObjectProperty(propertyValue->ToString().AsStringView(), - newPropertyValue.get()); + jsObjectValue->GetObjectProperty( + pIsolate, propertyValue->ToString(pIsolate).AsStringView(), + newPropertyValue.get()); return ValueToInteger(pThis, newPropertyValue.get()); } - if (pValue->IsObject()) { + if (pValue->IsObject(pIsolate)) { auto newPropertyValue = std::make_unique<CFXJSE_Value>(pIsolate); - GetObjectDefaultValue(pValue, newPropertyValue.get()); + GetObjectDefaultValue(pIsolate, pValue, newPropertyValue.get()); return ValueToInteger(pThis, newPropertyValue.get()); } - if (pValue->IsString()) - return FXSYS_atoi(pValue->ToString().c_str()); - return pValue->ToInteger(); + if (pValue->IsString(pIsolate)) + return FXSYS_atoi(pValue->ToString(pIsolate).c_str()); + return pValue->ToInteger(pIsolate); } // static @@ -5545,31 +5651,33 @@ if (!arg) return 0.0f; - v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetScriptRuntime(); - if (arg->IsArray()) { + v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetIsolate(); + if (arg->IsArray(pIsolate)) { auto propertyValue = std::make_unique<CFXJSE_Value>(pIsolate); auto jsObjectValue = std::make_unique<CFXJSE_Value>(pIsolate); auto newPropertyValue = std::make_unique<CFXJSE_Value>(pIsolate); - arg->GetObjectPropertyByIdx(1, propertyValue.get()); - arg->GetObjectPropertyByIdx(2, jsObjectValue.get()); - if (propertyValue->IsNull()) { - GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); + arg->GetObjectPropertyByIdx(pIsolate, 1, propertyValue.get()); + arg->GetObjectPropertyByIdx(pIsolate, 2, jsObjectValue.get()); + if (propertyValue->IsNull(pIsolate)) { + GetObjectDefaultValue(pIsolate, jsObjectValue.get(), + newPropertyValue.get()); return ValueToFloat(pThis, newPropertyValue.get()); } - jsObjectValue->GetObjectProperty(propertyValue->ToString().AsStringView(), - newPropertyValue.get()); + jsObjectValue->GetObjectProperty( + pIsolate, propertyValue->ToString(pIsolate).AsStringView(), + newPropertyValue.get()); return ValueToFloat(pThis, newPropertyValue.get()); } - if (arg->IsObject()) { + if (arg->IsObject(pIsolate)) { auto newPropertyValue = std::make_unique<CFXJSE_Value>(pIsolate); - GetObjectDefaultValue(arg, newPropertyValue.get()); + GetObjectDefaultValue(pIsolate, arg, newPropertyValue.get()); return ValueToFloat(pThis, newPropertyValue.get()); } - if (arg->IsString()) - return strtof(arg->ToString().c_str(), nullptr); - if (arg->IsUndefined() || arg->IsEmpty()) + if (arg->IsString(pIsolate)) + return strtof(arg->ToString(pIsolate).c_str(), nullptr); + if (arg->IsUndefined(pIsolate) || arg->IsEmpty()) return 0.0f; - return arg->ToFloat(); + return arg->ToFloat(pIsolate); } // static @@ -5578,31 +5686,33 @@ if (!arg) return 0; - v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetScriptRuntime(); - if (arg->IsArray()) { + v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetIsolate(); + if (arg->IsArray(pIsolate)) { auto propertyValue = std::make_unique<CFXJSE_Value>(pIsolate); auto jsObjectValue = std::make_unique<CFXJSE_Value>(pIsolate); auto newPropertyValue = std::make_unique<CFXJSE_Value>(pIsolate); - arg->GetObjectPropertyByIdx(1, propertyValue.get()); - arg->GetObjectPropertyByIdx(2, jsObjectValue.get()); - if (propertyValue->IsNull()) { - GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); + arg->GetObjectPropertyByIdx(pIsolate, 1, propertyValue.get()); + arg->GetObjectPropertyByIdx(pIsolate, 2, jsObjectValue.get()); + if (propertyValue->IsNull(pIsolate)) { + GetObjectDefaultValue(pIsolate, jsObjectValue.get(), + newPropertyValue.get()); return ValueToDouble(pThis, newPropertyValue.get()); } - jsObjectValue->GetObjectProperty(propertyValue->ToString().AsStringView(), - newPropertyValue.get()); + jsObjectValue->GetObjectProperty( + pIsolate, propertyValue->ToString(pIsolate).AsStringView(), + newPropertyValue.get()); return ValueToDouble(pThis, newPropertyValue.get()); } - if (arg->IsObject()) { + if (arg->IsObject(pIsolate)) { auto newPropertyValue = std::make_unique<CFXJSE_Value>(pIsolate); - GetObjectDefaultValue(arg, newPropertyValue.get()); + GetObjectDefaultValue(pIsolate, arg, newPropertyValue.get()); return ValueToDouble(pThis, newPropertyValue.get()); } - if (arg->IsString()) - return strtod(arg->ToString().c_str(), nullptr); - if (arg->IsUndefined() || arg->IsEmpty()) + if (arg->IsString(pIsolate)) + return strtod(arg->ToString(pIsolate).c_str(), nullptr); + if (arg->IsUndefined(pIsolate) || arg->IsEmpty()) return 0; - return arg->ToDouble(); + return arg->ToDouble(pIsolate); } // static. @@ -5615,13 +5725,13 @@ if (!src) return 0; - if (!src->IsArray()) + v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetIsolate(); + if (!src->IsArray(pIsolate)) return ValueToDouble(pThis, src); - v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetScriptRuntime(); auto lengthValue = std::make_unique<CFXJSE_Value>(pIsolate); - src->GetObjectProperty("length", lengthValue.get()); - int32_t iLength = lengthValue->ToInteger(); + src->GetObjectProperty(pIsolate, "length", lengthValue.get()); + int32_t iLength = lengthValue->ToInteger(pIsolate); if (iLength <= 2) { *ret = false; return 0.0; @@ -5629,24 +5739,28 @@ auto propertyValue = std::make_unique<CFXJSE_Value>(pIsolate); auto jsObjectValue = std::make_unique<CFXJSE_Value>(pIsolate); - src->GetObjectPropertyByIdx(1, propertyValue.get()); - src->GetObjectPropertyByIdx(2, jsObjectValue.get()); - if (propertyValue->IsNull()) + src->GetObjectPropertyByIdx(pIsolate, 1, propertyValue.get()); + src->GetObjectPropertyByIdx(pIsolate, 2, jsObjectValue.get()); + if (propertyValue->IsNull(pIsolate)) return ValueToDouble(pThis, jsObjectValue.get()); auto newPropertyValue = std::make_unique<CFXJSE_Value>(pIsolate); - jsObjectValue->GetObjectProperty(propertyValue->ToString().AsStringView(), - newPropertyValue.get()); + jsObjectValue->GetObjectProperty( + pIsolate, propertyValue->ToString(pIsolate).AsStringView(), + newPropertyValue.get()); return ValueToDouble(pThis, newPropertyValue.get()); } // static -ByteString CFXJSE_FormCalcContext::ValueToUTF8String(CFXJSE_Value* arg) { - if (!arg || arg->IsNull() || arg->IsUndefined() || arg->IsEmpty()) +ByteString CFXJSE_FormCalcContext::ValueToUTF8String(CFXJSE_HostObject* pThis, + CFXJSE_Value* arg) { + v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetIsolate(); + if (!arg || arg->IsNull(pIsolate) || arg->IsUndefined(pIsolate) || + arg->IsEmpty()) return ByteString(); - if (arg->IsBoolean()) - return arg->ToBoolean() ? "1" : "0"; - return arg->ToString(); + if (arg->IsBoolean(pIsolate)) + return arg->ToBoolean(pIsolate) ? "1" : "0"; + return arg->ToString(pIsolate); } Optional<CFX_WideTextBuf> CFXJSE_FormCalcContext::Translate( @@ -5672,14 +5786,14 @@ return wsJavaScript; } -CFXJSE_FormCalcContext::CFXJSE_FormCalcContext(v8::Isolate* pScriptIsolate, +CFXJSE_FormCalcContext::CFXJSE_FormCalcContext(v8::Isolate* pIsolate, CFXJSE_Context* pScriptContext, CXFA_Document* pDoc) - : m_pIsolate(pScriptIsolate), - m_pValue(std::make_unique<CFXJSE_Value>(pScriptIsolate)), + : m_pIsolate(pIsolate), + m_pValue(std::make_unique<CFXJSE_Value>(pIsolate)), m_pDocument(pDoc) { m_pValue->SetHostObject( - this, + pIsolate, this, CFXJSE_Class::Create(pScriptContext, &kFormCalcFM2JSDescriptor, false)); } @@ -5690,7 +5804,7 @@ } void CFXJSE_FormCalcContext::GlobalPropertyGetter(CFXJSE_Value* pValue) { - pValue->Assign(m_pValue.get()); + pValue->Assign(GetIsolate(), m_pValue.get()); } // static @@ -5699,7 +5813,7 @@ const v8::FunctionCallbackInfo<v8::Value>& info, bool bDotAccessor) { CFXJSE_FormCalcContext* pContext = ToFormCalcContext(pThis); - v8::Isolate* pIsolate = pContext->GetScriptRuntime(); + v8::Isolate* pIsolate = pContext->GetIsolate(); int32_t argc = info.Length(); if (argc < 4 || argc > 5) { pContext->ThrowCompilerErrorException(); @@ -5723,10 +5837,11 @@ bIsStar); auto argAccessor = std::make_unique<CFXJSE_Value>(info.GetIsolate(), info[0]); - if (argAccessor->IsArray()) { + if (argAccessor->IsArray(info.GetIsolate())) { auto pLengthValue = std::make_unique<CFXJSE_Value>(pIsolate); - argAccessor->GetObjectProperty("length", pLengthValue.get()); - int32_t iLength = pLengthValue->ToInteger(); + argAccessor->GetObjectProperty(info.GetIsolate(), "length", + pLengthValue.get()); + int32_t iLength = pLengthValue->ToInteger(info.GetIsolate()); if (iLength < 3) { pContext->ThrowArgumentMismatchException(); return; @@ -5738,7 +5853,8 @@ bool bAttribute = false; bool bAllEmpty = true; for (int32_t i = 2; i < iLength; i++) { - argAccessor->GetObjectPropertyByIdx(i, hJSObjValue.get()); + argAccessor->GetObjectPropertyByIdx(info.GetIsolate(), i, + hJSObjValue.get()); XFA_ResolveNodeRS resolveNodeRS; if (ResolveObjects(pThis, hJSObjValue.get(), bsSomExp.AsStringView(), &resolveNodeRS, bDotAccessor, bHasNoResolveName)) { @@ -5756,21 +5872,21 @@ std::vector<std::unique_ptr<CFXJSE_Value>> values; values.push_back(std::make_unique<CFXJSE_Value>(pIsolate)); - values.back()->SetInteger(1); + values.back()->SetInteger(pIsolate, 1); values.push_back(std::make_unique<CFXJSE_Value>(pIsolate)); if (bAttribute) - values.back()->SetString(bsName.AsStringView()); + values.back()->SetString(pIsolate, bsName.AsStringView()); else - values.back()->SetNull(); + values.back()->SetNull(pIsolate); for (int32_t i = 0; i < iLength - 2; i++) { for (size_t j = 0; j < resolveValues[i].size(); j++) { values.push_back(std::make_unique<CFXJSE_Value>(pIsolate)); - values.back()->Assign(resolveValues[i][j].get()); + values.back()->Assign(pIsolate, resolveValues[i][j].get()); } } auto pReturn = std::make_unique<CFXJSE_Value>(info.GetIsolate()); - pReturn->SetArray(values); + pReturn->SetArray(pIsolate, values); info.GetReturnValue().Set(pReturn->DirectGetValue()); return; } @@ -5779,11 +5895,11 @@ bool bRet = false; ByteString bsAccessorName = fxv8::ReentrantToByteStringHelper(info.GetIsolate(), info[1]); - if (argAccessor->IsObject() || - (argAccessor->IsNull() && bsAccessorName.IsEmpty())) { + if (argAccessor->IsObject(pIsolate) || + (argAccessor->IsNull(pIsolate) && bsAccessorName.IsEmpty())) { bRet = ResolveObjects(pThis, argAccessor.get(), bsSomExp.AsStringView(), &resolveNodeRS, bDotAccessor, bHasNoResolveName); - } else if (!argAccessor->IsObject() && !bsAccessorName.IsEmpty() && + } else if (!argAccessor->IsObject(pIsolate) && !bsAccessorName.IsEmpty() && GetObjectForName(pThis, argAccessor.get(), bsAccessorName.AsStringView())) { bRet = ResolveObjects(pThis, argAccessor.get(), bsSomExp.AsStringView(), @@ -5805,17 +5921,17 @@ for (size_t i = 0; i < resolveValues.size() + 2; i++) values.push_back(std::make_unique<CFXJSE_Value>(pIsolate)); - values[0]->SetInteger(1); + values[0]->SetInteger(pIsolate, 1); if (bAttribute) - values[1]->SetString(bsName.AsStringView()); + values[1]->SetString(pIsolate, bsName.AsStringView()); else - values[1]->SetNull(); + values[1]->SetNull(pIsolate); for (size_t i = 0; i < resolveValues.size(); i++) - values[i + 2]->Assign(resolveValues[i].get()); + values[i + 2]->Assign(pIsolate, resolveValues[i].get()); auto pReturn = std::make_unique<CFXJSE_Value>(info.GetIsolate()); - pReturn->SetArray(values); + pReturn->SetArray(pIsolate, values); info.GetReturnValue().Set(pReturn->DirectGetValue()); }
diff --git a/fxjs/xfa/cfxjse_formcalc_context.h b/fxjs/xfa/cfxjse_formcalc_context.h index 1a005f5..19b88ca 100644 --- a/fxjs/xfa/cfxjse_formcalc_context.h +++ b/fxjs/xfa/cfxjse_formcalc_context.h
@@ -25,7 +25,7 @@ class CFXJSE_FormCalcContext final : public CFXJSE_HostObject { public: - CFXJSE_FormCalcContext(v8::Isolate* pScriptIsolate, + CFXJSE_FormCalcContext(v8::Isolate* pIsolate, CFXJSE_Context* pScriptContext, CXFA_Document* pDoc); ~CFXJSE_FormCalcContext() override; @@ -295,11 +295,14 @@ CFXJSE_HostObject* pThis, const v8::FunctionCallbackInfo<v8::Value>& info, uint32_t index); - static bool ValueIsNull(CFXJSE_HostObject* pThis, CFXJSE_Value* pValue); + static bool ValueIsNull(v8::Isolate* pIsolate, + CFXJSE_HostObject* pThis, + CFXJSE_Value* pValue); static int32_t ValueToInteger(CFXJSE_HostObject* pThis, CFXJSE_Value* pValue); static float ValueToFloat(CFXJSE_HostObject* pThis, CFXJSE_Value* pValue); static double ValueToDouble(CFXJSE_HostObject* pThis, CFXJSE_Value* pValue); - static ByteString ValueToUTF8String(CFXJSE_Value* pValue); + static ByteString ValueToUTF8String(CFXJSE_HostObject* pThis, + CFXJSE_Value* pValue); static double ExtractDouble(CFXJSE_HostObject* pThis, CFXJSE_Value* src, bool* ret); @@ -313,7 +316,7 @@ const v8::FunctionCallbackInfo<v8::Value>& info, bool bDotAccessor); - v8::Isolate* GetScriptRuntime() const { return m_pIsolate.Get(); } + v8::Isolate* GetIsolate() const { return m_pIsolate.Get(); } CXFA_Document* GetDocument() const { return m_pDocument.Get(); } void ThrowNoDefaultPropertyException(ByteStringView name) const;
diff --git a/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp b/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp index 97b7b87..545c3d8 100644 --- a/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp +++ b/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp
@@ -16,7 +16,7 @@ protected: bool ExecuteExpectNull(ByteStringView input) { - return Execute(input) && GetValue()->IsNull(); + return Execute(input) && GetValue()->IsNull(isolate()); } }; @@ -38,8 +38,8 @@ EXPECT_TRUE(Execute(input)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsInteger()); - EXPECT_EQ(123, value->ToInteger()) << "Program: " << input; + EXPECT_TRUE(value->IsInteger(isolate())); + EXPECT_EQ(123, value->ToInteger(isolate())) << "Program: " << input; } TEST_F(CFXJSE_FormCalcContextEmbedderTest, Numeric) { @@ -77,8 +77,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsInteger()); - EXPECT_EQ(tests[i].result, value->ToInteger()) + EXPECT_TRUE(value->IsInteger(isolate())); + EXPECT_EQ(tests[i].result, value->ToInteger(isolate())) << "Program: " << tests[i].program; } } @@ -98,10 +98,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -139,8 +139,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsInteger()) << "Program: " << tests[i].program; - EXPECT_EQ(tests[i].result, value->ToBoolean()) + EXPECT_TRUE(value->IsInteger(isolate())) << "Program: " << tests[i].program; + EXPECT_EQ(tests[i].result, value->ToBoolean(isolate())) << "Program: " << tests[i].program; } } @@ -157,8 +157,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsNumber()); - EXPECT_FLOAT_EQ(tests[i].result, value->ToFloat()) + EXPECT_TRUE(value->IsNumber(isolate())); + EXPECT_FLOAT_EQ(tests[i].result, value->ToFloat(isolate())) << "Program: " << tests[i].program; } } @@ -175,8 +175,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsNumber()); - EXPECT_FLOAT_EQ(tests[i].result, value->ToFloat()) + EXPECT_TRUE(value->IsNumber(isolate())); + EXPECT_FLOAT_EQ(tests[i].result, value->ToFloat(isolate())) << "Program: " << tests[i].program; } } @@ -193,8 +193,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsInteger()); - EXPECT_EQ(tests[i].result, value->ToInteger()) + EXPECT_TRUE(value->IsInteger(isolate())); + EXPECT_EQ(tests[i].result, value->ToInteger(isolate())) << "Program: " << tests[i].program; } } @@ -211,8 +211,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsInteger()); - EXPECT_EQ(tests[i].result, value->ToInteger()) + EXPECT_TRUE(value->IsInteger(isolate())); + EXPECT_EQ(tests[i].result, value->ToInteger(isolate())) << "Program: " << tests[i].program; } } @@ -231,8 +231,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsInteger()); - EXPECT_EQ(tests[i].result, value->ToInteger()) + EXPECT_TRUE(value->IsInteger(isolate())); + EXPECT_EQ(tests[i].result, value->ToInteger(isolate())) << "Program: " << tests[i].program; } } @@ -251,8 +251,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsInteger()); - EXPECT_EQ(tests[i].result, value->ToInteger()) + EXPECT_TRUE(value->IsInteger(isolate())); + EXPECT_EQ(tests[i].result, value->ToInteger(isolate())) << "Program: " << tests[i].program; } } @@ -273,8 +273,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsInteger()); - EXPECT_EQ(tests[i].result, value->ToInteger()) + EXPECT_TRUE(value->IsInteger(isolate())); + EXPECT_EQ(tests[i].result, value->ToInteger(isolate())) << "Program: " << tests[i].program; } } @@ -291,8 +291,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsInteger()); - EXPECT_EQ(tests[i].result, value->ToInteger()) + EXPECT_TRUE(value->IsInteger(isolate())); + EXPECT_EQ(tests[i].result, value->ToInteger(isolate())) << "Program: " << tests[i].program; } } @@ -312,8 +312,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsNumber()) << "Program: " << tests[i].program; - EXPECT_FLOAT_EQ(tests[i].result, value->ToFloat()) + EXPECT_TRUE(value->IsNumber(isolate())) << "Program: " << tests[i].program; + EXPECT_FLOAT_EQ(tests[i].result, value->ToFloat(isolate())) << "Program: " << tests[i].program; } } @@ -332,8 +332,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsInteger()); - EXPECT_EQ(tests[i].result, value->ToInteger()) + EXPECT_TRUE(value->IsInteger(isolate())); + EXPECT_EQ(tests[i].result, value->ToInteger(isolate())) << "Program: " << tests[i].program; } } @@ -371,8 +371,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsInteger()); - EXPECT_EQ(tests[i].result, value->ToInteger()) + EXPECT_TRUE(value->IsInteger(isolate())); + EXPECT_EQ(tests[i].result, value->ToInteger(isolate())) << "Program: " << tests[i].program; } } @@ -394,10 +394,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -417,8 +417,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsInteger()); - EXPECT_EQ(tests[i].result, value->ToInteger()) + EXPECT_TRUE(value->IsInteger(isolate())); + EXPECT_EQ(tests[i].result, value->ToInteger(isolate())) << "Program: " << tests[i].program; } } @@ -435,8 +435,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsInteger()); - EXPECT_EQ(tests[i].result, value->ToInteger()) + EXPECT_TRUE(value->IsInteger(isolate())); + EXPECT_EQ(tests[i].result, value->ToInteger(isolate())) << "Program: " << tests[i].program; } } @@ -456,10 +456,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -478,10 +478,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -503,10 +503,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()) << "Program: " << tests[i].program; - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())) << "Program: " << tests[i].program; + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -527,10 +527,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -547,10 +547,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -582,8 +582,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsInteger()); - EXPECT_EQ(tests[i].result, value->ToInteger()) + EXPECT_TRUE(value->IsInteger(isolate())); + EXPECT_EQ(tests[i].result, value->ToInteger(isolate())) << "Program: " << tests[i].program; } } @@ -605,10 +605,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -625,8 +625,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsNumber()); - EXPECT_NEAR(tests[i].result, value->ToFloat(), 0.000001) + EXPECT_TRUE(value->IsNumber(isolate())); + EXPECT_NEAR(tests[i].result, value->ToFloat(isolate()), 0.000001) << "Program: " << tests[i].program; } } @@ -647,8 +647,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsNumber()); - EXPECT_FLOAT_EQ(tests[i].result, value->ToFloat()) + EXPECT_TRUE(value->IsNumber(isolate())); + EXPECT_FLOAT_EQ(tests[i].result, value->ToFloat(isolate())) << "Program: " << tests[i].program; } } @@ -666,8 +666,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsNumber()); - EXPECT_FLOAT_EQ(tests[i].result, value->ToFloat()) + EXPECT_TRUE(value->IsNumber(isolate())); + EXPECT_FLOAT_EQ(tests[i].result, value->ToFloat(isolate())) << "Program: " << tests[i].program; } } @@ -686,8 +686,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsNumber()); - EXPECT_FLOAT_EQ(tests[i].result, value->ToFloat()) + EXPECT_TRUE(value->IsNumber(isolate())); + EXPECT_FLOAT_EQ(tests[i].result, value->ToFloat(isolate())) << "Program: " << tests[i].program; } } @@ -706,8 +706,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsNumber()) << "Program: " << tests[i].program; - EXPECT_FLOAT_EQ(tests[i].result, value->ToFloat()) + EXPECT_TRUE(value->IsNumber(isolate())) << "Program: " << tests[i].program; + EXPECT_FLOAT_EQ(tests[i].result, value->ToFloat(isolate())) << "Program: " << tests[i].program; } } @@ -725,8 +725,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsNumber()); - EXPECT_FLOAT_EQ(tests[i].result, value->ToFloat()) + EXPECT_TRUE(value->IsNumber(isolate())); + EXPECT_FLOAT_EQ(tests[i].result, value->ToFloat(isolate())) << "Program: " << tests[i].program; } } @@ -747,8 +747,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsNumber()); - EXPECT_FLOAT_EQ(tests[i].result, value->ToFloat()) + EXPECT_TRUE(value->IsNumber(isolate())); + EXPECT_FLOAT_EQ(tests[i].result, value->ToFloat(isolate())) << "Program: " << tests[i].program; } } @@ -768,8 +768,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsNumber()); - EXPECT_FLOAT_EQ(tests[i].result, value->ToFloat()) + EXPECT_TRUE(value->IsNumber(isolate())); + EXPECT_FLOAT_EQ(tests[i].result, value->ToFloat(isolate())) << "Program: " << tests[i].program; } } @@ -787,8 +787,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsNumber()); - EXPECT_NEAR(tests[i].result, value->ToFloat(), 0.000001) + EXPECT_TRUE(value->IsNumber(isolate())); + EXPECT_NEAR(tests[i].result, value->ToFloat(isolate()), 0.000001) << "Program: " << tests[i].program; } } @@ -806,8 +806,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsNumber()); - EXPECT_FLOAT_EQ(tests[i].result, value->ToFloat()) + EXPECT_TRUE(value->IsNumber(isolate())); + EXPECT_FLOAT_EQ(tests[i].result, value->ToFloat(isolate())) << "Program: " << tests[i].program; } } @@ -828,10 +828,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -840,8 +840,8 @@ EXPECT_TRUE(Execute("Exists(\"hello world\")")); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsInteger()); - EXPECT_FALSE(value->ToBoolean()); + EXPECT_TRUE(value->IsInteger(isolate())); + EXPECT_FALSE(value->ToBoolean(isolate())); } TEST_F(CFXJSE_FormCalcContextEmbedderTest, HasValue) { @@ -856,8 +856,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsInteger()) << "Program: " << tests[i].program; - EXPECT_EQ(tests[i].result, value->ToBoolean()) + EXPECT_TRUE(value->IsInteger(isolate())) << "Program: " << tests[i].program; + EXPECT_EQ(tests[i].result, value->ToBoolean(isolate())) << "Program: " << tests[i].program; } } @@ -881,8 +881,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsInteger()) << "Program: " << tests[i].program; - EXPECT_EQ(tests[i].result, value->ToBoolean()) + EXPECT_TRUE(value->IsInteger(isolate())) << "Program: " << tests[i].program; + EXPECT_EQ(tests[i].result, value->ToBoolean(isolate())) << "Program: " << tests[i].program; } } @@ -901,8 +901,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsInteger()) << "Program: " << tests[i].program; - EXPECT_EQ(tests[i].result, value->ToBoolean()) + EXPECT_TRUE(value->IsInteger(isolate())) << "Program: " << tests[i].program; + EXPECT_EQ(tests[i].result, value->ToBoolean(isolate())) << "Program: " << tests[i].program; } } @@ -919,8 +919,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsInteger()); - EXPECT_EQ(tests[i].result, value->ToInteger()) + EXPECT_TRUE(value->IsInteger(isolate())); + EXPECT_EQ(tests[i].result, value->ToInteger(isolate())) << "Program: " << tests[i].program; } } @@ -938,17 +938,17 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } EXPECT_TRUE(Execute("Null() + 5")); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsInteger()); - EXPECT_EQ(5, value->ToInteger()); + EXPECT_TRUE(value->IsInteger(isolate())); + EXPECT_EQ(5, value->ToInteger(isolate())); } TEST_F(CFXJSE_FormCalcContextEmbedderTest, Ref) { @@ -963,10 +963,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -987,10 +987,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -1011,8 +1011,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsNumber()); - EXPECT_FLOAT_EQ(tests[i].result, value->ToFloat()) + EXPECT_TRUE(value->IsNumber(isolate())); + EXPECT_FLOAT_EQ(tests[i].result, value->ToFloat(isolate())) << "Program: " << tests[i].program; } } @@ -1031,8 +1031,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsInteger()); - EXPECT_EQ(tests[i].result, value->ToInteger()) + EXPECT_TRUE(value->IsInteger(isolate())); + EXPECT_EQ(tests[i].result, value->ToInteger(isolate())) << "Program: " << tests[i].program; } } @@ -1053,10 +1053,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -1096,10 +1096,10 @@ for (size_t i = 0; i < pdfium::size(tests); ++i) { EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -1133,10 +1133,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -1153,10 +1153,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -1173,10 +1173,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -1193,8 +1193,8 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsInteger()); - EXPECT_EQ(tests[i].result, value->ToInteger()) + EXPECT_TRUE(value->IsInteger(isolate())); + EXPECT_EQ(tests[i].result, value->ToInteger(isolate())) << "Program: " << tests[i].program; } } @@ -1213,10 +1213,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -1243,10 +1243,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -1262,16 +1262,16 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } EXPECT_TRUE(Execute("Parse(\"$9,999,999.99\", \"$1,234,567.89\")")); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsNumber()); - EXPECT_FLOAT_EQ(1234567.89f, value->ToFloat()); + EXPECT_TRUE(value->IsNumber(isolate())); + EXPECT_FLOAT_EQ(1234567.89f, value->ToFloat(isolate())); } TEST_F(CFXJSE_FormCalcContextEmbedderTest, Replace) { @@ -1288,10 +1288,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -1308,10 +1308,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -1328,10 +1328,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -1348,10 +1348,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -1370,10 +1370,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -1392,10 +1392,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -1439,10 +1439,10 @@ EXPECT_TRUE(Execute(test.program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(test.result, value->ToString().c_str()) - << "Program: " << test.program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(test.result, value->ToString(isolate()).c_str()) + << "Program: " << test.program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -1452,7 +1452,7 @@ EXPECT_TRUE(Execute("Uuid()")); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); + EXPECT_TRUE(value->IsString(isolate())); } TEST_F(CFXJSE_FormCalcContextEmbedderTest, Upper) { @@ -1469,10 +1469,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -1495,10 +1495,10 @@ EXPECT_TRUE(Execute(tests[i].program)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ(tests[i].result, value->ToString().c_str()) - << "Program: " << tests[i].program << " Result: '" << value->ToString() - << "'"; + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ(tests[i].result, value->ToString(isolate()).c_str()) + << "Program: " << tests[i].program << " Result: '" + << value->ToString(isolate()) << "'"; } } @@ -1536,8 +1536,8 @@ EXPECT_TRUE(Execute(test)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ("12.7mm", value->ToString().c_str()); + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ("12.7mm", value->ToString(isolate()).c_str()); } TEST_F(CFXJSE_FormCalcContextEmbedderTest, GetXFAEventChange) { @@ -1553,8 +1553,8 @@ EXPECT_TRUE(Execute(test)); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsString()); - EXPECT_STREQ("changed", value->ToString().c_str()); + EXPECT_TRUE(value->IsString(isolate())); + EXPECT_STREQ("changed", value->ToString(isolate()).c_str()); context->SetEventParam(nullptr); } @@ -1654,8 +1654,8 @@ EXPECT_TRUE(Execute("xfa.event.cancelAction")); CFXJSE_Value* value = GetValue(); - EXPECT_TRUE(value->IsBoolean()); - EXPECT_FALSE(value->ToBoolean()); + EXPECT_TRUE(value->IsBoolean(isolate())); + EXPECT_FALSE(value->ToBoolean(isolate())); EXPECT_TRUE(Execute("xfa.event.cancelAction = \"true\"")); EXPECT_TRUE(params.m_bCancelAction);
diff --git a/fxjs/xfa/cfxjse_resolveprocessor.cpp b/fxjs/xfa/cfxjse_resolveprocessor.cpp index 0d6d566..968bca4 100644 --- a/fxjs/xfa/cfxjse_resolveprocessor.cpp +++ b/fxjs/xfa/cfxjse_resolveprocessor.cpp
@@ -26,7 +26,8 @@ namespace { -void DoPredicateFilter(WideString wsCondition, +void DoPredicateFilter(v8::Isolate* pIsolate, + WideString wsCondition, size_t iFoundCount, CFXJSE_ResolveNodeData* pRnd) { ASSERT(iFoundCount == pRnd->m_Objects.size()); @@ -45,7 +46,7 @@ bool bRet = pRnd->m_pSC->RunScript(eLangType, wsExpression.AsStringView(), pRetValue.get(), pRnd->m_Objects[i - 1].Get()); - if (!bRet || !pRetValue->ToBoolean()) + if (!bRet || !pRetValue->ToBoolean(pIsolate)) pRnd->m_Objects.erase(pRnd->m_Objects.begin() + i - 1); } } @@ -57,7 +58,8 @@ CFXJSE_ResolveProcessor::~CFXJSE_ResolveProcessor() = default; -bool CFXJSE_ResolveProcessor::Resolve(CFXJSE_ResolveNodeData& rnd) { +bool CFXJSE_ResolveProcessor::Resolve(v8::Isolate* pIsolate, + CFXJSE_ResolveNodeData& rnd) { if (!rnd.m_CurObject) return false; @@ -69,22 +71,22 @@ return false; } if (rnd.m_dwStyles & XFA_RESOLVENODE_AnyChild) - return ResolveAnyChild(rnd); + return ResolveAnyChild(pIsolate, rnd); if (rnd.m_wsName.GetLength()) { wchar_t wch = rnd.m_wsName[0]; switch (wch) { case '$': - return ResolveDollar(rnd); + return ResolveDollar(pIsolate, rnd); case '!': - return ResolveExcalmatory(rnd); + return ResolveExcalmatory(pIsolate, rnd); case '#': - return ResolveNumberSign(rnd); + return ResolveNumberSign(pIsolate, rnd); case '*': return ResolveAsterisk(rnd); // TODO(dsinclair): We could probably remove this. case '.': - return ResolveAnyChild(rnd); + return ResolveAnyChild(pIsolate, rnd); default: break; } @@ -106,17 +108,18 @@ return true; } if (!rnd.m_Objects.empty()) - FilterCondition(rnd.m_wsCondition, &rnd); + FilterCondition(pIsolate, rnd.m_wsCondition, &rnd); return !rnd.m_Objects.empty(); } - if (!ResolveNormal(rnd) && rnd.m_uHashName == XFA_HASHCODE_Xfa) + if (!ResolveNormal(pIsolate, rnd) && rnd.m_uHashName == XFA_HASHCODE_Xfa) rnd.m_Objects.emplace_back(rnd.m_pSC->GetDocument()->GetRoot()); return !rnd.m_Objects.empty(); } -bool CFXJSE_ResolveProcessor::ResolveAnyChild(CFXJSE_ResolveNodeData& rnd) { +bool CFXJSE_ResolveProcessor::ResolveAnyChild(v8::Isolate* pIsolate, + CFXJSE_ResolveNodeData& rnd) { CXFA_Node* pParent = ToNode(rnd.m_CurObject.Get()); if (!pParent) return false; @@ -144,11 +147,12 @@ nodes.insert(nodes.end(), siblings.begin(), siblings.end()); rnd.m_Objects = std::vector<UnownedPtr<CXFA_Object>>(nodes.begin(), nodes.end()); - FilterCondition(wsCondition, &rnd); + FilterCondition(pIsolate, wsCondition, &rnd); return !rnd.m_Objects.empty(); } -bool CFXJSE_ResolveProcessor::ResolveDollar(CFXJSE_ResolveNodeData& rnd) { +bool CFXJSE_ResolveProcessor::ResolveDollar(v8::Isolate* pIsolate, + CFXJSE_ResolveNodeData& rnd) { WideString wsName = rnd.m_wsName; WideString wsCondition = rnd.m_wsCondition; int32_t iNameLen = wsName.GetLength(); @@ -169,11 +173,12 @@ rnd.m_Objects.emplace_back(pObjNode); } if (!rnd.m_Objects.empty()) - FilterCondition(wsCondition, &rnd); + FilterCondition(pIsolate, wsCondition, &rnd); return !rnd.m_Objects.empty(); } -bool CFXJSE_ResolveProcessor::ResolveExcalmatory(CFXJSE_ResolveNodeData& rnd) { +bool CFXJSE_ResolveProcessor::ResolveExcalmatory(v8::Isolate* pIsolate, + CFXJSE_ResolveNodeData& rnd) { if (rnd.m_nLevel > 0) return false; @@ -190,14 +195,15 @@ rndFind.m_nLevel = rnd.m_nLevel + 1; rndFind.m_dwStyles = XFA_RESOLVENODE_Children; rndFind.m_wsCondition = rnd.m_wsCondition; - Resolve(rndFind); + Resolve(pIsolate, rndFind); rnd.m_Objects.insert(rnd.m_Objects.end(), rndFind.m_Objects.begin(), rndFind.m_Objects.end()); return !rnd.m_Objects.empty(); } -bool CFXJSE_ResolveProcessor::ResolveNumberSign(CFXJSE_ResolveNodeData& rnd) { +bool CFXJSE_ResolveProcessor::ResolveNumberSign(v8::Isolate* pIsolate, + CFXJSE_ResolveNodeData& rnd) { WideString wsName = rnd.m_wsName.Last(rnd.m_wsName.GetLength() - 1); WideString wsCondition = rnd.m_wsCondition; CXFA_Node* curNode = ToNode(rnd.m_CurObject.Get()); @@ -214,7 +220,7 @@ FX_HashCode_GetW(rndFind.m_wsName.AsStringView(), false)); rndFind.m_wsCondition = wsCondition; rndFind.m_CurObject = curNode; - ResolveNormal(rndFind); + ResolveNormal(pIsolate, rndFind); if (rndFind.m_Objects.empty()) return false; @@ -241,7 +247,8 @@ return true; } -bool CFXJSE_ResolveProcessor::ResolveNormal(CFXJSE_ResolveNodeData& rnd) { +bool CFXJSE_ResolveProcessor::ResolveNormal(v8::Isolate* pIsolate, + CFXJSE_ResolveNodeData& rnd) { if (rnd.m_nLevel > 32 || !rnd.m_CurObject->IsNode()) return false; @@ -284,14 +291,14 @@ rndFind.m_CurObject = pVariablesNode; SetStylesForChild(dwStyles, rndFind); WideString wsSaveCondition = std::move(rndFind.m_wsCondition); - ResolveNormal(rndFind); + ResolveNormal(pIsolate, rndFind); rndFind.m_wsCondition = std::move(wsSaveCondition); rnd.m_Objects.insert(rnd.m_Objects.end(), rndFind.m_Objects.begin(), rndFind.m_Objects.end()); rndFind.m_Objects.clear(); } if (rnd.m_Objects.size() > nNum) { - FilterCondition(wsCondition, &rnd); + FilterCondition(pIsolate, wsCondition, &rnd); return !rnd.m_Objects.empty(); } } @@ -318,7 +325,7 @@ rndFind.m_CurObject = child; WideString wsSaveCondition = std::move(rndFind.m_wsCondition); - ResolveNormal(rndFind); + ResolveNormal(pIsolate, rndFind); rndFind.m_wsCondition = std::move(wsSaveCondition); rnd.m_Objects.insert(rnd.m_Objects.end(), rndFind.m_Objects.begin(), rndFind.m_Objects.end()); @@ -342,7 +349,7 @@ rnd.m_Objects.front() = pSaveObject; } } - FilterCondition(wsCondition, &rnd); + FilterCondition(pIsolate, wsCondition, &rnd); return !rnd.m_Objects.empty(); } } @@ -364,7 +371,7 @@ } } if (rnd.m_Objects.size() > nNum) { - FilterCondition(wsCondition, &rnd); + FilterCondition(pIsolate, wsCondition, &rnd); return !rnd.m_Objects.empty(); } @@ -395,7 +402,7 @@ if (!parentNode) { if (uCurClassHash == uNameHash) { rnd.m_Objects.emplace_back(curNode); - FilterCondition(wsCondition, &rnd); + FilterCondition(pIsolate, wsCondition, &rnd); if (!rnd.m_Objects.empty()) return true; } @@ -452,7 +459,7 @@ WideString wsOriginCondition = std::move(rndFind.m_wsCondition); uint32_t dwOriginStyle = rndFind.m_dwStyles; rndFind.m_dwStyles = dwOriginStyle | XFA_RESOLVENODE_ALL; - ResolveNormal(rndFind); + ResolveNormal(pIsolate, rndFind); rndFind.m_dwStyles = dwOriginStyle; rndFind.m_wsCondition = std::move(wsOriginCondition); rnd.m_Objects.insert(rnd.m_Objects.end(), rndFind.m_Objects.begin(), @@ -476,7 +483,7 @@ rnd.m_Objects.front() = pSaveObject; } } - FilterCondition(wsCondition, &rnd); + FilterCondition(pIsolate, wsCondition, &rnd); return !rnd.m_Objects.empty(); } } @@ -492,7 +499,7 @@ rndFind.m_dwStyles = dwSubStyles; rndFind.m_CurObject = parentNode; rnd.m_pSC->GetUpObjectArray()->push_back(parentNode); - ResolveNormal(rndFind); + ResolveNormal(pIsolate, rndFind); rnd.m_Objects.insert(rnd.m_Objects.end(), rndFind.m_Objects.begin(), rndFind.m_Objects.end()); rndFind.m_Objects.clear(); @@ -646,7 +653,8 @@ } } -void CFXJSE_ResolveProcessor::FilterCondition(WideString wsCondition, +void CFXJSE_ResolveProcessor::FilterCondition(v8::Isolate* pIsolate, + WideString wsCondition, CFXJSE_ResolveNodeData* pRnd) { size_t iCurIndex = 0; const auto* pArray = pRnd->m_pSC->GetUpObjectArray(); @@ -690,7 +698,7 @@ return; case '.': if (iLen > 1 && (wsCondition[1] == '[' || wsCondition[1] == '(')) - DoPredicateFilter(wsCondition, iFoundCount, pRnd); + DoPredicateFilter(pIsolate, wsCondition, iFoundCount, pRnd); return; case '(': case '"':
diff --git a/fxjs/xfa/cfxjse_resolveprocessor.h b/fxjs/xfa/cfxjse_resolveprocessor.h index ebde16e..139b79a 100644 --- a/fxjs/xfa/cfxjse_resolveprocessor.h +++ b/fxjs/xfa/cfxjse_resolveprocessor.h
@@ -44,7 +44,7 @@ CFXJSE_ResolveProcessor(); ~CFXJSE_ResolveProcessor(); - bool Resolve(CFXJSE_ResolveNodeData& rnd); + bool Resolve(v8::Isolate* pIsolate, CFXJSE_ResolveNodeData& rnd); int32_t GetFilter(WideStringView wsExpression, int32_t nStart, CFXJSE_ResolveNodeData& rnd); @@ -59,19 +59,21 @@ bool ResolveForAttributeRs(CXFA_Object* curNode, CFXJSE_ResolveNodeData& rnd, WideStringView strAttr); - bool ResolveAnyChild(CFXJSE_ResolveNodeData& rnd); - bool ResolveDollar(CFXJSE_ResolveNodeData& rnd); - bool ResolveExcalmatory(CFXJSE_ResolveNodeData& rnd); - bool ResolveNumberSign(CFXJSE_ResolveNodeData& rnd); + bool ResolveAnyChild(v8::Isolate* pIsolate, CFXJSE_ResolveNodeData& rnd); + bool ResolveDollar(v8::Isolate* pIsolate, CFXJSE_ResolveNodeData& rnd); + bool ResolveExcalmatory(v8::Isolate* pIsolate, CFXJSE_ResolveNodeData& rnd); + bool ResolveNumberSign(v8::Isolate* pIsolate, CFXJSE_ResolveNodeData& rnd); bool ResolveAsterisk(CFXJSE_ResolveNodeData& rnd); - bool ResolveNormal(CFXJSE_ResolveNodeData& rnd); + bool ResolveNormal(v8::Isolate* pIsolate, CFXJSE_ResolveNodeData& rnd); void SetStylesForChild(uint32_t dwParentStyles, CFXJSE_ResolveNodeData& rnd); void ConditionArray(size_t iCurIndex, WideString wsCondition, size_t iFoundCount, CFXJSE_ResolveNodeData* pRnd); - void FilterCondition(WideString wsCondition, CFXJSE_ResolveNodeData* pRnd); + void FilterCondition(v8::Isolate* pIsolate, + WideString wsCondition, + CFXJSE_ResolveNodeData* pRnd); int32_t m_iCurStart = 0; std::unique_ptr<CFXJSE_NodeHelper> const m_pNodeHelper;
diff --git a/fxjs/xfa/cfxjse_value.cpp b/fxjs/xfa/cfxjse_value.cpp index c034808..993f964 100644 --- a/fxjs/xfa/cfxjse_value.cpp +++ b/fxjs/xfa/cfxjse_value.cpp
@@ -65,167 +65,170 @@ pIsolate->ThrowException(hError); } -CFXJSE_Value::CFXJSE_Value(v8::Isolate* pIsolate) : m_pIsolate(pIsolate) {} +CFXJSE_Value::CFXJSE_Value(v8::Isolate* pIsolate) {} -CFXJSE_Value::CFXJSE_Value(v8::Isolate* pIsolate, v8::Local<v8::Value> value) - : m_pIsolate(pIsolate) { - ForceSetValue(value); +CFXJSE_Value::CFXJSE_Value(v8::Isolate* pIsolate, v8::Local<v8::Value> value) { + ForceSetValue(pIsolate, value); } CFXJSE_Value::~CFXJSE_Value() = default; -CFXJSE_HostObject* CFXJSE_Value::ToHostObject() const { - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(GetIsolate()); +CFXJSE_HostObject* CFXJSE_Value::ToHostObject(v8::Isolate* pIsolate) const { + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); return CFXJSE_HostObject::FromV8( - v8::Local<v8::Value>::New(GetIsolate(), m_hValue)); + v8::Local<v8::Value>::New(pIsolate, m_hValue)); } -void CFXJSE_Value::SetHostObject(CFXJSE_HostObject* pObject, +void CFXJSE_Value::SetHostObject(v8::Isolate* pIsolate, + CFXJSE_HostObject* pObject, CFXJSE_Class* pClass) { - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(GetIsolate()); - m_hValue.Reset(GetIsolate(), - pObject->NewBoundV8Object(GetIsolate(), - pClass->GetTemplate(GetIsolate()))); + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); + m_hValue.Reset(pIsolate, pObject->NewBoundV8Object( + pIsolate, pClass->GetTemplate(pIsolate))); } -void CFXJSE_Value::ClearHostObject() { - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(GetIsolate()); - FXJSE_ClearObjectBinding(m_hValue.Get(GetIsolate()).As<v8::Object>()); - v8::Local<v8::Value> hValue = v8::Null(GetIsolate()); - m_hValue.Reset(GetIsolate(), hValue); +void CFXJSE_Value::ClearHostObject(v8::Isolate* pIsolate) { + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); + FXJSE_ClearObjectBinding(m_hValue.Get(pIsolate).As<v8::Object>()); + v8::Local<v8::Value> hValue = v8::Null(pIsolate); + m_hValue.Reset(pIsolate, hValue); } void CFXJSE_Value::SetArray( + v8::Isolate* pIsolate, const std::vector<std::unique_ptr<CFXJSE_Value>>& values) { - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(GetIsolate()); - v8::Local<v8::Array> hArrayObject = - v8::Array::New(GetIsolate(), values.size()); + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); + v8::Local<v8::Array> hArrayObject = v8::Array::New(pIsolate, values.size()); uint32_t count = 0; for (auto& v : values) { if (v->IsEmpty()) - v->SetUndefined(); - fxv8::ReentrantPutArrayElementHelper(GetIsolate(), hArrayObject, count++, - v->GetValue()); + v->SetUndefined(pIsolate); + fxv8::ReentrantPutArrayElementHelper(pIsolate, hArrayObject, count++, + v->GetValue(pIsolate)); } - m_hValue.Reset(GetIsolate(), hArrayObject); + m_hValue.Reset(pIsolate, hArrayObject); } -void CFXJSE_Value::SetFloat(float fFloat) { - CFXJSE_ScopeUtil_IsolateHandle scope(GetIsolate()); - m_hValue.Reset(GetIsolate(), - fxv8::NewNumberHelper(GetIsolate(), ftod(fFloat))); +void CFXJSE_Value::SetFloat(v8::Isolate* pIsolate, float fFloat) { + CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); + m_hValue.Reset(pIsolate, fxv8::NewNumberHelper(pIsolate, ftod(fFloat))); } -bool CFXJSE_Value::SetObjectProperty(ByteStringView szPropName, +bool CFXJSE_Value::SetObjectProperty(v8::Isolate* pIsolate, + ByteStringView szPropName, CFXJSE_Value* lpPropValue) { if (lpPropValue->IsEmpty()) return false; - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(GetIsolate()); - v8::Local<v8::Value> hObject = GetValue(); + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); + v8::Local<v8::Value> hObject = GetValue(pIsolate); if (!hObject->IsObject()) return false; return fxv8::ReentrantPutObjectPropertyHelper( - GetIsolate(), hObject.As<v8::Object>(), szPropName, - lpPropValue->GetValue()); + pIsolate, hObject.As<v8::Object>(), szPropName, + lpPropValue->GetValue(pIsolate)); } -bool CFXJSE_Value::GetObjectProperty(ByteStringView szPropName, +bool CFXJSE_Value::GetObjectProperty(v8::Isolate* pIsolate, + ByteStringView szPropName, CFXJSE_Value* lpPropValue) { - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(GetIsolate()); - v8::Local<v8::Value> hObject = GetValue(); + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); + v8::Local<v8::Value> hObject = GetValue(pIsolate); if (!hObject->IsObject()) return false; - lpPropValue->ForceSetValue(fxv8::ReentrantGetObjectPropertyHelper( - GetIsolate(), hObject.As<v8::Object>(), szPropName)); + lpPropValue->ForceSetValue( + pIsolate, fxv8::ReentrantGetObjectPropertyHelper( + pIsolate, hObject.As<v8::Object>(), szPropName)); return true; } -bool CFXJSE_Value::GetObjectPropertyByIdx(uint32_t uPropIdx, +bool CFXJSE_Value::GetObjectPropertyByIdx(v8::Isolate* pIsolate, + uint32_t uPropIdx, CFXJSE_Value* lpPropValue) { - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(GetIsolate()); - v8::Local<v8::Value> hObject = GetValue(); + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); + v8::Local<v8::Value> hObject = GetValue(pIsolate); if (!hObject->IsArray()) return false; - lpPropValue->ForceSetValue(fxv8::ReentrantGetArrayElementHelper( - GetIsolate(), hObject.As<v8::Array>(), uPropIdx)); + lpPropValue->ForceSetValue(pIsolate, + fxv8::ReentrantGetArrayElementHelper( + pIsolate, hObject.As<v8::Array>(), uPropIdx)); return true; } -bool CFXJSE_Value::DeleteObjectProperty(ByteStringView szPropName) { - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(GetIsolate()); - v8::Local<v8::Value> hObject = - v8::Local<v8::Value>::New(GetIsolate(), m_hValue); +bool CFXJSE_Value::DeleteObjectProperty(v8::Isolate* pIsolate, + ByteStringView szPropName) { + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); + v8::Local<v8::Value> hObject = v8::Local<v8::Value>::New(pIsolate, m_hValue); return hObject->IsObject() && hObject.As<v8::Object>() - ->Delete(GetIsolate()->GetCurrentContext(), - fxv8::NewStringHelper(GetIsolate(), szPropName)) + ->Delete(pIsolate->GetCurrentContext(), + fxv8::NewStringHelper(pIsolate, szPropName)) .FromJust(); } -bool CFXJSE_Value::HasObjectOwnProperty(ByteStringView szPropName, +bool CFXJSE_Value::HasObjectOwnProperty(v8::Isolate* pIsolate, + ByteStringView szPropName, bool bUseTypeGetter) { - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(GetIsolate()); - v8::Local<v8::Value> hObject = - v8::Local<v8::Value>::New(GetIsolate(), m_hValue); + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); + v8::Local<v8::Value> hObject = v8::Local<v8::Value>::New(pIsolate, m_hValue); if (!hObject->IsObject()) return false; - v8::Local<v8::String> hKey = fxv8::NewStringHelper(GetIsolate(), szPropName); + v8::Local<v8::String> hKey = fxv8::NewStringHelper(pIsolate, szPropName); return hObject.As<v8::Object>() - ->HasRealNamedProperty(GetIsolate()->GetCurrentContext(), hKey) + ->HasRealNamedProperty(pIsolate->GetCurrentContext(), hKey) .FromJust() || (bUseTypeGetter && hObject.As<v8::Object>() - ->HasOwnProperty(GetIsolate()->GetCurrentContext(), hKey) + ->HasOwnProperty(pIsolate->GetCurrentContext(), hKey) .FromMaybe(false)); } -bool CFXJSE_Value::SetObjectOwnProperty(ByteStringView szPropName, +bool CFXJSE_Value::SetObjectOwnProperty(v8::Isolate* pIsolate, + ByteStringView szPropName, CFXJSE_Value* lpPropValue) { ASSERT(lpPropValue); - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(GetIsolate()); - v8::Local<v8::Value> hObject = - v8::Local<v8::Value>::New(GetIsolate(), m_hValue); + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); + v8::Local<v8::Value> hObject = v8::Local<v8::Value>::New(pIsolate, m_hValue); if (!hObject->IsObject()) return false; - v8::Local<v8::String> hPropName = - fxv8::NewStringHelper(GetIsolate(), szPropName); + v8::Local<v8::String> hPropName = fxv8::NewStringHelper(pIsolate, szPropName); v8::Local<v8::Value> pValue = - v8::Local<v8::Value>::New(GetIsolate(), lpPropValue->m_hValue); + v8::Local<v8::Value>::New(pIsolate, lpPropValue->m_hValue); return hObject.As<v8::Object>() - ->DefineOwnProperty(GetIsolate()->GetCurrentContext(), hPropName, pValue) + ->DefineOwnProperty(pIsolate->GetCurrentContext(), hPropName, pValue) .FromMaybe(false); } -bool CFXJSE_Value::SetFunctionBind(CFXJSE_Value* lpOldFunction, +bool CFXJSE_Value::SetFunctionBind(v8::Isolate* pIsolate, + CFXJSE_Value* lpOldFunction, CFXJSE_Value* lpNewThis) { ASSERT(lpOldFunction); ASSERT(lpNewThis); - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(GetIsolate()); + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); v8::Local<v8::Value> rgArgs[2]; v8::Local<v8::Value> hOldFunction = - v8::Local<v8::Value>::New(GetIsolate(), lpOldFunction->DirectGetValue()); + v8::Local<v8::Value>::New(pIsolate, lpOldFunction->DirectGetValue()); if (!fxv8::IsFunction(hOldFunction)) return false; rgArgs[0] = hOldFunction; v8::Local<v8::Value> hNewThis = - v8::Local<v8::Value>::New(GetIsolate(), lpNewThis->DirectGetValue()); + v8::Local<v8::Value>::New(pIsolate, lpNewThis->DirectGetValue()); if (hNewThis.IsEmpty()) return false; rgArgs[1] = hNewThis; v8::Local<v8::String> hBinderFuncSource = - fxv8::NewStringHelper(GetIsolate(), + fxv8::NewStringHelper(pIsolate, "(function (oldfunction, newthis) { return " "oldfunction.bind(newthis); })"); - v8::Local<v8::Context> hContext = GetIsolate()->GetCurrentContext(); + v8::Local<v8::Context> hContext = pIsolate->GetCurrentContext(); v8::Local<v8::Function> hBinderFunc = v8::Script::Compile(hContext, hBinderFuncSource) .ToLocalChecked() @@ -238,166 +241,157 @@ if (!fxv8::IsFunction(hBoundFunction)) return false; - m_hValue.Reset(GetIsolate(), hBoundFunction); + m_hValue.Reset(pIsolate, hBoundFunction); return true; } -v8::Local<v8::Value> CFXJSE_Value::GetValue() const { - return v8::Local<v8::Value>::New(GetIsolate(), m_hValue); +v8::Local<v8::Value> CFXJSE_Value::GetValue(v8::Isolate* pIsolate) const { + return v8::Local<v8::Value>::New(pIsolate, m_hValue); } bool CFXJSE_Value::IsEmpty() const { return m_hValue.IsEmpty(); } -bool CFXJSE_Value::IsUndefined() const { +bool CFXJSE_Value::IsUndefined(v8::Isolate* pIsolate) const { if (IsEmpty()) return false; - CFXJSE_ScopeUtil_IsolateHandle scope(GetIsolate()); - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(GetIsolate(), m_hValue); + CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); + v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(pIsolate, m_hValue); return hValue->IsUndefined(); } -bool CFXJSE_Value::IsNull() const { +bool CFXJSE_Value::IsNull(v8::Isolate* pIsolate) const { if (IsEmpty()) return false; - CFXJSE_ScopeUtil_IsolateHandle scope(GetIsolate()); - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(GetIsolate(), m_hValue); + CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); + v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(pIsolate, m_hValue); return hValue->IsNull(); } -bool CFXJSE_Value::IsBoolean() const { +bool CFXJSE_Value::IsBoolean(v8::Isolate* pIsolate) const { if (IsEmpty()) return false; - CFXJSE_ScopeUtil_IsolateHandle scope(GetIsolate()); - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(GetIsolate(), m_hValue); + CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); + v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(pIsolate, m_hValue); return hValue->IsBoolean(); } -bool CFXJSE_Value::IsString() const { +bool CFXJSE_Value::IsString(v8::Isolate* pIsolate) const { if (IsEmpty()) return false; - CFXJSE_ScopeUtil_IsolateHandle scope(GetIsolate()); - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(GetIsolate(), m_hValue); + CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); + v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(pIsolate, m_hValue); return hValue->IsString(); } -bool CFXJSE_Value::IsNumber() const { +bool CFXJSE_Value::IsNumber(v8::Isolate* pIsolate) const { if (IsEmpty()) return false; - CFXJSE_ScopeUtil_IsolateHandle scope(GetIsolate()); - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(GetIsolate(), m_hValue); + CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); + v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(pIsolate, m_hValue); return hValue->IsNumber(); } -bool CFXJSE_Value::IsInteger() const { +bool CFXJSE_Value::IsInteger(v8::Isolate* pIsolate) const { if (IsEmpty()) return false; - CFXJSE_ScopeUtil_IsolateHandle scope(GetIsolate()); - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(GetIsolate(), m_hValue); + CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); + v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(pIsolate, m_hValue); return hValue->IsInt32(); } -bool CFXJSE_Value::IsObject() const { +bool CFXJSE_Value::IsObject(v8::Isolate* pIsolate) const { if (IsEmpty()) return false; - CFXJSE_ScopeUtil_IsolateHandle scope(GetIsolate()); - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(GetIsolate(), m_hValue); + CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); + v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(pIsolate, m_hValue); return hValue->IsObject(); } -bool CFXJSE_Value::IsArray() const { +bool CFXJSE_Value::IsArray(v8::Isolate* pIsolate) const { if (IsEmpty()) return false; - CFXJSE_ScopeUtil_IsolateHandle scope(GetIsolate()); - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(GetIsolate(), m_hValue); + CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); + v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(pIsolate, m_hValue); return hValue->IsArray(); } -bool CFXJSE_Value::IsFunction() const { +bool CFXJSE_Value::IsFunction(v8::Isolate* pIsolate) const { if (IsEmpty()) return false; - CFXJSE_ScopeUtil_IsolateHandle scope(GetIsolate()); - v8::Local<v8::Value> hValue = - v8::Local<v8::Value>::New(GetIsolate(), m_hValue); + CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); + v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(pIsolate, m_hValue); return hValue->IsFunction(); } -bool CFXJSE_Value::ToBoolean() const { +bool CFXJSE_Value::ToBoolean(v8::Isolate* pIsolate) const { ASSERT(!IsEmpty()); - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(GetIsolate()); + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); return fxv8::ReentrantToBooleanHelper( - GetIsolate(), v8::Local<v8::Value>::New(GetIsolate(), m_hValue)); + pIsolate, v8::Local<v8::Value>::New(pIsolate, m_hValue)); } -float CFXJSE_Value::ToFloat() const { - return static_cast<float>(ToDouble()); +float CFXJSE_Value::ToFloat(v8::Isolate* pIsolate) const { + return static_cast<float>(ToDouble(pIsolate)); } -double CFXJSE_Value::ToDouble() const { +double CFXJSE_Value::ToDouble(v8::Isolate* pIsolate) const { ASSERT(!IsEmpty()); - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(GetIsolate()); + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); return fxv8::ReentrantToDoubleHelper( - GetIsolate(), v8::Local<v8::Value>::New(GetIsolate(), m_hValue)); + pIsolate, v8::Local<v8::Value>::New(pIsolate, m_hValue)); } -int32_t CFXJSE_Value::ToInteger() const { +int32_t CFXJSE_Value::ToInteger(v8::Isolate* pIsolate) const { ASSERT(!IsEmpty()); - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(GetIsolate()); + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); return fxv8::ReentrantToInt32Helper( - GetIsolate(), v8::Local<v8::Value>::New(GetIsolate(), m_hValue)); + pIsolate, v8::Local<v8::Value>::New(pIsolate, m_hValue)); } -ByteString CFXJSE_Value::ToString() const { +ByteString CFXJSE_Value::ToString(v8::Isolate* pIsolate) const { ASSERT(!IsEmpty()); - CFXJSE_ScopeUtil_IsolateHandleRootContext scope(GetIsolate()); + CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); return fxv8::ReentrantToByteStringHelper( - GetIsolate(), v8::Local<v8::Value>::New(GetIsolate(), m_hValue)); + pIsolate, v8::Local<v8::Value>::New(pIsolate, m_hValue)); } -void CFXJSE_Value::SetUndefined() { - CFXJSE_ScopeUtil_IsolateHandle scope(GetIsolate()); - m_hValue.Reset(GetIsolate(), fxv8::NewUndefinedHelper(GetIsolate())); +void CFXJSE_Value::SetUndefined(v8::Isolate* pIsolate) { + CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); + m_hValue.Reset(pIsolate, fxv8::NewUndefinedHelper(pIsolate)); } -void CFXJSE_Value::SetNull() { - CFXJSE_ScopeUtil_IsolateHandle scope(GetIsolate()); - m_hValue.Reset(GetIsolate(), fxv8::NewNullHelper(GetIsolate())); +void CFXJSE_Value::SetNull(v8::Isolate* pIsolate) { + CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); + m_hValue.Reset(pIsolate, fxv8::NewNullHelper(pIsolate)); } -void CFXJSE_Value::SetBoolean(bool bBoolean) { - CFXJSE_ScopeUtil_IsolateHandle scope(GetIsolate()); - m_hValue.Reset(GetIsolate(), fxv8::NewBooleanHelper(GetIsolate(), bBoolean)); +void CFXJSE_Value::SetBoolean(v8::Isolate* pIsolate, bool bBoolean) { + CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); + m_hValue.Reset(pIsolate, fxv8::NewBooleanHelper(pIsolate, bBoolean)); } -void CFXJSE_Value::SetInteger(int32_t nInteger) { - CFXJSE_ScopeUtil_IsolateHandle scope(GetIsolate()); - m_hValue.Reset(GetIsolate(), fxv8::NewNumberHelper(GetIsolate(), nInteger)); +void CFXJSE_Value::SetInteger(v8::Isolate* pIsolate, int32_t nInteger) { + CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); + m_hValue.Reset(pIsolate, fxv8::NewNumberHelper(pIsolate, nInteger)); } -void CFXJSE_Value::SetDouble(double dDouble) { - CFXJSE_ScopeUtil_IsolateHandle scope(GetIsolate()); - m_hValue.Reset(GetIsolate(), fxv8::NewNumberHelper(GetIsolate(), dDouble)); +void CFXJSE_Value::SetDouble(v8::Isolate* pIsolate, double dDouble) { + CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); + m_hValue.Reset(pIsolate, fxv8::NewNumberHelper(pIsolate, dDouble)); } -void CFXJSE_Value::SetString(ByteStringView szString) { - CFXJSE_ScopeUtil_IsolateHandle scope(GetIsolate()); - m_hValue.Reset(GetIsolate(), fxv8::NewStringHelper(GetIsolate(), szString)); +void CFXJSE_Value::SetString(v8::Isolate* pIsolate, ByteStringView szString) { + CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); + m_hValue.Reset(pIsolate, fxv8::NewStringHelper(pIsolate, szString)); }
diff --git a/fxjs/xfa/cfxjse_value.h b/fxjs/xfa/cfxjse_value.h index a588633..9d07ad0 100644 --- a/fxjs/xfa/cfxjse_value.h +++ b/fxjs/xfa/cfxjse_value.h
@@ -25,56 +25,70 @@ ~CFXJSE_Value(); bool IsEmpty() const; - bool IsUndefined() const; - bool IsNull() const; - bool IsBoolean() const; - bool IsString() const; - bool IsNumber() const; - bool IsInteger() const; - bool IsObject() const; - bool IsArray() const; - bool IsFunction() const; - bool ToBoolean() const; - float ToFloat() const; - double ToDouble() const; - int32_t ToInteger() const; - ByteString ToString() const; - WideString ToWideString() const { - return WideString::FromUTF8(ToString().AsStringView()); + bool IsUndefined(v8::Isolate* pIsolate) const; + bool IsNull(v8::Isolate* pIsolate) const; + bool IsBoolean(v8::Isolate* pIsolate) const; + bool IsString(v8::Isolate* pIsolate) const; + bool IsNumber(v8::Isolate* pIsolate) const; + bool IsInteger(v8::Isolate* pIsolate) const; + bool IsObject(v8::Isolate* pIsolate) const; + bool IsArray(v8::Isolate* pIsolate) const; + bool IsFunction(v8::Isolate* pIsolate) const; + bool ToBoolean(v8::Isolate* pIsolate) const; + float ToFloat(v8::Isolate* pIsolate) const; + double ToDouble(v8::Isolate* pIsolate) const; + int32_t ToInteger(v8::Isolate* pIsolate) const; + ByteString ToString(v8::Isolate* pIsolate) const; + WideString ToWideString(v8::Isolate* pIsolate) const { + return WideString::FromUTF8(ToString(pIsolate).AsStringView()); } - CFXJSE_HostObject* ToHostObject() const; + CFXJSE_HostObject* ToHostObject(v8::Isolate* pIsolate) const; - void SetUndefined(); - void SetNull(); - void SetBoolean(bool bBoolean); - void SetInteger(int32_t nInteger); - void SetDouble(double dDouble); - void SetString(ByteStringView szString); - void SetFloat(float fFloat); + void SetUndefined(v8::Isolate* pIsolate); + void SetNull(v8::Isolate* pIsolate); + void SetBoolean(v8::Isolate* pIsolate, bool bBoolean); + void SetInteger(v8::Isolate* pIsolate, int32_t nInteger); + void SetDouble(v8::Isolate* pIsolate, double dDouble); + void SetString(v8::Isolate* pIsolate, ByteStringView szString); + void SetFloat(v8::Isolate* pIsolate, float fFloat); - void SetHostObject(CFXJSE_HostObject* pObject, CFXJSE_Class* pClass); - void ClearHostObject(); + void SetHostObject(v8::Isolate* pIsolate, + CFXJSE_HostObject* lpObject, + CFXJSE_Class* pClass); + void ClearHostObject(v8::Isolate* pIsolate); - void SetArray(const std::vector<std::unique_ptr<CFXJSE_Value>>& values); + void SetArray(v8::Isolate* pIsolate, + const std::vector<std::unique_ptr<CFXJSE_Value>>& values); - bool GetObjectProperty(ByteStringView szPropName, CFXJSE_Value* lpPropValue); - bool SetObjectProperty(ByteStringView szPropName, CFXJSE_Value* lpPropValue); - bool GetObjectPropertyByIdx(uint32_t uPropIdx, CFXJSE_Value* lpPropValue); - bool DeleteObjectProperty(ByteStringView szPropName); - bool HasObjectOwnProperty(ByteStringView szPropName, bool bUseTypeGetter); - bool SetObjectOwnProperty(ByteStringView szPropName, + bool GetObjectProperty(v8::Isolate* pIsolate, + ByteStringView szPropName, + CFXJSE_Value* lpPropValue); + bool SetObjectProperty(v8::Isolate* pIsolate, + ByteStringView szPropName, + CFXJSE_Value* lpPropValue); + bool GetObjectPropertyByIdx(v8::Isolate* pIsolate, + uint32_t uPropIdx, + CFXJSE_Value* lpPropValue); + bool DeleteObjectProperty(v8::Isolate* pIsolate, ByteStringView szPropName); + bool HasObjectOwnProperty(v8::Isolate* pIsolate, + ByteStringView szPropName, + bool bUseTypeGetter); + bool SetObjectOwnProperty(v8::Isolate* pIsolate, + ByteStringView szPropName, CFXJSE_Value* lpPropValue); - bool SetFunctionBind(CFXJSE_Value* lpOldFunction, CFXJSE_Value* lpNewThis); + bool SetFunctionBind(v8::Isolate* pIsolate, + CFXJSE_Value* lpOldFunction, + CFXJSE_Value* lpNewThis); - v8::Local<v8::Value> GetValue() const; + v8::Local<v8::Value> GetValue(v8::Isolate* pIsolate) const; const v8::Global<v8::Value>& DirectGetValue() const { return m_hValue; } - void ForceSetValue(v8::Local<v8::Value> hValue) { - m_hValue.Reset(GetIsolate(), hValue); + void ForceSetValue(v8::Isolate* pIsolate, v8::Local<v8::Value> hValue) { + m_hValue.Reset(pIsolate, hValue); } - void Assign(const CFXJSE_Value* lpValue) { + void Assign(v8::Isolate* pIsolate, const CFXJSE_Value* lpValue) { ASSERT(lpValue); if (lpValue) { - m_hValue.Reset(GetIsolate(), lpValue->m_hValue); + m_hValue.Reset(pIsolate, lpValue->m_hValue); } else { m_hValue.Reset(); } @@ -85,9 +99,6 @@ CFXJSE_Value(const CFXJSE_Value&) = delete; CFXJSE_Value& operator=(const CFXJSE_Value&) = delete; - v8::Isolate* GetIsolate() const { return m_pIsolate.Get(); } - - UnownedPtr<v8::Isolate> const m_pIsolate; v8::Global<v8::Value> m_hValue; };
diff --git a/fxjs/xfa/cfxjse_value_embeddertest.cpp b/fxjs/xfa/cfxjse_value_embeddertest.cpp index 4223e5d..42617d5 100644 --- a/fxjs/xfa/cfxjse_value_embeddertest.cpp +++ b/fxjs/xfa/cfxjse_value_embeddertest.cpp
@@ -19,14 +19,14 @@ auto pValue = std::make_unique<CFXJSE_Value>(isolate()); EXPECT_TRUE(pValue->IsEmpty()); - EXPECT_FALSE(pValue->IsUndefined()); - EXPECT_FALSE(pValue->IsNull()); - EXPECT_FALSE(pValue->IsBoolean()); - EXPECT_FALSE(pValue->IsString()); - EXPECT_FALSE(pValue->IsNumber()); - EXPECT_FALSE(pValue->IsObject()); - EXPECT_FALSE(pValue->IsArray()); - EXPECT_FALSE(pValue->IsFunction()); + EXPECT_FALSE(pValue->IsUndefined(isolate())); + EXPECT_FALSE(pValue->IsNull(isolate())); + EXPECT_FALSE(pValue->IsBoolean(isolate())); + EXPECT_FALSE(pValue->IsString(isolate())); + EXPECT_FALSE(pValue->IsNumber(isolate())); + EXPECT_FALSE(pValue->IsObject(isolate())); + EXPECT_FALSE(pValue->IsArray(isolate())); + EXPECT_FALSE(pValue->IsFunction(isolate())); } TEST_F(CFXJSE_ValueEmbedderTest, EmptyArrayInsert) { @@ -38,6 +38,6 @@ vec.push_back(std::move(pValue)); CFXJSE_Value array(isolate()); - array.SetArray(vec); - EXPECT_TRUE(array.IsArray()); + array.SetArray(isolate(), vec); + EXPECT_TRUE(array.IsArray(isolate())); }
diff --git a/fxjs/xfa/cjx_boolean.cpp b/fxjs/xfa/cjx_boolean.cpp index 5c3f183..75797d8 100644 --- a/fxjs/xfa/cjx_boolean.cpp +++ b/fxjs/xfa/cjx_boolean.cpp
@@ -17,17 +17,18 @@ return eType == static_type__ || ParentType__::DynamicTypeIs(eType); } -void CJX_Boolean::defaultValue(CFXJSE_Value* pValue, +void CJX_Boolean::defaultValue(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (!bSetting) { - pValue->SetBoolean(GetContent(true).EqualsASCII("1")); + pValue->SetBoolean(pIsolate, GetContent(true).EqualsASCII("1")); return; } ByteString newValue; - if (pValue && !(pValue->IsNull() || pValue->IsUndefined())) - newValue = pValue->ToString(); + if (pValue && !(pValue->IsNull(pIsolate) || pValue->IsUndefined(pIsolate))) + newValue = pValue->ToString(pIsolate); int32_t iValue = FXSYS_atoi(newValue.c_str()); WideString wsNewValue(iValue == 0 ? L"0" : L"1"); @@ -39,8 +40,9 @@ SetContent(wsNewValue, wsFormatValue, true, true, true); } -void CJX_Boolean::value(CFXJSE_Value* pValue, +void CJX_Boolean::value(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - defaultValue(pValue, bSetting, eAttribute); + defaultValue(pIsolate, pValue, bSetting, eAttribute); }
diff --git a/fxjs/xfa/cjx_datawindow.cpp b/fxjs/xfa/cjx_datawindow.cpp index 9a189ec..7e9ab42 100644 --- a/fxjs/xfa/cjx_datawindow.cpp +++ b/fxjs/xfa/cjx_datawindow.cpp
@@ -52,18 +52,22 @@ return CJS_Result::Success(); } -void CJX_DataWindow::recordsBefore(CFXJSE_Value* pValue, +void CJX_DataWindow::recordsBefore(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) {} -void CJX_DataWindow::currentRecordNumber(CFXJSE_Value* pValue, +void CJX_DataWindow::currentRecordNumber(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) {} -void CJX_DataWindow::recordsAfter(CFXJSE_Value* pValue, +void CJX_DataWindow::recordsAfter(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) {} -void CJX_DataWindow::isDefined(CFXJSE_Value* pValue, +void CJX_DataWindow::isDefined(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) {}
diff --git a/fxjs/xfa/cjx_delta.cpp b/fxjs/xfa/cjx_delta.cpp index 9d17eaa..ede7e71 100644 --- a/fxjs/xfa/cjx_delta.cpp +++ b/fxjs/xfa/cjx_delta.cpp
@@ -32,14 +32,17 @@ return CJS_Result::Success(); } -void CJX_Delta::currentValue(CFXJSE_Value* pValue, +void CJX_Delta::currentValue(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) {} -void CJX_Delta::savedValue(CFXJSE_Value* pValue, +void CJX_Delta::savedValue(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) {} -void CJX_Delta::target(CFXJSE_Value* pValue, +void CJX_Delta::target(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) {}
diff --git a/fxjs/xfa/cjx_draw.cpp b/fxjs/xfa/cjx_draw.cpp index 4e8ddc1..5705ecc 100644 --- a/fxjs/xfa/cjx_draw.cpp +++ b/fxjs/xfa/cjx_draw.cpp
@@ -17,32 +17,33 @@ return eType == static_type__ || ParentType__::DynamicTypeIs(eType); } -void CJX_Draw::rawValue(CFXJSE_Value* pValue, +void CJX_Draw::rawValue(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - defaultValue(pValue, bSetting, eAttribute); + defaultValue(pIsolate, pValue, bSetting, eAttribute); } -void CJX_Draw::defaultValue(CFXJSE_Value* pValue, +void CJX_Draw::defaultValue(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (!bSetting) { WideString content = GetContent(true); if (content.IsEmpty()) - pValue->SetNull(); + pValue->SetNull(pIsolate); else - pValue->SetString(content.ToUTF8().AsStringView()); - + pValue->SetString(pIsolate, content.ToUTF8().AsStringView()); return; } - if (!pValue || !pValue->IsString()) + if (!pValue || !pValue->IsString(pIsolate)) return; ASSERT(GetXFANode()->IsWidgetReady()); if (GetXFANode()->GetFFWidgetType() != XFA_FFWidgetType::kText) return; - WideString wsNewValue = pValue->ToWideString(); + WideString wsNewValue = pValue->ToWideString(pIsolate); SetContent(wsNewValue, wsNewValue, true, true, true); }
diff --git a/fxjs/xfa/cjx_encrypt.cpp b/fxjs/xfa/cjx_encrypt.cpp index f50133d..8fa8f9f 100644 --- a/fxjs/xfa/cjx_encrypt.cpp +++ b/fxjs/xfa/cjx_encrypt.cpp
@@ -16,6 +16,7 @@ return eType == static_type__ || ParentType__::DynamicTypeIs(eType); } -void CJX_Encrypt::format(CFXJSE_Value* pValue, +void CJX_Encrypt::format(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) {}
diff --git a/fxjs/xfa/cjx_eventpseudomodel.cpp b/fxjs/xfa/cjx_eventpseudomodel.cpp index f7d757a..37b01a2 100644 --- a/fxjs/xfa/cjx_eventpseudomodel.cpp +++ b/fxjs/xfa/cjx_eventpseudomodel.cpp
@@ -19,28 +19,37 @@ namespace { -void StringProperty(CFXJSE_Value* pReturn, WideString* wsValue, bool bSetting) { +void StringProperty(v8::Isolate* pIsolate, + CFXJSE_Value* pReturn, + WideString* wsValue, + bool bSetting) { if (bSetting) { - *wsValue = pReturn->ToWideString(); + *wsValue = pReturn->ToWideString(pIsolate); return; } - pReturn->SetString(wsValue->ToUTF8().AsStringView()); + pReturn->SetString(pIsolate, wsValue->ToUTF8().AsStringView()); } -void IntegerProperty(CFXJSE_Value* pReturn, int32_t* iValue, bool bSetting) { +void IntegerProperty(v8::Isolate* pIsolate, + CFXJSE_Value* pReturn, + int32_t* iValue, + bool bSetting) { if (bSetting) { - *iValue = pReturn->ToInteger(); + *iValue = pReturn->ToInteger(pIsolate); return; } - pReturn->SetInteger(*iValue); + pReturn->SetInteger(pIsolate, *iValue); } -void BooleanProperty(CFXJSE_Value* pReturn, bool* bValue, bool bSetting) { +void BooleanProperty(v8::Isolate* pIsolate, + CFXJSE_Value* pReturn, + bool* bValue, + bool bSetting) { if (bSetting) { - *bValue = pReturn->ToBoolean(); + *bValue = pReturn->ToBoolean(pIsolate); return; } - pReturn->SetBoolean(*bValue); + pReturn->SetBoolean(pIsolate, *bValue); } } // namespace @@ -60,49 +69,57 @@ return eType == static_type__ || ParentType__::DynamicTypeIs(eType); } -void CJX_EventPseudoModel::cancelAction(CFXJSE_Value* pValue, +void CJX_EventPseudoModel::cancelAction(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::CancelAction, bSetting); + Property(pIsolate, pValue, XFA_Event::CancelAction, bSetting); } -void CJX_EventPseudoModel::change(CFXJSE_Value* pValue, +void CJX_EventPseudoModel::change(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::Change, bSetting); + Property(pIsolate, pValue, XFA_Event::Change, bSetting); } -void CJX_EventPseudoModel::commitKey(CFXJSE_Value* pValue, +void CJX_EventPseudoModel::commitKey(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::CommitKey, bSetting); + Property(pIsolate, pValue, XFA_Event::CommitKey, bSetting); } -void CJX_EventPseudoModel::fullText(CFXJSE_Value* pValue, +void CJX_EventPseudoModel::fullText(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::FullText, bSetting); + Property(pIsolate, pValue, XFA_Event::FullText, bSetting); } -void CJX_EventPseudoModel::keyDown(CFXJSE_Value* pValue, +void CJX_EventPseudoModel::keyDown(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::Keydown, bSetting); + Property(pIsolate, pValue, XFA_Event::Keydown, bSetting); } -void CJX_EventPseudoModel::modifier(CFXJSE_Value* pValue, +void CJX_EventPseudoModel::modifier(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::Modifier, bSetting); + Property(pIsolate, pValue, XFA_Event::Modifier, bSetting); } -void CJX_EventPseudoModel::newContentType(CFXJSE_Value* pValue, +void CJX_EventPseudoModel::newContentType(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::NewContentType, bSetting); + Property(pIsolate, pValue, XFA_Event::NewContentType, bSetting); } -void CJX_EventPseudoModel::newText(CFXJSE_Value* pValue, +void CJX_EventPseudoModel::newText(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) @@ -113,61 +130,71 @@ if (!pEventParam) return; - pValue->SetString(pEventParam->GetNewText().ToUTF8().AsStringView()); + pValue->SetString(pIsolate, + pEventParam->GetNewText().ToUTF8().AsStringView()); } -void CJX_EventPseudoModel::prevContentType(CFXJSE_Value* pValue, +void CJX_EventPseudoModel::prevContentType(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::PreviousContentType, bSetting); + Property(pIsolate, pValue, XFA_Event::PreviousContentType, bSetting); } -void CJX_EventPseudoModel::prevText(CFXJSE_Value* pValue, +void CJX_EventPseudoModel::prevText(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::PreviousText, bSetting); + Property(pIsolate, pValue, XFA_Event::PreviousText, bSetting); } -void CJX_EventPseudoModel::reenter(CFXJSE_Value* pValue, +void CJX_EventPseudoModel::reenter(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::Reenter, bSetting); + Property(pIsolate, pValue, XFA_Event::Reenter, bSetting); } -void CJX_EventPseudoModel::selEnd(CFXJSE_Value* pValue, +void CJX_EventPseudoModel::selEnd(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::SelectionEnd, bSetting); + Property(pIsolate, pValue, XFA_Event::SelectionEnd, bSetting); } -void CJX_EventPseudoModel::selStart(CFXJSE_Value* pValue, +void CJX_EventPseudoModel::selStart(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::SelectionStart, bSetting); + Property(pIsolate, pValue, XFA_Event::SelectionStart, bSetting); } -void CJX_EventPseudoModel::shift(CFXJSE_Value* pValue, +void CJX_EventPseudoModel::shift(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::Shift, bSetting); + Property(pIsolate, pValue, XFA_Event::Shift, bSetting); } -void CJX_EventPseudoModel::soapFaultCode(CFXJSE_Value* pValue, +void CJX_EventPseudoModel::soapFaultCode(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::SoapFaultCode, bSetting); + Property(pIsolate, pValue, XFA_Event::SoapFaultCode, bSetting); } -void CJX_EventPseudoModel::soapFaultString(CFXJSE_Value* pValue, +void CJX_EventPseudoModel::soapFaultString(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::SoapFaultString, bSetting); + Property(pIsolate, pValue, XFA_Event::SoapFaultString, bSetting); } -void CJX_EventPseudoModel::target(CFXJSE_Value* pValue, +void CJX_EventPseudoModel::target(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::Target, bSetting); + Property(pIsolate, pValue, XFA_Event::Target, bSetting); } CJS_Result CJX_EventPseudoModel::emit( @@ -201,7 +228,8 @@ return CJS_Result::Success(); } -void CJX_EventPseudoModel::Property(CFXJSE_Value* pValue, +void CJX_EventPseudoModel::Property(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, XFA_Event dwFlag, bool bSetting) { // Only the cancelAction, selStart, selEnd and change properties are writable. @@ -218,40 +246,43 @@ switch (dwFlag) { case XFA_Event::CancelAction: - BooleanProperty(pValue, &pEventParam->m_bCancelAction, bSetting); + BooleanProperty(pIsolate, pValue, &pEventParam->m_bCancelAction, + bSetting); break; case XFA_Event::Change: - StringProperty(pValue, &pEventParam->m_wsChange, bSetting); + StringProperty(pIsolate, pValue, &pEventParam->m_wsChange, bSetting); break; case XFA_Event::CommitKey: - IntegerProperty(pValue, &pEventParam->m_iCommitKey, bSetting); + IntegerProperty(pIsolate, pValue, &pEventParam->m_iCommitKey, bSetting); break; case XFA_Event::FullText: - StringProperty(pValue, &pEventParam->m_wsFullText, bSetting); + StringProperty(pIsolate, pValue, &pEventParam->m_wsFullText, bSetting); break; case XFA_Event::Keydown: - BooleanProperty(pValue, &pEventParam->m_bKeyDown, bSetting); + BooleanProperty(pIsolate, pValue, &pEventParam->m_bKeyDown, bSetting); break; case XFA_Event::Modifier: - BooleanProperty(pValue, &pEventParam->m_bModifier, bSetting); + BooleanProperty(pIsolate, pValue, &pEventParam->m_bModifier, bSetting); break; case XFA_Event::NewContentType: - StringProperty(pValue, &pEventParam->m_wsNewContentType, bSetting); + StringProperty(pIsolate, pValue, &pEventParam->m_wsNewContentType, + bSetting); break; case XFA_Event::NewText: NOTREACHED(); break; case XFA_Event::PreviousContentType: - StringProperty(pValue, &pEventParam->m_wsPrevContentType, bSetting); + StringProperty(pIsolate, pValue, &pEventParam->m_wsPrevContentType, + bSetting); break; case XFA_Event::PreviousText: - StringProperty(pValue, &pEventParam->m_wsPrevText, bSetting); + StringProperty(pIsolate, pValue, &pEventParam->m_wsPrevText, bSetting); break; case XFA_Event::Reenter: - BooleanProperty(pValue, &pEventParam->m_bReenter, bSetting); + BooleanProperty(pIsolate, pValue, &pEventParam->m_bReenter, bSetting); break; case XFA_Event::SelectionEnd: - IntegerProperty(pValue, &pEventParam->m_iSelEnd, bSetting); + IntegerProperty(pIsolate, pValue, &pEventParam->m_iSelEnd, bSetting); pEventParam->m_iSelEnd = std::max(0, pEventParam->m_iSelEnd); pEventParam->m_iSelEnd = @@ -261,7 +292,7 @@ std::min(pEventParam->m_iSelStart, pEventParam->m_iSelEnd); break; case XFA_Event::SelectionStart: - IntegerProperty(pValue, &pEventParam->m_iSelStart, bSetting); + IntegerProperty(pIsolate, pValue, &pEventParam->m_iSelStart, bSetting); pEventParam->m_iSelStart = std::max(0, pEventParam->m_iSelStart); pEventParam->m_iSelStart = std::min(static_cast<size_t>(pEventParam->m_iSelStart), @@ -270,13 +301,15 @@ std::max(pEventParam->m_iSelStart, pEventParam->m_iSelEnd); break; case XFA_Event::Shift: - BooleanProperty(pValue, &pEventParam->m_bShift, bSetting); + BooleanProperty(pIsolate, pValue, &pEventParam->m_bShift, bSetting); break; case XFA_Event::SoapFaultCode: - StringProperty(pValue, &pEventParam->m_wsSoapFaultCode, bSetting); + StringProperty(pIsolate, pValue, &pEventParam->m_wsSoapFaultCode, + bSetting); break; case XFA_Event::SoapFaultString: - StringProperty(pValue, &pEventParam->m_wsSoapFaultString, bSetting); + StringProperty(pIsolate, pValue, &pEventParam->m_wsSoapFaultString, + bSetting); break; case XFA_Event::Target: default:
diff --git a/fxjs/xfa/cjx_eventpseudomodel.h b/fxjs/xfa/cjx_eventpseudomodel.h index a4e741f..e4a698b 100644 --- a/fxjs/xfa/cjx_eventpseudomodel.h +++ b/fxjs/xfa/cjx_eventpseudomodel.h
@@ -71,7 +71,10 @@ static const TypeTag static_type__ = TypeTag::EventPseudoModel; static const CJX_MethodSpec MethodSpecs[]; - void Property(CFXJSE_Value* pValue, XFA_Event dwFlag, bool bSetting); + void Property(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, + XFA_Event dwFlag, + bool bSetting); }; #endif // FXJS_XFA_CJX_EVENTPSEUDOMODEL_H_
diff --git a/fxjs/xfa/cjx_exclgroup.cpp b/fxjs/xfa/cjx_exclgroup.cpp index 7f17bc8..74807ee 100644 --- a/fxjs/xfa/cjx_exclgroup.cpp +++ b/fxjs/xfa/cjx_exclgroup.cpp
@@ -115,7 +115,8 @@ value->DirectGetValue().Get(runtime->GetIsolate())); } -void CJX_ExclGroup::defaultValue(CFXJSE_Value* pValue, +void CJX_ExclGroup::defaultValue(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { CXFA_Node* node = GetXFANode(); @@ -123,31 +124,34 @@ return; if (bSetting) { - node->SetSelectedMemberByValue(pValue->ToWideString().AsStringView(), true, - true, true); + node->SetSelectedMemberByValue( + pValue->ToWideString(pIsolate).AsStringView(), true, true, true); return; } WideString wsValue = GetContent(true); XFA_VERSION curVersion = GetDocument()->GetCurVersionMode(); if (wsValue.IsEmpty() && curVersion >= XFA_VERSION_300) { - pValue->SetNull(); + pValue->SetNull(pIsolate); return; } - pValue->SetString(wsValue.ToUTF8().AsStringView()); + pValue->SetString(pIsolate, wsValue.ToUTF8().AsStringView()); } -void CJX_ExclGroup::rawValue(CFXJSE_Value* pValue, +void CJX_ExclGroup::rawValue(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - defaultValue(pValue, bSetting, eAttribute); + defaultValue(pIsolate, pValue, bSetting, eAttribute); } -void CJX_ExclGroup::transient(CFXJSE_Value* pValue, +void CJX_ExclGroup::transient(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) {} -void CJX_ExclGroup::errorText(CFXJSE_Value* pValue, +void CJX_ExclGroup::errorText(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting)
diff --git a/fxjs/xfa/cjx_extras.cpp b/fxjs/xfa/cjx_extras.cpp index a2e2eea..def230c 100644 --- a/fxjs/xfa/cjx_extras.cpp +++ b/fxjs/xfa/cjx_extras.cpp
@@ -16,6 +16,7 @@ return eType == static_type__ || ParentType__::DynamicTypeIs(eType); } -void CJX_Extras::type(CFXJSE_Value* pValue, +void CJX_Extras::type(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) {}
diff --git a/fxjs/xfa/cjx_field.cpp b/fxjs/xfa/cjx_field.cpp index 4e7bc44..60f534e 100644 --- a/fxjs/xfa/cjx_field.cpp +++ b/fxjs/xfa/cjx_field.cpp
@@ -242,7 +242,8 @@ runtime->NewBoolean(iRet != XFA_EventError::kError)); } -void CJX_Field::defaultValue(CFXJSE_Value* pValue, +void CJX_Field::defaultValue(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { CXFA_Node* xfaNode = GetXFANode(); @@ -252,12 +253,12 @@ if (bSetting) { if (pValue) { xfaNode->SetPreNull(xfaNode->IsNull()); - xfaNode->SetIsNull(pValue->IsNull()); + xfaNode->SetIsNull(pValue->IsNull(pIsolate)); } WideString wsNewText; - if (pValue && !(pValue->IsNull() || pValue->IsUndefined())) - wsNewText = pValue->ToWideString(); + if (pValue && !(pValue->IsNull(pIsolate) || pValue->IsUndefined(pIsolate))) + wsNewText = pValue->ToWideString(pIsolate); if (xfaNode->GetUIChildNode()->GetElementType() == XFA_Element::NumericEdit) wsNewText = xfaNode->NumericLimit(wsNewText); @@ -272,7 +273,7 @@ WideString content = GetContent(true); if (content.IsEmpty()) { - pValue->SetNull(); + pValue->SetNull(pIsolate); return; } @@ -282,24 +283,25 @@ if (xfaNode->GetUIChildNode()->GetElementType() == XFA_Element::NumericEdit && (pNode->JSObject()->GetInteger(XFA_Attribute::FracDigits) == -1)) { - pValue->SetString(content.ToUTF8().AsStringView()); + pValue->SetString(pIsolate, content.ToUTF8().AsStringView()); } else { CFGAS_Decimal decimal(content.AsStringView()); - pValue->SetFloat(decimal.ToFloat()); + pValue->SetFloat(pIsolate, decimal.ToFloat()); } } else if (pNode && pNode->GetElementType() == XFA_Element::Integer) { - pValue->SetInteger(FXSYS_wtoi(content.c_str())); + pValue->SetInteger(pIsolate, FXSYS_wtoi(content.c_str())); } else if (pNode && pNode->GetElementType() == XFA_Element::Boolean) { - pValue->SetBoolean(FXSYS_wtoi(content.c_str()) != 0); + pValue->SetBoolean(pIsolate, FXSYS_wtoi(content.c_str()) != 0); } else if (pNode && pNode->GetElementType() == XFA_Element::Float) { CFGAS_Decimal decimal(content.AsStringView()); - pValue->SetFloat(decimal.ToFloat()); + pValue->SetFloat(pIsolate, decimal.ToFloat()); } else { - pValue->SetString(content.ToUTF8().AsStringView()); + pValue->SetString(pIsolate, content.ToUTF8().AsStringView()); } } -void CJX_Field::editValue(CFXJSE_Value* pValue, +void CJX_Field::editValue(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { CXFA_Node* node = GetXFANode(); @@ -307,20 +309,22 @@ return; if (bSetting) { - node->SetValue(XFA_VALUEPICTURE_Edit, pValue->ToWideString()); + node->SetValue(XFA_VALUEPICTURE_Edit, pValue->ToWideString(pIsolate)); return; } pValue->SetString( - node->GetValue(XFA_VALUEPICTURE_Edit).ToUTF8().AsStringView()); + pIsolate, node->GetValue(XFA_VALUEPICTURE_Edit).ToUTF8().AsStringView()); } -void CJX_Field::formatMessage(CFXJSE_Value* pValue, +void CJX_Field::formatMessage(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - ScriptSomMessage(pValue, bSetting, XFA_SOM_FormatMessage); + ScriptSomMessage(pIsolate, pValue, bSetting, XFA_SOM_FormatMessage); } -void CJX_Field::formattedValue(CFXJSE_Value* pValue, +void CJX_Field::formattedValue(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { CXFA_Node* node = GetXFANode(); @@ -328,14 +332,16 @@ return; if (bSetting) { - node->SetValue(XFA_VALUEPICTURE_Display, pValue->ToWideString()); + node->SetValue(XFA_VALUEPICTURE_Display, pValue->ToWideString(pIsolate)); return; } pValue->SetString( + pIsolate, node->GetValue(XFA_VALUEPICTURE_Display).ToUTF8().AsStringView()); } -void CJX_Field::length(CFXJSE_Value* pValue, +void CJX_Field::length(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { @@ -345,23 +351,25 @@ CXFA_Node* node = GetXFANode(); if (!node->IsWidgetReady()) { - pValue->SetInteger(0); + pValue->SetInteger(pIsolate, 0); return; } - pValue->SetInteger(node->CountChoiceListItems(true)); + pValue->SetInteger(pIsolate, node->CountChoiceListItems(true)); } -void CJX_Field::parentSubform(CFXJSE_Value* pValue, +void CJX_Field::parentSubform(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { ThrowInvalidPropertyException(); return; } - pValue->SetNull(); + pValue->SetNull(pIsolate); } -void CJX_Field::selectedIndex(CFXJSE_Value* pValue, +void CJX_Field::selectedIndex(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { CXFA_Node* node = GetXFANode(); @@ -369,11 +377,11 @@ return; if (!bSetting) { - pValue->SetInteger(node->GetSelectedItem(0)); + pValue->SetInteger(pIsolate, node->GetSelectedItem(0)); return; } - int32_t iIndex = pValue->ToInteger(); + int32_t iIndex = pValue->ToInteger(pIsolate); if (iIndex == -1) { node->ClearAllSelections(); return; @@ -382,8 +390,9 @@ node->SetItemState(iIndex, true, true, true, true); } -void CJX_Field::rawValue(CFXJSE_Value* pValue, +void CJX_Field::rawValue(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - defaultValue(pValue, bSetting, eAttribute); + defaultValue(pIsolate, pValue, bSetting, eAttribute); }
diff --git a/fxjs/xfa/cjx_form.cpp b/fxjs/xfa/cjx_form.cpp index 6cb6c6b..d398437 100644 --- a/fxjs/xfa/cjx_form.cpp +++ b/fxjs/xfa/cjx_form.cpp
@@ -130,14 +130,17 @@ runtime->NewBoolean(iRet != XFA_EventError::kError)); } -void CJX_Form::checksumS(CFXJSE_Value* pValue, +void CJX_Form::checksumS(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { - SetAttributeByEnum(XFA_Attribute::Checksum, pValue->ToWideString(), false); + SetAttributeByEnum(XFA_Attribute::Checksum, pValue->ToWideString(pIsolate), + false); return; } Optional<WideString> checksum = TryAttribute(XFA_Attribute::Checksum, false); - pValue->SetString(checksum ? checksum->ToUTF8().AsStringView() : ""); + pValue->SetString(pIsolate, + checksum ? checksum->ToUTF8().AsStringView() : ""); }
diff --git a/fxjs/xfa/cjx_handler.cpp b/fxjs/xfa/cjx_handler.cpp index 21be88c..5cdf5b5 100644 --- a/fxjs/xfa/cjx_handler.cpp +++ b/fxjs/xfa/cjx_handler.cpp
@@ -16,6 +16,7 @@ return eType == static_type__ || ParentType__::DynamicTypeIs(eType); } -void CJX_Handler::version(CFXJSE_Value* pValue, +void CJX_Handler::version(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) {}
diff --git a/fxjs/xfa/cjx_hostpseudomodel.cpp b/fxjs/xfa/cjx_hostpseudomodel.cpp index e4bd454..34be45d 100644 --- a/fxjs/xfa/cjx_hostpseudomodel.cpp +++ b/fxjs/xfa/cjx_hostpseudomodel.cpp
@@ -76,7 +76,8 @@ return eType == static_type__ || ParentType__::DynamicTypeIs(eType); } -void CJX_HostPseudoModel::appType(CFXJSE_Value* pValue, +void CJX_HostPseudoModel::appType(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); @@ -87,10 +88,11 @@ ThrowInvalidPropertyException(); return; } - pValue->SetString("Exchange"); + pValue->SetString(pIsolate, "Exchange"); } -void CJX_HostPseudoModel::calculationsEnabled(CFXJSE_Value* pValue, +void CJX_HostPseudoModel::calculationsEnabled(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); @@ -99,13 +101,14 @@ CXFA_FFDoc* hDoc = pNotify->GetFFDoc(); if (bSetting) { - hDoc->SetCalculationsEnabled(pValue->ToBoolean()); + hDoc->SetCalculationsEnabled(pValue->ToBoolean(pIsolate)); return; } - pValue->SetBoolean(hDoc->IsCalculationsEnabled()); + pValue->SetBoolean(pIsolate, hDoc->IsCalculationsEnabled()); } -void CJX_HostPseudoModel::currentPage(CFXJSE_Value* pValue, +void CJX_HostPseudoModel::currentPage(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); @@ -114,13 +117,14 @@ CXFA_FFDoc* hDoc = pNotify->GetFFDoc(); if (bSetting) { - hDoc->SetCurrentPage(pValue->ToInteger()); + hDoc->SetCurrentPage(pValue->ToInteger(pIsolate)); return; } - pValue->SetInteger(hDoc->GetCurrentPage()); + pValue->SetInteger(pIsolate, hDoc->GetCurrentPage()); } -void CJX_HostPseudoModel::language(CFXJSE_Value* pValue, +void CJX_HostPseudoModel::language(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); @@ -132,10 +136,12 @@ return; } pValue->SetString( + pIsolate, pNotify->GetAppProvider()->GetLanguage().ToUTF8().AsStringView()); } -void CJX_HostPseudoModel::numPages(CFXJSE_Value* pValue, +void CJX_HostPseudoModel::numPages(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); @@ -147,10 +153,11 @@ ThrowException(WideString::FromASCII("Unable to set numPages value.")); return; } - pValue->SetInteger(hDoc->CountPages()); + pValue->SetInteger(pIsolate, hDoc->CountPages()); } -void CJX_HostPseudoModel::platform(CFXJSE_Value* pValue, +void CJX_HostPseudoModel::platform(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); @@ -162,10 +169,12 @@ return; } pValue->SetString( + pIsolate, pNotify->GetAppProvider()->GetPlatform().ToUTF8().AsStringView()); } -void CJX_HostPseudoModel::title(CFXJSE_Value* pValue, +void CJX_HostPseudoModel::title(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (!GetDocument()->GetScriptContext()->IsRunAtClient()) @@ -177,15 +186,16 @@ CXFA_FFDoc* hDoc = pNotify->GetFFDoc(); if (bSetting) { - hDoc->SetTitle(pValue->ToWideString()); + hDoc->SetTitle(pValue->ToWideString(pIsolate)); return; } WideString wsTitle = hDoc->GetTitle(); - pValue->SetString(wsTitle.ToUTF8().AsStringView()); + pValue->SetString(pIsolate, wsTitle.ToUTF8().AsStringView()); } -void CJX_HostPseudoModel::validationsEnabled(CFXJSE_Value* pValue, +void CJX_HostPseudoModel::validationsEnabled(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); @@ -194,15 +204,16 @@ CXFA_FFDoc* hDoc = pNotify->GetFFDoc(); if (bSetting) { - hDoc->SetValidationsEnabled(pValue->ToBoolean()); + hDoc->SetValidationsEnabled(pValue->ToBoolean(pIsolate)); return; } bool bEnabled = hDoc->IsValidationsEnabled(); - pValue->SetBoolean(bEnabled); + pValue->SetBoolean(pIsolate, bEnabled); } -void CJX_HostPseudoModel::variation(CFXJSE_Value* pValue, +void CJX_HostPseudoModel::variation(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (!GetDocument()->GetScriptContext()->IsRunAtClient()) @@ -212,20 +223,22 @@ ThrowException(WideString::FromASCII("Unable to set variation value.")); return; } - pValue->SetString("Full"); + pValue->SetString(pIsolate, "Full"); } -void CJX_HostPseudoModel::version(CFXJSE_Value* pValue, +void CJX_HostPseudoModel::version(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { ThrowException(WideString::FromASCII("Unable to set version value.")); return; } - pValue->SetString("11"); + pValue->SetString(pIsolate, "11"); } -void CJX_HostPseudoModel::name(CFXJSE_Value* pValue, +void CJX_HostPseudoModel::name(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); @@ -237,6 +250,7 @@ return; } pValue->SetString( + pIsolate, pNotify->GetAppProvider()->GetAppName().ToUTF8().AsStringView()); }
diff --git a/fxjs/xfa/cjx_instancemanager.cpp b/fxjs/xfa/cjx_instancemanager.cpp index fd3b4cd..7d1fdb6 100644 --- a/fxjs/xfa/cjx_instancemanager.cpp +++ b/fxjs/xfa/cjx_instancemanager.cpp
@@ -302,7 +302,8 @@ value->DirectGetValue().Get(runtime->GetIsolate())); } -void CJX_InstanceManager::max(CFXJSE_Value* pValue, +void CJX_InstanceManager::max(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { @@ -310,10 +311,12 @@ return; } CXFA_Occur* occur = GetXFANode()->GetOccurIfExists(); - pValue->SetInteger(occur ? occur->GetMax() : CXFA_Occur::kDefaultMax); + pValue->SetInteger(pIsolate, + occur ? occur->GetMax() : CXFA_Occur::kDefaultMax); } -void CJX_InstanceManager::min(CFXJSE_Value* pValue, +void CJX_InstanceManager::min(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { @@ -321,15 +324,17 @@ return; } CXFA_Occur* occur = GetXFANode()->GetOccurIfExists(); - pValue->SetInteger(occur ? occur->GetMin() : CXFA_Occur::kDefaultMin); + pValue->SetInteger(pIsolate, + occur ? occur->GetMin() : CXFA_Occur::kDefaultMin); } -void CJX_InstanceManager::count(CFXJSE_Value* pValue, +void CJX_InstanceManager::count(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { - SetInstances(pValue->ToInteger()); + SetInstances(pValue->ToInteger(pIsolate)); return; } - pValue->SetInteger(GetXFANode()->GetCount()); + pValue->SetInteger(pIsolate, GetXFANode()->GetCount()); }
diff --git a/fxjs/xfa/cjx_layoutpseudomodel.cpp b/fxjs/xfa/cjx_layoutpseudomodel.cpp index e4a6f03..89222fc 100644 --- a/fxjs/xfa/cjx_layoutpseudomodel.cpp +++ b/fxjs/xfa/cjx_layoutpseudomodel.cpp
@@ -62,7 +62,8 @@ return eType == static_type__ || ParentType__::DynamicTypeIs(eType); } -void CJX_LayoutPseudoModel::ready(CFXJSE_Value* pValue, +void CJX_LayoutPseudoModel::ready(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); @@ -74,7 +75,7 @@ } int32_t iStatus = pNotify->GetLayoutStatus(); - pValue->SetBoolean(iStatus >= 2); + pValue->SetBoolean(pIsolate, iStatus >= 2); } CJS_Result CJX_LayoutPseudoModel::HWXY(
diff --git a/fxjs/xfa/cjx_list.cpp b/fxjs/xfa/cjx_list.cpp index 75d63b3..bd66cb6 100644 --- a/fxjs/xfa/cjx_list.cpp +++ b/fxjs/xfa/cjx_list.cpp
@@ -97,7 +97,8 @@ pEngine->NewNormalXFAObject(GetXFAList()->Item(cast_index))); } -void CJX_List::length(CFXJSE_Value* pValue, +void CJX_List::length(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { @@ -105,5 +106,5 @@ return; } pValue->SetInteger( - pdfium::base::checked_cast<int32_t>(GetXFAList()->GetLength())); + pIsolate, pdfium::base::checked_cast<int32_t>(GetXFAList()->GetLength())); }
diff --git a/fxjs/xfa/cjx_model.cpp b/fxjs/xfa/cjx_model.cpp index 1c1ae19..fc70823 100644 --- a/fxjs/xfa/cjx_model.cpp +++ b/fxjs/xfa/cjx_model.cpp
@@ -86,10 +86,12 @@ runtime->NewBoolean(TryNamespace().value_or(WideString()) == nameSpace)); } -void CJX_Model::context(CFXJSE_Value* pValue, +void CJX_Model::context(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) {} -void CJX_Model::aliasNode(CFXJSE_Value* pValue, +void CJX_Model::aliasNode(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) {}
diff --git a/fxjs/xfa/cjx_node.cpp b/fxjs/xfa/cjx_node.cpp index 5034165..db57654 100644 --- a/fxjs/xfa/cjx_node.cpp +++ b/fxjs/xfa/cjx_node.cpp
@@ -448,7 +448,8 @@ return CJS_Result::Success(); } -void CJX_Node::ns(CFXJSE_Value* pValue, +void CJX_Node::ns(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { @@ -456,31 +457,35 @@ return; } pValue->SetString( - TryNamespace().value_or(WideString()).ToUTF8().AsStringView()); + pIsolate, TryNamespace().value_or(WideString()).ToUTF8().AsStringView()); } -void CJX_Node::model(CFXJSE_Value* pValue, +void CJX_Node::model(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { ThrowInvalidPropertyException(); return; } - pValue->Assign(GetDocument()->GetScriptContext()->GetOrCreateJSBindingFromMap( - GetXFANode()->GetModelNode())); + pValue->Assign(pIsolate, + GetDocument()->GetScriptContext()->GetOrCreateJSBindingFromMap( + GetXFANode()->GetModelNode())); } -void CJX_Node::isContainer(CFXJSE_Value* pValue, +void CJX_Node::isContainer(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { ThrowInvalidPropertyException(); return; } - pValue->SetBoolean(GetXFANode()->IsContainerNode()); + pValue->SetBoolean(pIsolate, GetXFANode()->IsContainerNode()); } -void CJX_Node::isNull(CFXJSE_Value* pValue, +void CJX_Node::isNull(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { @@ -488,13 +493,14 @@ return; } if (GetXFANode()->GetElementType() == XFA_Element::Subform) { - pValue->SetBoolean(false); + pValue->SetBoolean(pIsolate, false); return; } - pValue->SetBoolean(GetContent(false).IsEmpty()); + pValue->SetBoolean(pIsolate, GetContent(false).IsEmpty()); } -void CJX_Node::oneOfChild(CFXJSE_Value* pValue, +void CJX_Node::oneOfChild(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { @@ -506,6 +512,7 @@ GetXFANode()->GetNodeListWithFilter(XFA_NODEFILTER_OneOfProperty); if (!properties.empty()) { pValue->Assign( + pIsolate, GetDocument()->GetScriptContext()->GetOrCreateJSBindingFromMap( properties.front())); }
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp index eb975b1..4944a2b 100644 --- a/fxjs/xfa/cjx_object.cpp +++ b/fxjs/xfa/cjx_object.cpp
@@ -125,14 +125,15 @@ return ToNode(GetXFAObject()); } -void CJX_Object::className(CFXJSE_Value* pValue, +void CJX_Object::className(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { ThrowInvalidPropertyException(); return; } - pValue->SetString(GetXFAObject()->GetClassName()); + pValue->SetString(pIsolate, GetXFAObject()->GetClassName()); } int32_t CJX_Object::Subform_and_SubformSet_InstanceIndex() { @@ -942,15 +943,17 @@ that->calc_data_ = nullptr; } -void CJX_Object::ScriptAttributeString(CFXJSE_Value* pValue, +void CJX_Object::ScriptAttributeString(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (!bSetting) { - pValue->SetString(GetAttributeByEnum(eAttribute).ToUTF8().AsStringView()); + pValue->SetString(pIsolate, + GetAttributeByEnum(eAttribute).ToUTF8().AsStringView()); return; } - WideString wsValue = pValue->ToWideString(); + WideString wsValue = pValue->ToWideString(pIsolate); SetAttributeByEnum(eAttribute, wsValue, true); if (eAttribute != XFA_Attribute::Use || GetXFAObject()->GetElementType() != XFA_Element::Desc) { @@ -1009,27 +1012,30 @@ } } -void CJX_Object::ScriptAttributeBool(CFXJSE_Value* pValue, +void CJX_Object::ScriptAttributeBool(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { - SetBoolean(eAttribute, pValue->ToBoolean(), true); + SetBoolean(eAttribute, pValue->ToBoolean(pIsolate), true); return; } - pValue->SetString(GetBoolean(eAttribute) ? "1" : "0"); + pValue->SetString(pIsolate, GetBoolean(eAttribute) ? "1" : "0"); } -void CJX_Object::ScriptAttributeInteger(CFXJSE_Value* pValue, +void CJX_Object::ScriptAttributeInteger(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { - SetInteger(eAttribute, pValue->ToInteger(), true); + SetInteger(eAttribute, pValue->ToInteger(pIsolate), true); return; } - pValue->SetInteger(GetInteger(eAttribute)); + pValue->SetInteger(pIsolate, GetInteger(eAttribute)); } -void CJX_Object::ScriptSomFontColor(CFXJSE_Value* pValue, +void CJX_Object::ScriptSomFontColor(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { CXFA_Font* font = ToNode(object_.Get())->GetOrCreateFontIfPossible(); @@ -1040,7 +1046,7 @@ int32_t r; int32_t g; int32_t b; - std::tie(r, g, b) = StrToRGB(pValue->ToWideString()); + std::tie(r, g, b) = StrToRGB(pValue->ToWideString(pIsolate)); FX_ARGB color = ArgbEncode(0xff, r, g, b); font->SetColor(color); return; @@ -1051,10 +1057,12 @@ int32_t g; int32_t b; std::tie(a, r, g, b) = ArgbDecode(font->GetColor()); - pValue->SetString(ByteString::Format("%d,%d,%d", r, g, b).AsStringView()); + pValue->SetString(pIsolate, + ByteString::Format("%d,%d,%d", r, g, b).AsStringView()); } -void CJX_Object::ScriptSomFillColor(CFXJSE_Value* pValue, +void CJX_Object::ScriptSomFillColor(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { CXFA_Border* border = ToNode(object_.Get())->GetOrCreateBorderIfPossible(); @@ -1066,7 +1074,7 @@ int32_t r; int32_t g; int32_t b; - std::tie(r, g, b) = StrToRGB(pValue->ToWideString()); + std::tie(r, g, b) = StrToRGB(pValue->ToWideString(pIsolate)); FX_ARGB color = ArgbEncode(0xff, r, g, b); borderfill->SetColor(color); return; @@ -1079,10 +1087,12 @@ int32_t b; std::tie(a, r, g, b) = ArgbDecode(color); pValue->SetString( + pIsolate, WideString::Format(L"%d,%d,%d", r, g, b).ToUTF8().AsStringView()); } -void CJX_Object::ScriptSomBorderColor(CFXJSE_Value* pValue, +void CJX_Object::ScriptSomBorderColor(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { CXFA_Border* border = ToNode(object_.Get())->GetOrCreateBorderIfPossible(); @@ -1091,7 +1101,7 @@ int32_t r = 0; int32_t g = 0; int32_t b = 0; - std::tie(r, g, b) = StrToRGB(pValue->ToWideString()); + std::tie(r, g, b) = StrToRGB(pValue->ToWideString(pIsolate)); FX_ARGB rgb = ArgbEncode(100, r, g, b); for (int32_t i = 0; i < iSize; ++i) { CXFA_Edge* edge = border->GetEdgeIfExists(i); @@ -1110,10 +1120,12 @@ int32_t b; std::tie(a, r, g, b) = ArgbDecode(color); pValue->SetString( + pIsolate, WideString::Format(L"%d,%d,%d", r, g, b).ToUTF8().AsStringView()); } -void CJX_Object::ScriptSomBorderWidth(CFXJSE_Value* pValue, +void CJX_Object::ScriptSomBorderWidth(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { CXFA_Border* border = ToNode(object_.Get())->GetOrCreateBorderIfPossible(); @@ -1121,14 +1133,14 @@ CXFA_Edge* edge = border->GetEdgeIfExists(0); CXFA_Measurement thickness = edge ? edge->GetMSThickness() : CXFA_Measurement(0.5, XFA_Unit::Pt); - pValue->SetString(thickness.ToString().ToUTF8().AsStringView()); + pValue->SetString(pIsolate, thickness.ToString().ToUTF8().AsStringView()); return; } if (pValue->IsEmpty()) return; - WideString wsThickness = pValue->ToWideString(); + WideString wsThickness = pValue->ToWideString(pIsolate); for (int32_t i = 0; i < border->CountEdges(); ++i) { CXFA_Edge* edge = border->GetEdgeIfExists(i); if (edge) @@ -1136,7 +1148,8 @@ } } -void CJX_Object::ScriptSomMessage(CFXJSE_Value* pValue, +void CJX_Object::ScriptSomMessage(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_SOM_MESSAGETYPE iMessageType) { bool bNew = false; @@ -1150,13 +1163,13 @@ if (validate) { switch (iMessageType) { case XFA_SOM_ValidationMessage: - validate->SetScriptMessageText(pValue->ToWideString()); + validate->SetScriptMessageText(pValue->ToWideString(pIsolate)); break; case XFA_SOM_FormatMessage: - validate->SetFormatMessageText(pValue->ToWideString()); + validate->SetFormatMessageText(pValue->ToWideString(pIsolate)); break; case XFA_SOM_MandatoryMessage: - validate->SetNullMessageText(pValue->ToWideString()); + validate->SetNullMessageText(pValue->ToWideString(pIsolate)); break; default: break; @@ -1193,22 +1206,25 @@ default: break; } - pValue->SetString(wsMessage.ToUTF8().AsStringView()); + pValue->SetString(pIsolate, wsMessage.ToUTF8().AsStringView()); } -void CJX_Object::ScriptSomValidationMessage(CFXJSE_Value* pValue, +void CJX_Object::ScriptSomValidationMessage(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - ScriptSomMessage(pValue, bSetting, XFA_SOM_ValidationMessage); + ScriptSomMessage(pIsolate, pValue, bSetting, XFA_SOM_ValidationMessage); } -void CJX_Object::ScriptSomMandatoryMessage(CFXJSE_Value* pValue, +void CJX_Object::ScriptSomMandatoryMessage(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - ScriptSomMessage(pValue, bSetting, XFA_SOM_MandatoryMessage); + ScriptSomMessage(pIsolate, pValue, bSetting, XFA_SOM_MandatoryMessage); } -void CJX_Object::ScriptSomDefaultValue(CFXJSE_Value* pValue, +void CJX_Object::ScriptSomDefaultValue(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute /* unused */) { XFA_Element eType = GetXFANode()->GetElementType(); @@ -1217,26 +1233,26 @@ // if defaultValue is defined and, if so, call that one. Just have to make // sure that those defaultValue calls don't call back to this one .... if (eType == XFA_Element::Field) { - static_cast<CJX_Field*>(this)->defaultValue(pValue, bSetting, + static_cast<CJX_Field*>(this)->defaultValue(pIsolate, pValue, bSetting, XFA_Attribute::Unknown); return; } if (eType == XFA_Element::Draw) { - static_cast<CJX_Draw*>(this)->defaultValue(pValue, bSetting, + static_cast<CJX_Draw*>(this)->defaultValue(pIsolate, pValue, bSetting, XFA_Attribute::Unknown); return; } if (eType == XFA_Element::Boolean) { - static_cast<CJX_Boolean*>(this)->defaultValue(pValue, bSetting, + static_cast<CJX_Boolean*>(this)->defaultValue(pIsolate, pValue, bSetting, XFA_Attribute::Unknown); return; } if (bSetting) { WideString wsNewValue; - if (pValue && - !(pValue->IsEmpty() || pValue->IsNull() || pValue->IsUndefined())) { - wsNewValue = pValue->ToWideString(); + if (pValue && !(pValue->IsEmpty() || pValue->IsNull(pIsolate) || + pValue->IsUndefined(pIsolate))) { + wsNewValue = pValue->ToWideString(pIsolate); } WideString wsFormatValue(wsNewValue); @@ -1271,18 +1287,19 @@ WideString content = GetContent(true); if (content.IsEmpty() && eType != XFA_Element::Text && eType != XFA_Element::SubmitUrl) { - pValue->SetNull(); + pValue->SetNull(pIsolate); } else if (eType == XFA_Element::Integer) { - pValue->SetInteger(FXSYS_wtoi(content.c_str())); + pValue->SetInteger(pIsolate, FXSYS_wtoi(content.c_str())); } else if (eType == XFA_Element::Float || eType == XFA_Element::Decimal) { CFGAS_Decimal decimal(content.AsStringView()); - pValue->SetFloat(decimal.ToFloat()); + pValue->SetFloat(pIsolate, decimal.ToFloat()); } else { - pValue->SetString(content.ToUTF8().AsStringView()); + pValue->SetString(pIsolate, content.ToUTF8().AsStringView()); } } -void CJX_Object::ScriptSomDefaultValue_Read(CFXJSE_Value* pValue, +void CJX_Object::ScriptSomDefaultValue_Read(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { @@ -1292,13 +1309,14 @@ WideString content = GetContent(true); if (content.IsEmpty()) { - pValue->SetNull(); + pValue->SetNull(pIsolate); return; } - pValue->SetString(content.ToUTF8().AsStringView()); + pValue->SetString(pIsolate, content.ToUTF8().AsStringView()); } -void CJX_Object::ScriptSomDataNode(CFXJSE_Value* pValue, +void CJX_Object::ScriptSomDataNode(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { @@ -1308,15 +1326,17 @@ CXFA_Node* pDataNode = GetXFANode()->GetBindData(); if (!pDataNode) { - pValue->SetNull(); + pValue->SetNull(pIsolate); return; } - pValue->Assign(GetDocument()->GetScriptContext()->GetOrCreateJSBindingFromMap( - pDataNode)); + pValue->Assign(pIsolate, + GetDocument()->GetScriptContext()->GetOrCreateJSBindingFromMap( + pDataNode)); } -void CJX_Object::ScriptSomMandatory(CFXJSE_Value* pValue, +void CJX_Object::ScriptSomMandatory(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { CXFA_Validate* validate = @@ -1325,22 +1345,24 @@ return; if (bSetting) { - validate->SetNullTest(pValue->ToWideString()); + validate->SetNullTest(pValue->ToWideString(pIsolate)); return; } - pValue->SetString(XFA_AttributeValueToName(validate->GetNullTest())); + pValue->SetString(pIsolate, + XFA_AttributeValueToName(validate->GetNullTest())); } -void CJX_Object::ScriptSomInstanceIndex(CFXJSE_Value* pValue, +void CJX_Object::ScriptSomInstanceIndex(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (!bSetting) { - pValue->SetInteger(Subform_and_SubformSet_InstanceIndex()); + pValue->SetInteger(pIsolate, Subform_and_SubformSet_InstanceIndex()); return; } - int32_t iTo = pValue->ToInteger(); + int32_t iTo = pValue->ToInteger(pIsolate); int32_t iFrom = Subform_and_SubformSet_InstanceIndex(); CXFA_Node* pManagerNode = nullptr; for (CXFA_Node* pNode = GetXFANode()->GetPrevSibling(); pNode; @@ -1371,7 +1393,8 @@ } } -void CJX_Object::ScriptSubmitFormatMode(CFXJSE_Value* pValue, +void CJX_Object::ScriptSubmitFormatMode(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) {}
diff --git a/fxjs/xfa/cjx_object.h b/fxjs/xfa/cjx_object.h index 8cd5ab0..bae2419 100644 --- a/fxjs/xfa/cjx_object.h +++ b/fxjs/xfa/cjx_object.h
@@ -180,7 +180,8 @@ JSE_PROP(ScriptSomInstanceIndex); JSE_PROP(ScriptSubmitFormatMode); - void ScriptSomMessage(CFXJSE_Value* pValue, + void ScriptSomMessage(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_SOM_MESSAGETYPE iMessageType);
diff --git a/fxjs/xfa/cjx_occur.cpp b/fxjs/xfa/cjx_occur.cpp index 227b8ae..c3aa678 100644 --- a/fxjs/xfa/cjx_occur.cpp +++ b/fxjs/xfa/cjx_occur.cpp
@@ -17,24 +17,26 @@ return eType == static_type__ || ParentType__::DynamicTypeIs(eType); } -void CJX_Occur::max(CFXJSE_Value* pValue, +void CJX_Occur::max(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { CXFA_Occur* occur = static_cast<CXFA_Occur*>(GetXFANode()); if (!bSetting) { - pValue->SetInteger(occur->GetMax()); + pValue->SetInteger(pIsolate, occur->GetMax()); return; } - occur->SetMax(pValue->ToInteger()); + occur->SetMax(pValue->ToInteger(pIsolate)); } -void CJX_Occur::min(CFXJSE_Value* pValue, +void CJX_Occur::min(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { CXFA_Occur* occur = static_cast<CXFA_Occur*>(GetXFANode()); if (!bSetting) { - pValue->SetInteger(occur->GetMin()); + pValue->SetInteger(pIsolate, occur->GetMin()); return; } - occur->SetMin(pValue->ToInteger()); + occur->SetMin(pValue->ToInteger(pIsolate)); }
diff --git a/fxjs/xfa/cjx_packet.cpp b/fxjs/xfa/cjx_packet.cpp index ab1b478..70c8609 100644 --- a/fxjs/xfa/cjx_packet.cpp +++ b/fxjs/xfa/cjx_packet.cpp
@@ -78,7 +78,8 @@ return CJS_Result::Success(runtime->NewNull()); } -void CJX_Packet::content(CFXJSE_Value* pValue, +void CJX_Packet::content(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { CFX_XMLElement* element = ToXMLElement(GetXFANode()->GetXMLMappingNode()); @@ -90,7 +91,7 @@ ->GetNotify() ->GetFFDoc() ->GetXMLDocument() - ->CreateNode<CFX_XMLText>(pValue->ToWideString())); + ->CreateNode<CFX_XMLText>(pValue->ToWideString(pIsolate))); } return; } @@ -99,5 +100,5 @@ if (element) wsTextData = element->GetTextData(); - pValue->SetString(wsTextData.ToUTF8().AsStringView()); + pValue->SetString(pIsolate, wsTextData.ToUTF8().AsStringView()); }
diff --git a/fxjs/xfa/cjx_script.cpp b/fxjs/xfa/cjx_script.cpp index 207a2ce..a2de5a7 100644 --- a/fxjs/xfa/cjx_script.cpp +++ b/fxjs/xfa/cjx_script.cpp
@@ -17,12 +17,13 @@ return eType == static_type__ || ParentType__::DynamicTypeIs(eType); } -void CJX_Script::stateless(CFXJSE_Value* pValue, +void CJX_Script::stateless(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { ThrowInvalidPropertyException(); return; } - pValue->SetString("0"); + pValue->SetString(pIsolate, "0"); }
diff --git a/fxjs/xfa/cjx_source.cpp b/fxjs/xfa/cjx_source.cpp index 0e1aab9..c793f29 100644 --- a/fxjs/xfa/cjx_source.cpp +++ b/fxjs/xfa/cjx_source.cpp
@@ -183,6 +183,7 @@ return CJS_Result::Success(); } -void CJX_Source::db(CFXJSE_Value* pValue, +void CJX_Source::db(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) {}
diff --git a/fxjs/xfa/cjx_subform.cpp b/fxjs/xfa/cjx_subform.cpp index 37fe01c..709be8a3 100644 --- a/fxjs/xfa/cjx_subform.cpp +++ b/fxjs/xfa/cjx_subform.cpp
@@ -87,19 +87,22 @@ runtime->NewBoolean(iRet != XFA_EventError::kError)); } -void CJX_Subform::locale(CFXJSE_Value* pValue, +void CJX_Subform::locale(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { - SetCDataImpl(XFA_Attribute::Locale, pValue->ToWideString(), true, true); + SetCDataImpl(XFA_Attribute::Locale, pValue->ToWideString(pIsolate), true, + true); return; } WideString wsLocaleName = GetXFANode()->GetLocaleName().value_or(L""); - pValue->SetString(wsLocaleName.ToUTF8().AsStringView()); + pValue->SetString(pIsolate, wsLocaleName.ToUTF8().AsStringView()); } -void CJX_Subform::instanceManager(CFXJSE_Value* pValue, +void CJX_Subform::instanceManager(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { @@ -122,10 +125,11 @@ } } if (!pInstanceMgr) { - pValue->SetNull(); + pValue->SetNull(pIsolate); return; } - pValue->Assign(GetDocument()->GetScriptContext()->GetOrCreateJSBindingFromMap( - pInstanceMgr)); + pValue->Assign(pIsolate, + GetDocument()->GetScriptContext()->GetOrCreateJSBindingFromMap( + pInstanceMgr)); }
diff --git a/fxjs/xfa/cjx_textnode.cpp b/fxjs/xfa/cjx_textnode.cpp index df6b305..6e90fb3 100644 --- a/fxjs/xfa/cjx_textnode.cpp +++ b/fxjs/xfa/cjx_textnode.cpp
@@ -17,14 +17,16 @@ return eType == static_type__ || ParentType__::DynamicTypeIs(eType); } -void CJX_TextNode::defaultValue(CFXJSE_Value* pValue, +void CJX_TextNode::defaultValue(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute attr) { - ScriptSomDefaultValue(pValue, bSetting, attr); + ScriptSomDefaultValue(pIsolate, pValue, bSetting, attr); } -void CJX_TextNode::value(CFXJSE_Value* pValue, +void CJX_TextNode::value(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute attr) { - ScriptSomDefaultValue(pValue, bSetting, attr); + ScriptSomDefaultValue(pIsolate, pValue, bSetting, attr); }
diff --git a/fxjs/xfa/cjx_tree.cpp b/fxjs/xfa/cjx_tree.cpp index 657e73d..3e7c556 100644 --- a/fxjs/xfa/cjx_tree.cpp +++ b/fxjs/xfa/cjx_tree.cpp
@@ -74,7 +74,8 @@ auto pValue = std::make_unique<CFXJSE_Value>(pScriptContext->GetIsolate()); CJX_Object* jsObject = resolveNodeRS.objects.front()->JSObject(); (*resolveNodeRS.script_attribute.callback)( - jsObject, pValue.get(), false, resolveNodeRS.script_attribute.attribute); + runtime->GetIsolate(), jsObject, pValue.get(), false, + resolveNodeRS.script_attribute.attribute); return CJS_Result::Success( pValue->DirectGetValue().Get(runtime->GetIsolate())); } @@ -91,7 +92,8 @@ CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext(); auto pValue = std::make_unique<CFXJSE_Value>(pScriptContext->GetIsolate()); - ResolveNodeList(pValue.get(), runtime->ToWideString(params[0]), + ResolveNodeList(pScriptContext->GetIsolate(), pValue.get(), + runtime->ToWideString(params[0]), XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings, @@ -100,7 +102,8 @@ pValue->DirectGetValue().Get(runtime->GetIsolate())); } -void CJX_Tree::all(CFXJSE_Value* pValue, +void CJX_Tree::all(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { @@ -110,10 +113,11 @@ uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL; WideString wsExpression = GetAttributeByEnum(XFA_Attribute::Name) + L"[*]"; - ResolveNodeList(pValue, wsExpression, dwFlag, nullptr); + ResolveNodeList(pIsolate, pValue, wsExpression, dwFlag, nullptr); } -void CJX_Tree::classAll(CFXJSE_Value* pValue, +void CJX_Tree::classAll(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { @@ -123,11 +127,12 @@ WideString wsExpression = L"#" + WideString::FromASCII(GetXFAObject()->GetClassName()) + L"[*]"; - ResolveNodeList(pValue, wsExpression, + ResolveNodeList(pIsolate, pValue, wsExpression, XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL, nullptr); } -void CJX_Tree::nodes(CFXJSE_Value* pValue, +void CJX_Tree::nodes(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { @@ -142,10 +147,12 @@ pDoc->GetNodeOwner()->PersistList(pNodeList); CFXJSE_Engine* pEngine = pDoc->GetScriptContext(); - pValue->SetHostObject(pNodeList->JSObject(), pEngine->GetJseNormalClass()); + pValue->SetHostObject(pIsolate, pNodeList->JSObject(), + pEngine->GetJseNormalClass()); } -void CJX_Tree::parent(CFXJSE_Value* pValue, +void CJX_Tree::parent(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { @@ -155,15 +162,17 @@ CXFA_Node* pParent = GetXFANode()->GetParent(); if (!pParent) { - pValue->SetNull(); + pValue->SetNull(pIsolate); return; } pValue->Assign( + pIsolate, GetDocument()->GetScriptContext()->GetOrCreateJSBindingFromMap(pParent)); } -void CJX_Tree::index(CFXJSE_Value* pValue, +void CJX_Tree::index(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { @@ -173,10 +182,11 @@ CXFA_Node* pNode = GetXFANode(); size_t iIndex = pNode ? pNode->GetIndexByName() : 0; - pValue->SetInteger(pdfium::base::checked_cast<int32_t>(iIndex)); + pValue->SetInteger(pIsolate, pdfium::base::checked_cast<int32_t>(iIndex)); } -void CJX_Tree::classIndex(CFXJSE_Value* pValue, +void CJX_Tree::classIndex(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { @@ -186,10 +196,11 @@ CXFA_Node* pNode = GetXFANode(); size_t iIndex = pNode ? pNode->GetIndexByClassName() : 0; - pValue->SetInteger(pdfium::base::checked_cast<int32_t>(iIndex)); + pValue->SetInteger(pIsolate, pdfium::base::checked_cast<int32_t>(iIndex)); } -void CJX_Tree::somExpression(CFXJSE_Value* pValue, +void CJX_Tree::somExpression(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) { @@ -198,10 +209,11 @@ } WideString wsSOMExpression = GetXFAObject()->GetSOMExpression(); - pValue->SetString(wsSOMExpression.ToUTF8().AsStringView()); + pValue->SetString(pIsolate, wsSOMExpression.ToUTF8().AsStringView()); } -void CJX_Tree::ResolveNodeList(CFXJSE_Value* pValue, +void CJX_Tree::ResolveNodeList(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, WideString wsExpression, uint32_t dwFlag, CXFA_Node* refNode) { @@ -231,14 +243,15 @@ std::make_unique<CFXJSE_Value>(pScriptContext->GetIsolate()); CJX_Object* jsObject = pObject->JSObject(); (*resolveNodeRS.script_attribute.callback)( - jsObject, innerValue.get(), false, + pIsolate, jsObject, innerValue.get(), false, resolveNodeRS.script_attribute.attribute); - CXFA_Object* obj = CFXJSE_Engine::ToObject(innerValue.get()); + CXFA_Object* obj = CFXJSE_Engine::ToObject(pScriptContext->GetIsolate(), + innerValue.get()); if (obj->IsNode()) pNodeList->Append(obj->AsNode()); } } } - pValue->SetHostObject(pNodeList->JSObject(), + pValue->SetHostObject(pIsolate, pNodeList->JSObject(), pScriptContext->GetJseNormalClass()); }
diff --git a/fxjs/xfa/cjx_tree.h b/fxjs/xfa/cjx_tree.h index 54dd88d..ad117f3 100644 --- a/fxjs/xfa/cjx_tree.h +++ b/fxjs/xfa/cjx_tree.h
@@ -43,7 +43,8 @@ static const TypeTag static_type__ = TypeTag::Tree; static const CJX_MethodSpec MethodSpecs[]; - void ResolveNodeList(CFXJSE_Value* pValue, + void ResolveNodeList(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, WideString wsExpression, uint32_t dwFlag, CXFA_Node* refNode);
diff --git a/fxjs/xfa/cjx_xfa.cpp b/fxjs/xfa/cjx_xfa.cpp index 08c6a80..f107f76 100644 --- a/fxjs/xfa/cjx_xfa.cpp +++ b/fxjs/xfa/cjx_xfa.cpp
@@ -19,7 +19,8 @@ return eType == static_type__ || ParentType__::DynamicTypeIs(eType); } -void CJX_Xfa::thisValue(CFXJSE_Value* pValue, +void CJX_Xfa::thisValue(v8::Isolate* pIsolate, + CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { if (bSetting) @@ -28,8 +29,8 @@ auto* pScriptContext = GetDocument()->GetScriptContext(); CXFA_Object* pThis = pScriptContext->GetThisObject(); if (!pThis) { - pValue->SetNull(); + pValue->SetNull(pIsolate); return; } - pValue->Assign(pScriptContext->GetOrCreateJSBindingFromMap(pThis)); + pValue->Assign(pIsolate, pScriptContext->GetOrCreateJSBindingFromMap(pThis)); }
diff --git a/fxjs/xfa/fxjse.h b/fxjs/xfa/fxjse.h index 10750ef..5d70351 100644 --- a/fxjs/xfa/fxjse.h +++ b/fxjs/xfa/fxjse.h
@@ -50,10 +50,12 @@ typedef void (*FXJSE_FuncCallback)( CFXJSE_HostObject* pThis, const v8::FunctionCallbackInfo<v8::Value>& info); -typedef void (*FXJSE_PropAccessor)(CFXJSE_Value* pObject, +typedef void (*FXJSE_PropAccessor)(v8::Isolate* pIsolate, + CFXJSE_Value* pObject, ByteStringView szPropName, CFXJSE_Value* pValue); -typedef int32_t (*FXJSE_PropTypeGetter)(CFXJSE_Value* pObject, +typedef int32_t (*FXJSE_PropTypeGetter)(v8::Isolate* pIsolate, + CFXJSE_Value* pObject, ByteStringView szPropName, bool bQueryIn);
diff --git a/fxjs/xfa/jse_define.h b/fxjs/xfa/jse_define.h index 26405c9..328e0a0 100644 --- a/fxjs/xfa/jse_define.h +++ b/fxjs/xfa/jse_define.h
@@ -24,12 +24,15 @@ CJS_Result method_name(CFX_V8* runtime, \ const std::vector<v8::Local<v8::Value>>& params) -#define JSE_PROP(prop_name) \ - static void prop_name##_static(CJX_Object* node, CFXJSE_Value* value, \ - bool setting, XFA_Attribute attribute) { \ - if (node->DynamicTypeIs(static_type__)) \ - static_cast<Type__*>(node)->prop_name(value, setting, attribute); \ - } \ - void prop_name(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) +#define JSE_PROP(prop_name) \ + static void prop_name##_static(v8::Isolate* pIsolate, CJX_Object* node, \ + CFXJSE_Value* value, bool setting, \ + XFA_Attribute attribute) { \ + if (node->DynamicTypeIs(static_type__)) \ + static_cast<Type__*>(node)->prop_name(pIsolate, value, setting, \ + attribute); \ + } \ + void prop_name(v8::Isolate* pIsolate, CFXJSE_Value* pValue, bool bSetting, \ + XFA_Attribute eAttribute) #endif // FXJS_XFA_JSE_DEFINE_H_
diff --git a/testing/xfa_js_embedder_test.cpp b/testing/xfa_js_embedder_test.cpp index 2eb1947..4df2d05 100644 --- a/testing/xfa_js_embedder_test.cpp +++ b/testing/xfa_js_embedder_test.cpp
@@ -59,13 +59,13 @@ return true; CFXJSE_Value msg(isolate()); - value_->GetObjectPropertyByIdx(1, &msg); + value_->GetObjectPropertyByIdx(isolate(), 1, &msg); fprintf(stderr, "FormCalc: %.*s\n", static_cast<int>(input.GetLength()), input.unterminated_c_str()); // If the parsing of the input fails, then v8 will not run, so there will be // no value here to print. - if (msg.IsString() && !msg.ToWideString().IsEmpty()) - fprintf(stderr, "JS ERROR: %ls\n", msg.ToWideString().c_str()); + if (msg.IsString(isolate()) && !msg.ToWideString(isolate()).IsEmpty()) + fprintf(stderr, "JS ERROR: %ls\n", msg.ToWideString(isolate()).c_str()); return false; }
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index d2d1e63..51a34d1 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -2771,9 +2771,10 @@ iRet = XFA_EventError::kSuccess; if (pEventParam->m_eType == XFA_EVENT_Calculate || pEventParam->m_eType == XFA_EVENT_InitCalculate) { - if (!pTmpRetValue->IsUndefined()) { - if (!pTmpRetValue->IsNull()) - pEventParam->m_wsResult = pTmpRetValue->ToWideString(); + if (!pTmpRetValue->IsUndefined(pContext->GetIsolate())) { + if (!pTmpRetValue->IsNull(pContext->GetIsolate())) + pEventParam->m_wsResult = + pTmpRetValue->ToWideString(pContext->GetIsolate()); iRet = XFA_EventError::kSuccess; } else { @@ -2800,7 +2801,8 @@ pContext->SetNodesOfRunScript(nullptr); pContext->SetEventParam(nullptr); - return {iRet, pTmpRetValue->IsBoolean() && pTmpRetValue->ToBoolean()}; + return {iRet, pTmpRetValue->IsBoolean(pContext->GetIsolate()) && + pTmpRetValue->ToBoolean(pContext->GetIsolate())}; } std::pair<XFA_FFWidgetType, CXFA_Ui*>
diff --git a/xfa/fxfa/parser/xfa_basic_data.h b/xfa/fxfa/parser/xfa_basic_data.h index f342847..873d01c 100644 --- a/xfa/fxfa/parser/xfa_basic_data.h +++ b/xfa/fxfa/parser/xfa_basic_data.h
@@ -14,7 +14,8 @@ #include "third_party/base/optional.h" #include "xfa/fxfa/fxfa_basic.h" -typedef void (*XFA_ATTRIBUTE_CALLBACK)(CJX_Object* pNode, +typedef void (*XFA_ATTRIBUTE_CALLBACK)(v8::Isolate* pIsolate, + CJX_Object* pNode, CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute);