summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r--xfa/fxfa/parser/xfa_object_imp.cpp14
-rw-r--r--xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp12
-rw-r--r--xfa/fxfa/parser/xfa_script_imp.cpp42
3 files changed, 35 insertions, 33 deletions
diff --git a/xfa/fxfa/parser/xfa_object_imp.cpp b/xfa/fxfa/parser/xfa_object_imp.cpp
index d5a669340d..d3d076d302 100644
--- a/xfa/fxfa/parser/xfa_object_imp.cpp
+++ b/xfa/fxfa/parser/xfa_object_imp.cpp
@@ -104,7 +104,7 @@ void CXFA_Object::ThrowException(int32_t iStringID, ...) {
wsMessage.FormatV(wsFormat.c_str(), arg_ptr);
va_end(arg_ptr);
FXJSE_ThrowMessage(
- "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC());
+ FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC());
}
CXFA_Node::CXFA_Node(CXFA_Document* pDoc,
@@ -745,7 +745,6 @@ void CXFA_Node::Script_TreeClass_Nodes(CFXJSE_Value* pValue,
CFX_WideString wsMessage;
pAppProvider->LoadString(XFA_IDS_Unable_TO_SET, wsMessage);
FXJSE_ThrowMessage(
- "",
FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC());
} else {
CXFA_AttachNodeList* pNodeList = new CXFA_AttachNodeList(m_pDocument, this);
@@ -1620,7 +1619,7 @@ void CXFA_Node::Script_Som_DefaultValue(CFXJSE_Value* pValue,
}
if (bSetting) {
CFX_ByteString newValue;
- if (!(FXJSE_Value_IsNull(pValue) || FXJSE_Value_IsUndefined(pValue)))
+ if (!(pValue && (pValue->IsNull() || pValue->IsUndefined())))
pValue->ToString(newValue);
CFX_WideString wsNewValue = CFX_WideString::FromUTF8(newValue.AsStringC());
@@ -1688,7 +1687,7 @@ void CXFA_Node::Script_Boolean_Value(CFXJSE_Value* pValue,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
CFX_ByteString newValue;
- if (!(FXJSE_Value_IsNull(pValue) || FXJSE_Value_IsUndefined(pValue)))
+ if (!(pValue && (pValue->IsNull() || pValue->IsUndefined())))
pValue->ToString(newValue);
int32_t iValue = FXSYS_atoi(newValue.c_str());
@@ -1896,7 +1895,7 @@ void CXFA_Node::Script_Draw_DefaultValue(CFXJSE_Value* pValue,
FX_BOOL bSetting,
XFA_ATTRIBUTE eAttribute) {
if (bSetting) {
- if (FXJSE_Value_IsUTF8String(pValue)) {
+ if (pValue && pValue->IsString()) {
CXFA_WidgetData* pWidgetData = GetWidgetData();
ASSERT(pWidgetData);
XFA_ELEMENT uiType = pWidgetData->GetUIType();
@@ -1907,7 +1906,6 @@ void CXFA_Node::Script_Draw_DefaultValue(CFXJSE_Value* pValue,
CFX_WideString::FromUTF8(newValue.AsStringC());
CFX_WideString wsFormatValue(wsNewValue);
SetScriptContent(wsNewValue, wsFormatValue, true, TRUE);
- } else if (uiType != XFA_ELEMENT_Image) {
}
}
} else {
@@ -1928,7 +1926,7 @@ void CXFA_Node::Script_Field_DefaultValue(CFXJSE_Value* pValue,
return;
}
if (bSetting) {
- if (FXJSE_Value_IsNull(pValue)) {
+ if (pValue && pValue->IsNull()) {
pWidgetData->m_bPreNull = pWidgetData->m_bIsNull;
pWidgetData->m_bIsNull = TRUE;
} else {
@@ -1936,7 +1934,7 @@ void CXFA_Node::Script_Field_DefaultValue(CFXJSE_Value* pValue,
pWidgetData->m_bIsNull = FALSE;
}
CFX_ByteString newValue;
- if (!(FXJSE_Value_IsNull(pValue) || FXJSE_Value_IsUndefined(pValue)))
+ if (!(pValue && (pValue->IsNull() || pValue->IsUndefined())))
pValue->ToString(newValue);
CFX_WideString wsNewText = CFX_WideString::FromUTF8(newValue.AsStringC());
diff --git a/xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp b/xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp
index 990a86517f..1a3ef8f151 100644
--- a/xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp
+++ b/xfa/fxfa/parser/xfa_script_hostpseudomodel.cpp
@@ -311,9 +311,9 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_OpenList(
CXFA_Node* pNode = NULL;
if (iLength >= 1) {
std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0));
- if (FXJSE_Value_IsObject(pValue.get())) {
+ if (pValue->IsObject()) {
pNode = ToNode(pValue.get(), nullptr);
- } else if (FXJSE_Value_IsUTF8String(pValue.get())) {
+ } else if (pValue->IsString()) {
CFX_ByteString bsString;
pValue->ToString(bsString);
CFX_WideString wsExpression =
@@ -506,9 +506,9 @@ void CScript_HostPseudoModel::Script_HostPseudoModel_SetFocus(
CXFA_Node* pNode = NULL;
if (iLength >= 1) {
std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0));
- if (FXJSE_Value_IsObject(pValue.get())) {
+ if (pValue->IsObject()) {
pNode = ToNode(pValue.get(), nullptr);
- } else if (FXJSE_Value_IsUTF8String(pValue.get())) {
+ } else if (pValue->IsString()) {
CFX_ByteString bsString;
pValue->ToString(bsString);
CFX_WideString wsExpression =
@@ -606,11 +606,11 @@ FX_BOOL CScript_HostPseudoModel::Script_HostPseudoModel_ValidateArgsForMsg(
bIsJsType = TRUE;
}
std::unique_ptr<CFXJSE_Value> pValueArg(pArguments->GetValue(iArgIndex));
- if (!FXJSE_Value_IsUTF8String(pValueArg.get()) && bIsJsType) {
+ if (!pValueArg->IsString() && bIsJsType) {
ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
return FALSE;
}
- if (FXJSE_Value_IsNull(pValueArg.get())) {
+ if (pValueArg->IsNull()) {
wsValue = FX_WSTRC(L"");
} else {
CFX_ByteString byMessage;
diff --git a/xfa/fxfa/parser/xfa_script_imp.cpp b/xfa/fxfa/parser/xfa_script_imp.cpp
index e682c9ad85..245ea8bca4 100644
--- a/xfa/fxfa/parser/xfa_script_imp.cpp
+++ b/xfa/fxfa/parser/xfa_script_imp.cpp
@@ -18,6 +18,7 @@
#include "xfa/fxfa/parser/xfa_script_resolveprocessor.h"
#include "xfa/fxfa/parser/xfa_utils.h"
#include "xfa/fxjse/cfxjse_arguments.h"
+#include "xfa/fxjse/class.h"
#include "xfa/fxjse/value.h"
namespace {
@@ -104,11 +105,8 @@ CXFA_ScriptContext::~CXFA_ScriptContext() {
ReleaseVariablesMap();
delete m_hFM2JSContext;
+ delete m_pJsContext;
- if (m_pJsContext) {
- FXJSE_Context_Release(m_pJsContext);
- m_pJsContext = NULL;
- }
delete m_pResolveProcessor;
m_upObjectArray.RemoveAll();
for (int32_t i = 0; i < m_CacheListArray.GetSize(); i++)
@@ -149,7 +147,7 @@ FX_BOOL CXFA_ScriptContext::RunScript(XFA_SCRIPTLANGTYPE eScriptType,
m_pThisObject = pThisObject;
CFXJSE_Value* pValue = pThisObject ? GetJSValueFromMap(pThisObject) : NULL;
FX_BOOL bRet =
- FXJSE_ExecuteScript(m_pJsContext, btScript.c_str(), hRetValue, pValue);
+ m_pJsContext->ExecuteScript(btScript.c_str(), hRetValue, pValue);
m_pThisObject = pOriginalObject;
m_eScriptType = eSaveType;
return bRet;
@@ -174,7 +172,7 @@ void CXFA_ScriptContext::GlobalPropertySetter(CFXJSE_Value* pObject,
return;
}
if (lpOrginalNode->GetObjectType() == XFA_OBJECTTYPE_VariablesThis) {
- if (FXJSE_Value_IsUndefined(pValue)) {
+ if (pValue && pValue->IsUndefined()) {
pObject->SetObjectOwnProperty(szPropName, pValue);
return;
}
@@ -422,10 +420,10 @@ XFA_SCRIPTLANGTYPE CXFA_ScriptContext::GetType() {
return m_eScriptType;
}
void CXFA_ScriptContext::DefineJsContext() {
- m_pJsContext = FXJSE_Context_Create(m_pIsolate, &GlobalClassDescriptor,
- m_pDocument->GetRoot());
+ m_pJsContext = CFXJSE_Context::Create(m_pIsolate, &GlobalClassDescriptor,
+ m_pDocument->GetRoot());
RemoveBuiltInObjs(m_pJsContext);
- FXJSE_Context_EnableCompatibleMode(m_pJsContext);
+ m_pJsContext->EnableCompatibleMode();
}
CFXJSE_Context* CXFA_ScriptContext::CreateVariablesContext(
CXFA_Node* pScriptNode,
@@ -434,10 +432,10 @@ CFXJSE_Context* CXFA_ScriptContext::CreateVariablesContext(
return nullptr;
CFXJSE_Context* pVariablesContext =
- FXJSE_Context_Create(m_pIsolate, &VariablesClassDescriptor,
- new CXFA_ThisProxy(pSubform, pScriptNode));
+ CFXJSE_Context::Create(m_pIsolate, &VariablesClassDescriptor,
+ new CXFA_ThisProxy(pSubform, pScriptNode));
RemoveBuiltInObjs(pVariablesContext);
- FXJSE_Context_EnableCompatibleMode(pVariablesContext);
+ pVariablesContext->EnableCompatibleMode();
m_mapVariableToContext.SetAt(pScriptNode, pVariablesContext);
return pVariablesContext;
}
@@ -481,7 +479,7 @@ FX_BOOL CXFA_ScriptContext::RunVariablesScript(CXFA_Node* pScriptNode) {
CXFA_Object* pOriginalObject = m_pThisObject;
m_pThisObject = pThisObject;
FX_BOOL bRet =
- FXJSE_ExecuteScript(pVariablesContext, btScript.c_str(), hRetValue.get());
+ pVariablesContext->ExecuteScript(btScript.c_str(), hRetValue.get());
m_pThisObject = pOriginalObject;
return bRet;
}
@@ -505,14 +503,16 @@ FX_BOOL CXFA_ScriptContext::QueryVariableValue(
FX_BOOL bRes = FALSE;
CFXJSE_Context* pVariableContext = static_cast<CFXJSE_Context*>(lpVariables);
std::unique_ptr<CFXJSE_Value> pObject(
- FXJSE_Context_GetGlobalObject(pVariableContext));
+ new CFXJSE_Value(pVariableContext->GetRuntime()));
+ pVariableContext->GetGlobalObject(pObject.get());
+
std::unique_ptr<CFXJSE_Value> hVariableValue(new CFXJSE_Value(m_pIsolate));
if (!bGetter) {
pObject->SetObjectOwnProperty(szPropName, pValue);
bRes = TRUE;
} else if (pObject->HasObjectOwnProperty(szPropName, FALSE)) {
pObject->GetObjectProperty(szPropName, hVariableValue.get());
- if (FXJSE_Value_IsFunction(hVariableValue.get()))
+ if (hVariableValue->IsFunction())
pValue->SetFunctionBind(hVariableValue.get(), pObject.get());
else if (bGetter)
pValue->Assign(hVariableValue.get());
@@ -530,21 +530,25 @@ void CXFA_ScriptContext::ReleaseVariablesMap() {
CFXJSE_Context* pVariableContext = nullptr;
m_mapVariableToContext.GetNextAssoc(ps, pScriptNode, pVariableContext);
std::unique_ptr<CFXJSE_Value> pObject(
- FXJSE_Context_GetGlobalObject(pVariableContext));
+ new CFXJSE_Value(pVariableContext->GetRuntime()));
+ pVariableContext->GetGlobalObject(pObject.get());
+
delete ToThisProxy(pObject.get(), nullptr);
- FXJSE_Context_Release(pVariableContext);
+ delete pVariableContext;
}
m_mapVariableToContext.RemoveAll();
}
void CXFA_ScriptContext::DefineJsClass() {
- m_pJsClass = FXJSE_DefineClass(m_pJsContext, &NormalClassDescriptor);
+ m_pJsClass = CFXJSE_Class::Create(m_pJsContext, &NormalClassDescriptor);
}
void CXFA_ScriptContext::RemoveBuiltInObjs(CFXJSE_Context* pContext) const {
static const CFX_ByteStringC OBJ_NAME[2] = {"Number", "Date"};
std::unique_ptr<CFXJSE_Value> pObject(
- FXJSE_Context_GetGlobalObject(pContext));
+ new CFXJSE_Value(pContext->GetRuntime()));
+ pContext->GetGlobalObject(pObject.get());
+
std::unique_ptr<CFXJSE_Value> hProp(new CFXJSE_Value(m_pIsolate));
for (int i = 0; i < 2; ++i) {
if (pObject->GetObjectProperty(OBJ_NAME[i], hProp.get()))