summaryrefslogtreecommitdiff
path: root/fxjs/xfa
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-12-11 22:01:08 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-12-11 22:01:08 +0000
commitcb22f9ad9265f40b1104ed2b09488ccc6ec9e5aa (patch)
tree4aaa14dfb0528268fb9a9a94a4cac82df1af4602 /fxjs/xfa
parent731526e3b9f32ceac1cdac600fe3ecd55a0bc9b5 (diff)
downloadpdfium-cb22f9ad9265f40b1104ed2b09488ccc6ec9e5aa.tar.xz
[xfa] Refactor CJX method signatures.
This CL changes the CJX methods from void (*)(CFXJSE_Arguments*) to CJS_Return (*)(CJS_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) which is closer to how CJS works in practice. Change-Id: I3a3129268acfe4262dfeb04179919ed19f6c24e1 Reviewed-on: https://pdfium-review.googlesource.com/20491 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs/xfa')
-rw-r--r--fxjs/xfa/cjx_container.cpp18
-rw-r--r--fxjs/xfa/cjx_content.cpp1
-rw-r--r--fxjs/xfa/cjx_delta.cpp12
-rw-r--r--fxjs/xfa/cjx_desc.cpp16
-rw-r--r--fxjs/xfa/cjx_exclgroup.cpp116
-rw-r--r--fxjs/xfa/cjx_field.cpp281
-rw-r--r--fxjs/xfa/cjx_form.cpp110
-rw-r--r--fxjs/xfa/cjx_instancemanager.cpp171
-rw-r--r--fxjs/xfa/cjx_list.cpp91
-rw-r--r--fxjs/xfa/cjx_manifest.cpp20
-rw-r--r--fxjs/xfa/cjx_model.cpp101
-rw-r--r--fxjs/xfa/cjx_packet.cpp62
-rw-r--r--fxjs/xfa/cjx_source.cpp146
-rw-r--r--fxjs/xfa/cjx_subform.cpp74
-rw-r--r--fxjs/xfa/cjx_template.cpp84
-rw-r--r--fxjs/xfa/cjx_textnode.cpp1
-rw-r--r--fxjs/xfa/cjx_tree.cpp91
-rw-r--r--fxjs/xfa/cjx_treelist.cpp28
-rw-r--r--fxjs/xfa/cjx_wsdlconnection.cpp17
19 files changed, 718 insertions, 722 deletions
diff --git a/fxjs/xfa/cjx_container.cpp b/fxjs/xfa/cjx_container.cpp
index 517fb86f98..a5d7921090 100644
--- a/fxjs/xfa/cjx_container.cpp
+++ b/fxjs/xfa/cjx_container.cpp
@@ -6,7 +6,8 @@
#include "fxjs/xfa/cjx_container.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_engine.h"
#include "fxjs/cfxjse_value.h"
#include "xfa/fxfa/parser/cxfa_arraynodelist.h"
@@ -24,10 +25,17 @@ CJX_Container::CJX_Container(CXFA_Node* node) : CJX_Node(node) {
CJX_Container::~CJX_Container() {}
-void CJX_Container::getDelta(CFXJSE_Arguments* pArguments) {}
+CJS_Return CJX_Container::getDelta(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
+}
-void CJX_Container::getDeltas(CFXJSE_Arguments* pArguments) {
+CJS_Return CJX_Container::getDeltas(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(GetDocument());
- pArguments->GetReturnValue()->SetObject(
- pFormNodes, GetDocument()->GetScriptContext()->GetJseNormalClass());
+ return CJS_Return(runtime->NewXFAObject(
+ pFormNodes,
+ GetDocument()->GetScriptContext()->GetJseNormalClass()->GetTemplate()));
}
diff --git a/fxjs/xfa/cjx_content.cpp b/fxjs/xfa/cjx_content.cpp
index 87ddf63d86..dd25829a67 100644
--- a/fxjs/xfa/cjx_content.cpp
+++ b/fxjs/xfa/cjx_content.cpp
@@ -6,7 +6,6 @@
#include "fxjs/xfa/cjx_content.h"
-#include "fxjs/cfxjse_arguments.h"
#include "fxjs/cfxjse_value.h"
#include "xfa/fxfa/parser/cxfa_object.h"
diff --git a/fxjs/xfa/cjx_delta.cpp b/fxjs/xfa/cjx_delta.cpp
index b661ae9ffd..1dfad24319 100644
--- a/fxjs/xfa/cjx_delta.cpp
+++ b/fxjs/xfa/cjx_delta.cpp
@@ -6,8 +6,10 @@
#include "fxjs/xfa/cjx_delta.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/parser/cxfa_delta.h"
const CJX_MethodSpec CJX_Delta::MethodSpecs[] = {{"restore", restore_static},
@@ -19,7 +21,9 @@ CJX_Delta::CJX_Delta(CXFA_Delta* delta) : CJX_Object(delta) {
CJX_Delta::~CJX_Delta() {}
-void CJX_Delta::restore(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"restore");
+CJS_Return CJX_Delta::restore(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
diff --git a/fxjs/xfa/cjx_desc.cpp b/fxjs/xfa/cjx_desc.cpp
index 4efd1dde0e..7ff58a774a 100644
--- a/fxjs/xfa/cjx_desc.cpp
+++ b/fxjs/xfa/cjx_desc.cpp
@@ -6,8 +6,10 @@
#include "fxjs/xfa/cjx_desc.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/parser/cxfa_desc.h"
const CJX_MethodSpec CJX_Desc::MethodSpecs[] = {{"metadata", metadata_static},
@@ -19,11 +21,9 @@ CJX_Desc::CJX_Desc(CXFA_Desc* desc) : CJX_Node(desc) {
CJX_Desc::~CJX_Desc() {}
-void CJX_Desc::metadata(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 0 && argc != 1) {
- ThrowParamCountMismatchException(L"metadata");
- return;
- }
- pArguments->GetReturnValue()->SetString("");
+CJS_Return CJX_Desc::metadata(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 0 && params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(runtime->NewString(""));
}
diff --git a/fxjs/xfa/cjx_exclgroup.cpp b/fxjs/xfa/cjx_exclgroup.cpp
index c84ec94793..6317736ffa 100644
--- a/fxjs/xfa/cjx_exclgroup.cpp
+++ b/fxjs/xfa/cjx_exclgroup.cpp
@@ -6,9 +6,11 @@
#include "fxjs/xfa/cjx_exclgroup.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_engine.h"
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/cxfa_eventparam.h"
#include "xfa/fxfa/cxfa_ffnotify.h"
#include "xfa/fxfa/fxfa.h"
@@ -30,89 +32,79 @@ CJX_ExclGroup::CJX_ExclGroup(CXFA_ExclGroup* group) : CJX_Node(group) {
CJX_ExclGroup::~CJX_ExclGroup() {}
-void CJX_ExclGroup::execEvent(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"execEvent");
- return;
- }
+CJS_Return CJX_ExclGroup::execEvent(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- ByteString eventString = pArguments->GetUTF8String(0);
- execSingleEventByName(
- WideString::FromUTF8(eventString.AsStringView()).AsStringView(),
- XFA_Element::ExclGroup);
+ execSingleEventByName(runtime->ToWideString(params[0]).AsStringView(),
+ XFA_Element::ExclGroup);
+ return CJS_Return(true);
}
-void CJX_ExclGroup::execInitialize(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execInitialize");
- return;
- }
+CJS_Return CJX_ExclGroup::execInitialize(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify)
- return;
-
- pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize);
+ if (pNotify)
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize);
+ return CJS_Return(true);
}
-void CJX_ExclGroup::execCalculate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execCalculate");
- return;
- }
+CJS_Return CJX_ExclGroup::execCalculate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify)
- return;
-
- pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate);
+ if (pNotify)
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate);
+ return CJS_Return(true);
}
-void CJX_ExclGroup::execValidate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execValidate");
- return;
- }
+CJS_Return CJX_ExclGroup::execValidate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify) {
- pArguments->GetReturnValue()->SetBoolean(false);
- return;
- }
+ CXFA_FFNotify* notify = GetDocument()->GetNotify();
+ if (!notify)
+ return CJS_Return(runtime->NewBoolean(false));
- int32_t iRet =
- pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate);
- pArguments->GetReturnValue()->SetBoolean(
- (iRet == XFA_EVENTERROR_Error) ? false : true);
+ int32_t iRet = notify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate);
+ return CJS_Return(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error));
}
-void CJX_ExclGroup::selectedMember(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc < 0 || argc > 1) {
- ThrowParamCountMismatchException(L"selectedMember");
- return;
- }
+CJS_Return CJX_ExclGroup::selectedMember(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
- if (!pWidgetData) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
+ if (!pWidgetData)
+ return CJS_Return(runtime->NewNull());
CXFA_Node* pReturnNode = nullptr;
- if (argc == 0) {
+ if (params.empty()) {
pReturnNode = pWidgetData->GetSelectedMember();
} else {
- ByteString szName;
- szName = pArguments->GetUTF8String(0);
pReturnNode = pWidgetData->SetSelectedMember(
- WideString::FromUTF8(szName.AsStringView()).AsStringView(), true);
- }
- if (!pReturnNode) {
- pArguments->GetReturnValue()->SetNull();
- return;
+ runtime->ToWideString(params[0]).AsStringView(), true);
}
+ if (!pReturnNode)
+ return CJS_Return(runtime->NewNull());
+
+ CFXJSE_Value* value =
+ GetDocument()->GetScriptContext()->GetJSValueFromMap(pReturnNode);
+ if (!value)
+ return CJS_Return(runtime->NewNull());
- pArguments->GetReturnValue()->Assign(
- GetDocument()->GetScriptContext()->GetJSValueFromMap(pReturnNode));
+ return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
}
diff --git a/fxjs/xfa/cjx_field.cpp b/fxjs/xfa/cjx_field.cpp
index f0dbc78c78..d2cffbc983 100644
--- a/fxjs/xfa/cjx_field.cpp
+++ b/fxjs/xfa/cjx_field.cpp
@@ -6,8 +6,10 @@
#include "fxjs/xfa/cjx_field.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/cxfa_eventparam.h"
#include "xfa/fxfa/cxfa_ffnotify.h"
#include "xfa/fxfa/fxfa.h"
@@ -36,228 +38,199 @@ CJX_Field::CJX_Field(CXFA_Field* field) : CJX_Container(field) {
CJX_Field::~CJX_Field() {}
-void CJX_Field::clearItems(CFXJSE_Arguments* pArguments) {
+CJS_Return CJX_Field::clearItems(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
- if (!pWidgetData)
- return;
-
- pWidgetData->DeleteItem(-1, true, false);
+ if (pWidgetData)
+ pWidgetData->DeleteItem(-1, true, false);
+ return CJS_Return(true);
}
-void CJX_Field::execEvent(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"execEvent");
- return;
- }
+CJS_Return CJX_Field::execEvent(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- ByteString eventString = pArguments->GetUTF8String(0);
- int32_t iRet = execSingleEventByName(
- WideString::FromUTF8(eventString.AsStringView()).AsStringView(),
- XFA_Element::Field);
- if (eventString != "validate")
- return;
+ WideString eventString = runtime->ToWideString(params[0]);
+ int32_t iRet =
+ execSingleEventByName(eventString.AsStringView(), XFA_Element::Field);
+ if (eventString != L"validate")
+ return CJS_Return(true);
- pArguments->GetReturnValue()->SetBoolean(
- (iRet == XFA_EVENTERROR_Error) ? false : true);
+ return CJS_Return(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error));
}
-void CJX_Field::execInitialize(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execInitialize");
- return;
- }
+CJS_Return CJX_Field::execInitialize(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify)
- return;
-
- pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize, false,
- false);
+ if (pNotify) {
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize, false,
+ false);
+ }
+ return CJS_Return(true);
}
-void CJX_Field::deleteItem(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"deleteItem");
- return;
- }
+CJS_Return CJX_Field::deleteItem(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
if (!pWidgetData)
- return;
+ return CJS_Return(true);
- int32_t iIndex = pArguments->GetInt32(0);
- bool bValue = pWidgetData->DeleteItem(iIndex, true, true);
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (pValue)
- pValue->SetBoolean(bValue);
+ bool bValue =
+ pWidgetData->DeleteItem(runtime->ToInt32(params[0]), true, true);
+ return CJS_Return(runtime->NewBoolean(bValue));
}
-void CJX_Field::getSaveItem(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"getSaveItem");
- return;
- }
+CJS_Return CJX_Field::getSaveItem(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- int32_t iIndex = pArguments->GetInt32(0);
- if (iIndex < 0) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
+ int32_t iIndex = runtime->ToInt32(params[0]);
+ if (iIndex < 0)
+ return CJS_Return(runtime->NewNull());
CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
- if (!pWidgetData) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
+ if (!pWidgetData)
+ return CJS_Return(runtime->NewNull());
pdfium::Optional<WideString> value =
pWidgetData->GetChoiceListItem(iIndex, true);
- if (!value) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
- pArguments->GetReturnValue()->SetString(value->UTF8Encode().AsStringView());
+ if (!value)
+ return CJS_Return(runtime->NewNull());
+
+ return CJS_Return(runtime->NewString(value->UTF8Encode().AsStringView()));
}
-void CJX_Field::boundItem(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"boundItem");
- return;
- }
+CJS_Return CJX_Field::boundItem(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
if (!pWidgetData)
- return;
-
- ByteString bsValue = pArguments->GetUTF8String(0);
- WideString wsValue = WideString::FromUTF8(bsValue.AsStringView());
- WideString wsBoundValue = pWidgetData->GetItemValue(wsValue.AsStringView());
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (pValue)
- pValue->SetString(wsBoundValue.UTF8Encode().AsStringView());
+ return CJS_Return(true);
+
+ WideString value = runtime->ToWideString(params[0]);
+ WideString boundValue = pWidgetData->GetItemValue(value.AsStringView());
+ return CJS_Return(runtime->NewString(boundValue.UTF8Encode().AsStringView()));
}
-void CJX_Field::getItemState(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"getItemState");
- return;
- }
+CJS_Return CJX_Field::getItemState(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
if (!pWidgetData)
- return;
+ return CJS_Return(true);
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (pValue)
- pValue->SetBoolean(pWidgetData->GetItemState(pArguments->GetInt32(0)));
+ int32_t state = pWidgetData->GetItemState(runtime->ToInt32(params[0]));
+ return CJS_Return(runtime->NewBoolean(state != 0));
}
-void CJX_Field::execCalculate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execCalculate");
- return;
- }
+CJS_Return CJX_Field::execCalculate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify)
- return;
-
- pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate, false,
- false);
+ if (pNotify) {
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate, false,
+ false);
+ }
+ return CJS_Return(true);
}
-void CJX_Field::getDisplayItem(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"getDisplayItem");
- return;
- }
+CJS_Return CJX_Field::getDisplayItem(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- int32_t iIndex = pArguments->GetInt32(0);
- if (iIndex < 0) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
+ int32_t iIndex = runtime->ToInt32(params[0]);
+ if (iIndex < 0)
+ return CJS_Return(runtime->NewNull());
CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
- if (!pWidgetData) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
+ if (!pWidgetData)
+ return CJS_Return(runtime->NewNull());
pdfium::Optional<WideString> value =
pWidgetData->GetChoiceListItem(iIndex, false);
- if (!value) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
- pArguments->GetReturnValue()->SetString(value->UTF8Encode().AsStringView());
+ if (!value)
+ return CJS_Return(runtime->NewNull());
+
+ return CJS_Return(runtime->NewString(value->UTF8Encode().AsStringView()));
}
-void CJX_Field::setItemState(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 2) {
- ThrowParamCountMismatchException(L"setItemState");
- return;
- }
+CJS_Return CJX_Field::setItemState(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 2)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
if (!pWidgetData)
- return;
+ return CJS_Return(true);
- int32_t iIndex = pArguments->GetInt32(0);
- if (pArguments->GetInt32(1) != 0) {
+ int32_t iIndex = runtime->ToInt32(params[0]);
+ if (runtime->ToInt32(params[1]) != 0) {
pWidgetData->SetItemState(iIndex, true, true, true, true);
- return;
+ return CJS_Return(true);
}
-
if (pWidgetData->GetItemState(iIndex))
pWidgetData->SetItemState(iIndex, false, true, true, true);
+
+ return CJS_Return(true);
}
-void CJX_Field::addItem(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 1 || iLength > 2) {
- ThrowParamCountMismatchException(L"addItem");
- return;
- }
+CJS_Return CJX_Field::addItem(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1 && params.size() != 2)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
if (!pWidgetData)
- return;
+ return CJS_Return(true);
- WideString wsLabel;
- if (iLength >= 1) {
- ByteString bsLabel = pArguments->GetUTF8String(0);
- wsLabel = WideString::FromUTF8(bsLabel.AsStringView());
- }
+ WideString label;
+ if (params.size() >= 1)
+ label = runtime->ToWideString(params[0]);
- WideString wsValue;
- if (iLength >= 2) {
- ByteString bsValue = pArguments->GetUTF8String(1);
- wsValue = WideString::FromUTF8(bsValue.AsStringView());
- }
+ WideString value;
+ if (params.size() >= 2)
+ value = runtime->ToWideString(params[1]);
- pWidgetData->InsertItem(wsLabel, wsValue, true);
+ pWidgetData->InsertItem(label, value, true);
+ return CJS_Return(true);
}
-void CJX_Field::execValidate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execValidate");
- return;
- }
+CJS_Return CJX_Field::execValidate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify) {
- pArguments->GetReturnValue()->SetBoolean(false);
- return;
- }
+ if (!pNotify)
+ return CJS_Return(runtime->NewBoolean(false));
int32_t iRet = pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate,
false, false);
- pArguments->GetReturnValue()->SetBoolean(
- (iRet == XFA_EVENTERROR_Error) ? false : true);
+ return CJS_Return(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error));
}
diff --git a/fxjs/xfa/cjx_form.cpp b/fxjs/xfa/cjx_form.cpp
index 106910c6c1..22a7db2135 100644
--- a/fxjs/xfa/cjx_form.cpp
+++ b/fxjs/xfa/cjx_form.cpp
@@ -8,9 +8,9 @@
#include <vector>
-#include "fxjs/cfxjse_arguments.h"
#include "fxjs/cfxjse_engine.h"
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/cxfa_eventparam.h"
#include "xfa/fxfa/cxfa_ffnotify.h"
#include "xfa/fxfa/parser/cxfa_arraynodelist.h"
@@ -32,97 +32,93 @@ CJX_Form::CJX_Form(CXFA_Form* form) : CJX_Model(form) {
CJX_Form::~CJX_Form() {}
-void CJX_Form::formNodes(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"formNodes");
- return;
- }
+CJS_Return CJX_Form::formNodes(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- CXFA_Node* pDataNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
- if (!pDataNode) {
- ThrowArgumentMismatchException();
- return;
- }
+ CXFA_Node* pDataNode = ToNode(runtime->ToXFAObject(params[0]));
+ if (!pDataNode)
+ return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
std::vector<CXFA_Node*> formItems;
CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(GetDocument());
pFormNodes->SetArrayNodeList(formItems);
- pArguments->GetReturnValue()->SetObject(
- pFormNodes, GetDocument()->GetScriptContext()->GetJseNormalClass());
+
+ CFXJSE_Value* value =
+ GetDocument()->GetScriptContext()->GetJSValueFromMap(pFormNodes);
+ if (!value)
+ return CJS_Return(runtime->NewNull());
+ return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
}
-void CJX_Form::remerge(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"remerge");
- return;
- }
+CJS_Return CJX_Form::remerge(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
GetDocument()->DoDataRemerge(true);
+ return CJS_Return(true);
}
-void CJX_Form::execInitialize(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execInitialize");
- return;
- }
+CJS_Return CJX_Form::execInitialize(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify)
- return;
-
- pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize);
+ if (pNotify)
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize);
+ return CJS_Return(true);
}
-void CJX_Form::recalculate(CFXJSE_Arguments* pArguments) {
+CJS_Return CJX_Form::recalculate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
CXFA_EventParam* pEventParam =
GetDocument()->GetScriptContext()->GetEventParam();
if (pEventParam->m_eType == XFA_EVENT_Calculate ||
pEventParam->m_eType == XFA_EVENT_InitCalculate) {
- return;
- }
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"recalculate");
- return;
+ return CJS_Return(true);
}
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify)
- return;
- if (pArguments->GetInt32(0) != 0)
- return;
+ if (!pNotify || runtime->ToInt32(params[0]) != 0)
+ return CJS_Return(true);
pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate);
pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate);
pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Ready, true);
+ return CJS_Return(true);
}
-void CJX_Form::execCalculate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execCalculate");
- return;
- }
+CJS_Return CJX_Form::execCalculate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify)
- return;
-
- pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate);
+ if (pNotify)
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate);
+ return CJS_Return(true);
}
-void CJX_Form::execValidate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execValidate");
- return;
- }
+CJS_Return CJX_Form::execValidate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 0)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify) {
- pArguments->GetReturnValue()->SetBoolean(false);
- return;
- }
+ if (!pNotify)
+ return CJS_Return(runtime->NewBoolean(false));
int32_t iRet =
pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate);
- pArguments->GetReturnValue()->SetBoolean(
- (iRet == XFA_EVENTERROR_Error) ? false : true);
+ return CJS_Return(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error));
}
diff --git a/fxjs/xfa/cjx_instancemanager.cpp b/fxjs/xfa/cjx_instancemanager.cpp
index da8422ea35..19c6d72cc3 100644
--- a/fxjs/xfa/cjx_instancemanager.cpp
+++ b/fxjs/xfa/cjx_instancemanager.cpp
@@ -6,9 +6,11 @@
#include "fxjs/xfa/cjx_instancemanager.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_engine.h"
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/cxfa_ffnotify.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_instancemanager.h"
@@ -30,18 +32,19 @@ CJX_InstanceManager::CJX_InstanceManager(CXFA_InstanceManager* mgr)
CJX_InstanceManager::~CJX_InstanceManager() {}
-void CJX_InstanceManager::moveInstance(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 2) {
- pArguments->GetReturnValue()->SetUndefined();
- return;
- }
+CJS_Return CJX_InstanceManager::moveInstance(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 2)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- int32_t iFrom = pArguments->GetInt32(0);
- int32_t iTo = pArguments->GetInt32(1);
+ int32_t iFrom = runtime->ToInt32(params[0]);
+ int32_t iTo = runtime->ToInt32(params[1]);
InstanceManager_MoveInstance(iTo, iFrom);
+
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return;
+ return CJS_Return(true);
CXFA_Node* pToInstance = GetXFANode()->GetItem(iTo);
if (pToInstance && pToInstance->GetElementType() == XFA_Element::Subform)
@@ -52,29 +55,28 @@ void CJX_InstanceManager::moveInstance(CFXJSE_Arguments* pArguments) {
pFromInstance->GetElementType() == XFA_Element::Subform) {
pNotify->RunSubformIndexChange(pFromInstance);
}
+
+ return CJS_Return(true);
}
-void CJX_InstanceManager::removeInstance(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- pArguments->GetReturnValue()->SetUndefined();
- return;
- }
+CJS_Return CJX_InstanceManager::removeInstance(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- int32_t iIndex = pArguments->GetInt32(0);
+ int32_t iIndex = runtime->ToInt32(params[0]);
int32_t iCount = GetXFANode()->GetCount();
- if (iIndex < 0 || iIndex >= iCount) {
- ThrowIndexOutOfBoundsException();
- return;
- }
+ if (iIndex < 0 || iIndex >= iCount)
+ return CJS_Return(JSGetStringFromID(JSMessage::kInvalidInputError));
int32_t iMin = CXFA_OccurData(GetXFANode()->GetOccurNode()).GetMin();
- if (iCount - 1 < iMin) {
- ThrowTooManyOccurancesException(L"min");
- return;
- }
+ if (iCount - 1 < iMin)
+ return CJS_Return(JSGetStringFromID(JSMessage::kTooManyOccurances));
CXFA_Node* pRemoveInstance = GetXFANode()->GetItem(iIndex);
GetXFANode()->RemoveItem(pRemoveInstance, true);
+
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (pNotify) {
for (int32_t i = iIndex; i < iCount - 1; i++) {
@@ -86,95 +88,96 @@ void CJX_InstanceManager::removeInstance(CFXJSE_Arguments* pArguments) {
}
}
CXFA_LayoutProcessor* pLayoutPro = GetDocument()->GetLayoutProcessor();
- if (!pLayoutPro)
- return;
-
- pLayoutPro->AddChangedContainer(
- ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
+ if (pLayoutPro) {
+ pLayoutPro->AddChangedContainer(
+ ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
+ }
+ return CJS_Return(true);
}
-void CJX_InstanceManager::setInstances(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- pArguments->GetReturnValue()->SetUndefined();
- return;
- }
+CJS_Return CJX_InstanceManager::setInstances(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- int32_t iDesired = pArguments->GetInt32(0);
- InstanceManager_SetInstances(iDesired);
+ InstanceManager_SetInstances(runtime->ToInt32(params[0]));
+ return CJS_Return(true);
}
-void CJX_InstanceManager::addInstance(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 0 && argc != 1) {
- ThrowParamCountMismatchException(L"addInstance");
- return;
- }
+CJS_Return CJX_InstanceManager::addInstance(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty() && params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
bool fFlags = true;
- if (argc == 1)
- fFlags = pArguments->GetInt32(0) == 0 ? false : true;
+ if (params.size() == 1)
+ fFlags = runtime->ToBoolean(params[0]);
int32_t iCount = GetXFANode()->GetCount();
int32_t iMax = CXFA_OccurData(GetXFANode()->GetOccurNode()).GetMax();
- if (iMax >= 0 && iCount >= iMax) {
- ThrowTooManyOccurancesException(L"max");
- return;
- }
+ if (iMax >= 0 && iCount >= iMax)
+ return CJS_Return(JSGetStringFromID(JSMessage::kTooManyOccurances));
CXFA_Node* pNewInstance = GetXFANode()->CreateInstance(fFlags);
GetXFANode()->InsertItem(pNewInstance, iCount, iCount, false);
- pArguments->GetReturnValue()->Assign(
- GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewInstance));
+
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify)
- return;
+ if (pNotify) {
+ pNotify->RunNodeInitialize(pNewInstance);
- pNotify->RunNodeInitialize(pNewInstance);
- CXFA_LayoutProcessor* pLayoutPro = GetDocument()->GetLayoutProcessor();
- if (!pLayoutPro)
- return;
+ CXFA_LayoutProcessor* pLayoutPro = GetDocument()->GetLayoutProcessor();
+ if (pLayoutPro) {
+ pLayoutPro->AddChangedContainer(
+ ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
+ }
+ }
- pLayoutPro->AddChangedContainer(
- ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
+ CFXJSE_Value* value =
+ GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewInstance);
+ if (!value)
+ return CJS_Return(runtime->NewNull());
+
+ return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
}
-void CJX_InstanceManager::insertInstance(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 1 && argc != 2) {
- ThrowParamCountMismatchException(L"insertInstance");
- return;
- }
+CJS_Return CJX_InstanceManager::insertInstance(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1 && params.size() != 2)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- int32_t iIndex = pArguments->GetInt32(0);
+ int32_t iIndex = runtime->ToInt32(params[0]);
bool bBind = false;
- if (argc == 2)
- bBind = pArguments->GetInt32(1) == 0 ? false : true;
+ if (params.size() == 2)
+ bBind = runtime->ToBoolean(params[1]);
int32_t iCount = GetXFANode()->GetCount();
- if (iIndex < 0 || iIndex > iCount) {
- ThrowIndexOutOfBoundsException();
- return;
- }
+ if (iIndex < 0 || iIndex > iCount)
+ return CJS_Return(JSGetStringFromID(JSMessage::kInvalidInputError));
int32_t iMax = CXFA_OccurData(GetXFANode()->GetOccurNode()).GetMax();
- if (iMax >= 0 && iCount >= iMax) {
- ThrowTooManyOccurancesException(L"max");
- return;
- }
+ if (iMax >= 0 && iCount >= iMax)
+ return CJS_Return(JSGetStringFromID(JSMessage::kInvalidInputError));
CXFA_Node* pNewInstance = GetXFANode()->CreateInstance(bBind);
GetXFANode()->InsertItem(pNewInstance, iIndex, iCount, true);
- pArguments->GetReturnValue()->Assign(
- GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewInstance));
+
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify)
- return;
+ if (pNotify) {
+ pNotify->RunNodeInitialize(pNewInstance);
+ CXFA_LayoutProcessor* pLayoutPro = GetDocument()->GetLayoutProcessor();
+ if (pLayoutPro) {
+ pLayoutPro->AddChangedContainer(
+ ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
+ }
+ }
- pNotify->RunNodeInitialize(pNewInstance);
- CXFA_LayoutProcessor* pLayoutPro = GetDocument()->GetLayoutProcessor();
- if (!pLayoutPro)
- return;
+ CFXJSE_Value* value =
+ GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewInstance);
+ if (!value)
+ return CJS_Return(runtime->NewNull());
- pLayoutPro->AddChangedContainer(
- ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
+ return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
}
diff --git a/fxjs/xfa/cjx_list.cpp b/fxjs/xfa/cjx_list.cpp
index 34cf9da7a5..84bdf7bd07 100644
--- a/fxjs/xfa/cjx_list.cpp
+++ b/fxjs/xfa/cjx_list.cpp
@@ -6,9 +6,11 @@
#include "fxjs/xfa/cjx_list.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_engine.h"
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_list.h"
#include "xfa/fxfa/parser/cxfa_node.h"
@@ -29,67 +31,58 @@ CXFA_List* CJX_List::GetXFAList() {
return static_cast<CXFA_List*>(GetXFAObject());
}
-void CJX_List::append(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 1) {
- ThrowParamCountMismatchException(L"append");
- return;
- }
+CJS_Return CJX_List::append(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+
+ auto* pNode = ToNode(runtime->ToXFAObject(params[0]));
+ if (!pNode)
+ return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
- auto* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
- if (!pNode) {
- ThrowArgumentMismatchException();
- return;
- }
GetXFAList()->Append(pNode);
+ return CJS_Return(true);
}
-void CJX_List::insert(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 2) {
- ThrowParamCountMismatchException(L"insert");
- return;
- }
+CJS_Return CJX_List::insert(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 2)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- auto* pNewNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
- auto* pBeforeNode = static_cast<CXFA_Node*>(pArguments->GetObject(1));
- if (!pNewNode) {
- ThrowArgumentMismatchException();
- return;
- }
+ auto* pNewNode = ToNode(runtime->ToXFAObject(params[0]));
+ if (!pNewNode)
+ return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
+
+ auto* pBeforeNode = ToNode(runtime->ToXFAObject(params[1]));
GetXFAList()->Insert(pNewNode, pBeforeNode);
+ return CJS_Return(true);
}
-void CJX_List::remove(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 1) {
- ThrowParamCountMismatchException(L"remove");
- return;
- }
+CJS_Return CJX_List::remove(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+
+ auto* pNode = ToNode(runtime->ToXFAObject(params[0]));
+ if (!pNode)
+ return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
- auto* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
- if (!pNode) {
- ThrowArgumentMismatchException();
- return;
- }
GetXFAList()->Remove(pNode);
+ return CJS_Return(true);
}
-void CJX_List::item(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 1) {
- ThrowParamCountMismatchException(L"item");
- return;
- }
+CJS_Return CJX_List::item(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- int32_t iIndex = pArguments->GetInt32(0);
- if (iIndex < 0 || iIndex >= GetXFAList()->GetLength()) {
- ThrowIndexOutOfBoundsException();
- return;
- }
- pArguments->GetReturnValue()->Assign(
- GetDocument()->GetScriptContext()->GetJSValueFromMap(
- GetXFAList()->Item(iIndex)));
+ int32_t iIndex = runtime->ToInt32(params[0]);
+ if (iIndex < 0 || iIndex >= GetXFAList()->GetLength())
+ return CJS_Return(JSGetStringFromID(JSMessage::kInvalidInputError));
+
+ return CJS_Return(runtime->NewXFAObject(
+ GetXFAList()->Item(iIndex),
+ GetDocument()->GetScriptContext()->GetJseNormalClass()->GetTemplate()));
}
void CJX_List::length(CFXJSE_Value* pValue,
diff --git a/fxjs/xfa/cjx_manifest.cpp b/fxjs/xfa/cjx_manifest.cpp
index 066ba29e15..6d5da2c60e 100644
--- a/fxjs/xfa/cjx_manifest.cpp
+++ b/fxjs/xfa/cjx_manifest.cpp
@@ -6,8 +6,10 @@
#include "fxjs/xfa/cjx_manifest.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/parser/cxfa_manifest.h"
const CJX_MethodSpec CJX_Manifest::MethodSpecs[] = {
@@ -20,16 +22,12 @@ CJX_Manifest::CJX_Manifest(CXFA_Manifest* manifest) : CJX_Node(manifest) {
CJX_Manifest::~CJX_Manifest() {}
-void CJX_Manifest::evaluate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"evaluate");
- return;
- }
+CJS_Return CJX_Manifest::evaluate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
- if (!pWidgetData) {
- pArguments->GetReturnValue()->SetBoolean(false);
- return;
- }
- pArguments->GetReturnValue()->SetBoolean(true);
+ return CJS_Return(runtime->NewBoolean(!!pWidgetData));
}
diff --git a/fxjs/xfa/cjx_model.cpp b/fxjs/xfa/cjx_model.cpp
index cd738b0018..65084162fb 100644
--- a/fxjs/xfa/cjx_model.cpp
+++ b/fxjs/xfa/cjx_model.cpp
@@ -6,9 +6,11 @@
#include "fxjs/xfa/cjx_model.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_engine.h"
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/parser/cxfa_delta.h"
#include "xfa/fxfa/parser/cxfa_document.h"
@@ -24,71 +26,60 @@ CJX_Model::CJX_Model(CXFA_Node* node) : CJX_Node(node) {
CJX_Model::~CJX_Model() {}
-void CJX_Model::clearErrorList(CFXJSE_Arguments* pArguments) {}
+CJS_Return CJX_Model::clearErrorList(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
+}
-void CJX_Model::createNode(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc <= 0 || argc >= 4) {
- ThrowParamCountMismatchException(L"createNode");
- return;
- }
+CJS_Return CJX_Model::createNode(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.empty() || params.size() > 3)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- WideString strName;
- WideString strNameSpace;
- if (argc > 1) {
- ByteString bsName = pArguments->GetUTF8String(1);
- strName = WideString::FromUTF8(bsName.AsStringView());
- if (argc == 3) {
- ByteString bsNameSpace = pArguments->GetUTF8String(2);
- strNameSpace = WideString::FromUTF8(bsNameSpace.AsStringView());
- }
- }
+ WideString name;
+ if (params.size() > 1)
+ name = runtime->ToWideString(params[1]);
+
+ WideString nameSpace;
+ if (params.size() == 3)
+ nameSpace = runtime->ToWideString(params[2]);
- ByteString bsTagName = pArguments->GetUTF8String(0);
- WideString strTagName = WideString::FromUTF8(bsTagName.AsStringView());
- XFA_Element eType = CXFA_Node::NameToElement(strTagName);
+ WideString tagName = runtime->ToWideString(params[0]);
+ XFA_Element eType = CXFA_Node::NameToElement(tagName);
CXFA_Node* pNewNode = GetXFANode()->CreateSamePacketNode(eType);
- if (!pNewNode) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
+ if (!pNewNode)
+ return CJS_Return(runtime->NewNull());
- if (strName.IsEmpty()) {
- pArguments->GetReturnValue()->Assign(
- GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewNode));
- return;
- }
+ if (!name.IsEmpty()) {
+ if (!pNewNode->HasAttribute(XFA_Attribute::Name))
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- if (!pNewNode->HasAttribute(XFA_Attribute::Name)) {
- ThrowMissingPropertyException(strTagName, L"name");
- return;
+ pNewNode->JSNode()->SetAttribute(XFA_Attribute::Name, name.AsStringView(),
+ true);
+ if (pNewNode->GetPacketType() == XFA_PacketType::Datasets)
+ pNewNode->CreateXMLMappingNode();
}
- pNewNode->JSNode()->SetAttribute(XFA_Attribute::Name, strName.AsStringView(),
- true);
- if (pNewNode->GetPacketType() == XFA_PacketType::Datasets)
- pNewNode->CreateXMLMappingNode();
+ CFXJSE_Value* value =
+ GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewNode);
+ if (!value)
+ return CJS_Return(runtime->NewNull());
- pArguments->GetReturnValue()->Assign(
- GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewNode));
+ return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
}
-void CJX_Model::isCompatibleNS(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 1) {
- ThrowParamCountMismatchException(L"isCompatibleNS");
- return;
- }
-
- WideString wsNameSpace;
- if (iLength >= 1) {
- ByteString bsNameSpace = pArguments->GetUTF8String(0);
- wsNameSpace = WideString::FromUTF8(bsNameSpace.AsStringView());
- }
+CJS_Return CJX_Model::isCompatibleNS(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (!pValue)
- return;
+ WideString nameSpace;
+ if (params.size() >= 1)
+ nameSpace = runtime->ToWideString(params[0]);
- pValue->SetBoolean(TryNamespace().value_or(WideString()) == wsNameSpace);
+ return CJS_Return(
+ runtime->NewBoolean(TryNamespace().value_or(WideString()) == nameSpace));
}
diff --git a/fxjs/xfa/cjx_packet.cpp b/fxjs/xfa/cjx_packet.cpp
index b1424d27e7..0040951ac3 100644
--- a/fxjs/xfa/cjx_packet.cpp
+++ b/fxjs/xfa/cjx_packet.cpp
@@ -6,8 +6,10 @@
#include "fxjs/xfa/cjx_packet.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/parser/cxfa_packet.h"
const CJX_MethodSpec CJX_Packet::MethodSpecs[] = {
@@ -22,54 +24,48 @@ CJX_Packet::CJX_Packet(CXFA_Packet* packet) : CJX_Node(packet) {
CJX_Packet::~CJX_Packet() {}
-void CJX_Packet::getAttribute(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"getAttribute");
- return;
- }
+CJS_Return CJX_Packet::getAttribute(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- WideString wsAttributeValue;
+ WideString attributeValue;
CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode();
if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) {
- ByteString bsAttributeName = pArguments->GetUTF8String(0);
- wsAttributeValue = static_cast<CFX_XMLElement*>(pXMLNode)->GetString(
- WideString::FromUTF8(bsAttributeName.AsStringView()).c_str());
+ attributeValue = static_cast<CFX_XMLElement*>(pXMLNode)->GetString(
+ runtime->ToWideString(params[0]).c_str());
}
-
- pArguments->GetReturnValue()->SetString(
- wsAttributeValue.UTF8Encode().AsStringView());
+ return CJS_Return(
+ runtime->NewString(attributeValue.UTF8Encode().AsStringView()));
}
-void CJX_Packet::setAttribute(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 2) {
- ThrowParamCountMismatchException(L"setAttribute");
- return;
- }
+CJS_Return CJX_Packet::setAttribute(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 2)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode();
if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) {
- ByteString bsValue = pArguments->GetUTF8String(0);
- ByteString bsName = pArguments->GetUTF8String(1);
static_cast<CFX_XMLElement*>(pXMLNode)->SetString(
- WideString::FromUTF8(bsName.AsStringView()),
- WideString::FromUTF8(bsValue.AsStringView()));
+ runtime->ToWideString(params[1]), runtime->ToWideString(params[0]));
}
- pArguments->GetReturnValue()->SetNull();
+ return CJS_Return(runtime->NewNull());
}
-void CJX_Packet::removeAttribute(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"removeAttribute");
- return;
- }
+CJS_Return CJX_Packet::removeAttribute(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode();
if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) {
- ByteString bsName = pArguments->GetUTF8String(0);
- WideString wsName = WideString::FromUTF8(bsName.AsStringView());
+ WideString name = runtime->ToWideString(params[0]);
CFX_XMLElement* pXMLElement = static_cast<CFX_XMLElement*>(pXMLNode);
- if (pXMLElement->HasAttribute(wsName.c_str()))
- pXMLElement->RemoveAttribute(wsName.c_str());
+ if (pXMLElement->HasAttribute(name.c_str()))
+ pXMLElement->RemoveAttribute(name.c_str());
}
- pArguments->GetReturnValue()->SetNull();
+ return CJS_Return(runtime->NewNull());
}
diff --git a/fxjs/xfa/cjx_source.cpp b/fxjs/xfa/cjx_source.cpp
index 3197231811..17512b3e63 100644
--- a/fxjs/xfa/cjx_source.cpp
+++ b/fxjs/xfa/cjx_source.cpp
@@ -6,8 +6,10 @@
#include "fxjs/xfa/cjx_source.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/parser/cxfa_source.h"
const CJX_MethodSpec CJX_Source::MethodSpecs[] = {
@@ -36,87 +38,127 @@ CJX_Source::CJX_Source(CXFA_Source* src) : CJX_Node(src) {
CJX_Source::~CJX_Source() {}
-void CJX_Source::next(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"next");
+CJS_Return CJX_Source::next(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::cancelBatch(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"cancelBatch");
+CJS_Return CJX_Source::cancelBatch(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::first(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"first");
+CJS_Return CJX_Source::first(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::updateBatch(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"updateBatch");
+CJS_Return CJX_Source::updateBatch(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::previous(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"previous");
+CJS_Return CJX_Source::previous(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::isBOF(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"isBOF");
+CJS_Return CJX_Source::isBOF(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::isEOF(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"isEOF");
+CJS_Return CJX_Source::isEOF(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::cancel(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"cancel");
+CJS_Return CJX_Source::cancel(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::update(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"update");
+CJS_Return CJX_Source::update(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::open(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"open");
+CJS_Return CJX_Source::open(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::deleteItem(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"delete");
+CJS_Return CJX_Source::deleteItem(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::addNew(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"addNew");
+CJS_Return CJX_Source::addNew(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::requery(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"requery");
+CJS_Return CJX_Source::requery(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::resync(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"resync");
+CJS_Return CJX_Source::resync(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::close(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"close");
+CJS_Return CJX_Source::close(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::last(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"last");
+CJS_Return CJX_Source::last(CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
-void CJX_Source::hasDataChanged(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"hasDataChanged");
+CJS_Return CJX_Source::hasDataChanged(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(true);
}
diff --git a/fxjs/xfa/cjx_subform.cpp b/fxjs/xfa/cjx_subform.cpp
index 32de182e7b..a7e1d2a587 100644
--- a/fxjs/xfa/cjx_subform.cpp
+++ b/fxjs/xfa/cjx_subform.cpp
@@ -6,8 +6,10 @@
#include "fxjs/xfa/cjx_subform.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/cxfa_eventparam.h"
#include "xfa/fxfa/cxfa_ffnotify.h"
#include "xfa/fxfa/fxfa.h"
@@ -27,58 +29,52 @@ CJX_Subform::CJX_Subform(CXFA_Node* node) : CJX_Container(node) {
CJX_Subform::~CJX_Subform() {}
-void CJX_Subform::execEvent(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"execEvent");
- return;
- }
+CJS_Return CJX_Subform::execEvent(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- ByteString eventString = pArguments->GetUTF8String(0);
- execSingleEventByName(
- WideString::FromUTF8(eventString.AsStringView()).AsStringView(),
- XFA_Element::Subform);
+ execSingleEventByName(runtime->ToWideString(params[0]).AsStringView(),
+ XFA_Element::Subform);
+ return CJS_Return(true);
}
-void CJX_Subform::execInitialize(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execInitialize");
- return;
- }
+CJS_Return CJX_Subform::execInitialize(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify)
- return;
-
- pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize);
+ if (pNotify)
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize);
+ return CJS_Return(true);
}
-void CJX_Subform::execCalculate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execCalculate");
- return;
- }
+CJS_Return CJX_Subform::execCalculate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify)
- return;
-
- pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate);
+ if (pNotify)
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate);
+ return CJS_Return(true);
}
-void CJX_Subform::execValidate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execValidate");
- return;
- }
+CJS_Return CJX_Subform::execValidate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
- if (!pNotify) {
- pArguments->GetReturnValue()->SetBoolean(false);
- return;
- }
+ if (!pNotify)
+ return CJS_Return(runtime->NewBoolean(false));
int32_t iRet =
pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate);
- pArguments->GetReturnValue()->SetBoolean(
- (iRet == XFA_EVENTERROR_Error) ? false : true);
+ return CJS_Return(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error));
}
diff --git a/fxjs/xfa/cjx_template.cpp b/fxjs/xfa/cjx_template.cpp
index 99db4ea69a..48507c3494 100644
--- a/fxjs/xfa/cjx_template.cpp
+++ b/fxjs/xfa/cjx_template.cpp
@@ -6,8 +6,10 @@
#include "fxjs/xfa/cjx_template.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_template.h"
@@ -26,62 +28,56 @@ CJX_Template::CJX_Template(CXFA_Template* tmpl) : CJX_Model(tmpl) {
CJX_Template::~CJX_Template() {}
-void CJX_Template::formNodes(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"formNodes");
- return;
- }
- pArguments->GetReturnValue()->SetBoolean(true);
+CJS_Return CJX_Template::formNodes(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(runtime->NewBoolean(true));
}
-void CJX_Template::remerge(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"remerge");
- return;
- }
+CJS_Return CJX_Template::remerge(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+
GetDocument()->DoDataRemerge(true);
+ return CJS_Return(true);
}
-void CJX_Template::execInitialize(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execInitialize");
- return;
- }
+CJS_Return CJX_Template::execInitialize(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
- if (!pWidgetData) {
- pArguments->GetReturnValue()->SetBoolean(false);
- return;
- }
- pArguments->GetReturnValue()->SetBoolean(true);
+ return CJS_Return(runtime->NewBoolean(!!pWidgetData));
}
-void CJX_Template::recalculate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"recalculate");
- return;
- }
- pArguments->GetReturnValue()->SetBoolean(true);
+CJS_Return CJX_Template::recalculate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(runtime->NewBoolean(true));
}
-void CJX_Template::execCalculate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execCalculate");
- return;
- }
+CJS_Return CJX_Template::execCalculate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
- if (!pWidgetData) {
- pArguments->GetReturnValue()->SetBoolean(false);
- return;
- }
- pArguments->GetReturnValue()->SetBoolean(true);
+ return CJS_Return(runtime->NewBoolean(!!pWidgetData));
}
-void CJX_Template::execValidate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execValidate");
- return;
- }
- pArguments->GetReturnValue()->SetBoolean(!!GetXFANode()->GetWidgetData());
+CJS_Return CJX_Template::execValidate(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty())
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(runtime->NewBoolean(!!GetXFANode()->GetWidgetData()));
}
diff --git a/fxjs/xfa/cjx_textnode.cpp b/fxjs/xfa/cjx_textnode.cpp
index 4ebf3ce472..604682f2ee 100644
--- a/fxjs/xfa/cjx_textnode.cpp
+++ b/fxjs/xfa/cjx_textnode.cpp
@@ -6,7 +6,6 @@
#include "fxjs/xfa/cjx_textnode.h"
-#include "fxjs/cfxjse_arguments.h"
#include "fxjs/cfxjse_value.h"
#include "xfa/fxfa/parser/cxfa_node.h"
diff --git a/fxjs/xfa/cjx_tree.cpp b/fxjs/xfa/cjx_tree.cpp
index 69cbfa0652..6c5e5abd89 100644
--- a/fxjs/xfa/cjx_tree.cpp
+++ b/fxjs/xfa/cjx_tree.cpp
@@ -6,9 +6,11 @@
#include "fxjs/xfa/cjx_tree.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_engine.h"
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "third_party/base/ptr_util.h"
#include "xfa/fxfa/parser/cxfa_arraynodelist.h"
#include "xfa/fxfa/parser/cxfa_attachnodelist.h"
@@ -28,73 +30,76 @@ CJX_Tree::CJX_Tree(CXFA_Object* obj) : CJX_Object(obj) {
CJX_Tree::~CJX_Tree() {}
-void CJX_Tree::resolveNode(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"resolveNode");
- return;
- }
- WideString wsExpression =
- WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringView());
+CJS_Return CJX_Tree::resolveNode(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+
+ WideString expression = runtime->ToWideString(params[0]);
CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
if (!pScriptContext)
- return;
+ return CJS_Return(true);
+
CXFA_Object* refNode = GetXFAObject();
if (refNode->GetElementType() == XFA_Element::Xfa)
refNode = pScriptContext->GetThisObject();
+
uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes |
XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent |
XFA_RESOLVENODE_Siblings;
XFA_RESOLVENODE_RS resolveNodeRS;
if (!pScriptContext->ResolveObjects(ToNode(refNode),
- wsExpression.AsStringView(),
- &resolveNodeRS, dwFlag, nullptr)) {
- pArguments->GetReturnValue()->SetNull();
- return;
+ expression.AsStringView(), &resolveNodeRS,
+ dwFlag, nullptr)) {
+ return CJS_Return(runtime->NewNull());
}
+
if (resolveNodeRS.dwFlags == XFA_ResolveNode_RSType_Nodes) {
CXFA_Object* pObject = resolveNodeRS.objects.front();
- pArguments->GetReturnValue()->Assign(
- pScriptContext->GetJSValueFromMap(pObject));
- } else {
- const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo =
- resolveNodeRS.pScriptAttribute;
- if (lpAttributeInfo &&
- lpAttributeInfo->eValueType == XFA_ScriptType::Object) {
- auto pValue =
- pdfium::MakeUnique<CFXJSE_Value>(pScriptContext->GetRuntime());
- CJX_Object* jsObject = resolveNodeRS.objects.front()->JSObject();
- (jsObject->*(lpAttributeInfo->callback))(pValue.get(), false,
- lpAttributeInfo->attribute);
- pArguments->GetReturnValue()->Assign(pValue.get());
- } else {
- pArguments->GetReturnValue()->SetNull();
- }
+ CFXJSE_Value* value =
+ GetDocument()->GetScriptContext()->GetJSValueFromMap(pObject);
+ if (!value)
+ return CJS_Return(runtime->NewNull());
+
+ return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
}
-}
-void CJX_Tree::resolveNodes(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"resolveNodes");
- return;
+ const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo =
+ resolveNodeRS.pScriptAttribute;
+ if (!lpAttributeInfo ||
+ lpAttributeInfo->eValueType != XFA_ScriptType::Object) {
+ return CJS_Return(runtime->NewNull());
}
- WideString wsExpression =
- WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringView());
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (!pValue)
- return;
+ auto pValue = pdfium::MakeUnique<CFXJSE_Value>(pScriptContext->GetIsolate());
+ CJX_Object* jsObject = resolveNodeRS.objects.front()->JSObject();
+ (jsObject->*(lpAttributeInfo->callback))(pValue.get(), false,
+ lpAttributeInfo->attribute);
+ return CJS_Return(pValue->DirectGetValue().Get(runtime->GetIsolate()));
+}
+
+CJS_Return CJX_Tree::resolveNodes(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CXFA_Object* refNode = GetXFAObject();
if (refNode->GetElementType() == XFA_Element::Xfa)
refNode = GetDocument()->GetScriptContext()->GetThisObject();
- ResolveNodeList(pValue, wsExpression,
+ CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
+ if (!pScriptContext)
+ return CJS_Return(true);
+
+ auto pValue = pdfium::MakeUnique<CFXJSE_Value>(pScriptContext->GetIsolate());
+ ResolveNodeList(pValue.get(), runtime->ToWideString(params[0]),
XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes |
XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent |
XFA_RESOLVENODE_Siblings,
ToNode(refNode));
+ return CJS_Return(pValue->DirectGetValue().Get(runtime->GetIsolate()));
}
void CJX_Tree::all(CFXJSE_Value* pValue,
@@ -215,7 +220,7 @@ void CJX_Tree::ResolveNodeList(CFXJSE_Value* pValue,
resolveNodeRS.pScriptAttribute->eValueType == XFA_ScriptType::Object) {
for (CXFA_Object* pObject : resolveNodeRS.objects) {
auto pValue =
- pdfium::MakeUnique<CFXJSE_Value>(pScriptContext->GetRuntime());
+ pdfium::MakeUnique<CFXJSE_Value>(pScriptContext->GetIsolate());
CJX_Object* jsObject = pObject->JSObject();
(jsObject->*(resolveNodeRS.pScriptAttribute->callback))(
pValue.get(), false, resolveNodeRS.pScriptAttribute->attribute);
diff --git a/fxjs/xfa/cjx_treelist.cpp b/fxjs/xfa/cjx_treelist.cpp
index f82f30db29..bb9e4167f8 100644
--- a/fxjs/xfa/cjx_treelist.cpp
+++ b/fxjs/xfa/cjx_treelist.cpp
@@ -6,9 +6,11 @@
#include "fxjs/xfa/cjx_treelist.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_engine.h"
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_treelist.h"
@@ -27,19 +29,21 @@ CXFA_TreeList* CJX_TreeList::GetXFATreeList() {
return static_cast<CXFA_TreeList*>(GetXFAObject());
}
-void CJX_TreeList::namedItem(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 1) {
- ThrowParamCountMismatchException(L"namedItem");
- return;
- }
+CJS_Return CJX_TreeList::namedItem(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- ByteString szName = pArguments->GetUTF8String(0);
CXFA_Node* pNode = GetXFATreeList()->NamedItem(
- WideString::FromUTF8(szName.AsStringView()).AsStringView());
+ runtime->ToWideString(params[0]).AsStringView());
if (!pNode)
- return;
+ return CJS_Return(true);
+
+ CFXJSE_Value* value =
+ GetDocument()->GetScriptContext()->GetJSValueFromMap(pNode);
+ if (!value)
+ return CJS_Return(runtime->NewNull());
- pArguments->GetReturnValue()->Assign(
- GetDocument()->GetScriptContext()->GetJSValueFromMap(pNode));
+ return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
}
diff --git a/fxjs/xfa/cjx_wsdlconnection.cpp b/fxjs/xfa/cjx_wsdlconnection.cpp
index 8a684f4341..a1d673fae5 100644
--- a/fxjs/xfa/cjx_wsdlconnection.cpp
+++ b/fxjs/xfa/cjx_wsdlconnection.cpp
@@ -6,8 +6,10 @@
#include "fxjs/xfa/cjx_wsdlconnection.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/parser/cxfa_wsdlconnection.h"
const CJX_MethodSpec CJX_WsdlConnection::MethodSpecs[] = {
@@ -21,11 +23,10 @@ CJX_WsdlConnection::CJX_WsdlConnection(CXFA_WsdlConnection* connection)
CJX_WsdlConnection::~CJX_WsdlConnection() {}
-void CJX_WsdlConnection::execute(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 0 && argc != 1) {
- ThrowParamCountMismatchException(L"execute");
- return;
- }
- pArguments->GetReturnValue()->SetBoolean(false);
+CJS_Return CJX_WsdlConnection::execute(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!params.empty() && params.size() != 1)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(runtime->NewBoolean(false));
}