summaryrefslogtreecommitdiff
path: root/fxjs/cjx_signaturepseudomodel.cpp
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/cjx_signaturepseudomodel.cpp
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/cjx_signaturepseudomodel.cpp')
-rw-r--r--fxjs/cjx_signaturepseudomodel.cpp64
1 files changed, 27 insertions, 37 deletions
diff --git a/fxjs/cjx_signaturepseudomodel.cpp b/fxjs/cjx_signaturepseudomodel.cpp
index b50e5dc9ab..900116bccf 100644
--- a/fxjs/cjx_signaturepseudomodel.cpp
+++ b/fxjs/cjx_signaturepseudomodel.cpp
@@ -6,8 +6,10 @@
#include "fxjs/cjx_signaturepseudomodel.h"
-#include "fxjs/cfxjse_arguments.h"
+#include <vector>
+
#include "fxjs/cfxjse_value.h"
+#include "fxjs/js_resources.h"
#include "xfa/fxfa/parser/cscript_signaturepseudomodel.h"
const CJX_MethodSpec CJX_SignaturePseudoModel::MethodSpecs[] = {
@@ -25,46 +27,34 @@ CJX_SignaturePseudoModel::CJX_SignaturePseudoModel(
CJX_SignaturePseudoModel::~CJX_SignaturePseudoModel() {}
-void CJX_SignaturePseudoModel::verifySignature(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 1 || iLength > 4) {
- ThrowParamCountMismatchException(L"verify");
- return;
- }
-
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (pValue)
- pValue->SetInteger(0);
+CJS_Return CJX_SignaturePseudoModel::verifySignature(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.empty() || params.size() > 4)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(runtime->NewNumber(0));
}
-void CJX_SignaturePseudoModel::sign(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 3 || iLength > 7) {
- ThrowParamCountMismatchException(L"sign");
- return;
- }
-
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (pValue)
- pValue->SetBoolean(false);
+CJS_Return CJX_SignaturePseudoModel::sign(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() < 3 || params.size() > 7)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(runtime->NewBoolean(false));
}
-void CJX_SignaturePseudoModel::enumerate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"enumerate");
- return;
- }
- return;
+CJS_Return CJX_SignaturePseudoModel::enumerate(
+ 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_SignaturePseudoModel::clear(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 1 || iLength > 2) {
- ThrowParamCountMismatchException(L"clear");
- return;
- }
-
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (pValue)
- pValue->SetBoolean(false);
+CJS_Return CJX_SignaturePseudoModel::clear(
+ CJS_V8* runtime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.empty() || params.size() > 2)
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(runtime->NewBoolean(false));
}