summaryrefslogtreecommitdiff
path: root/fxjs/cfxjse_class.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/cfxjse_class.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/cfxjse_class.cpp')
-rw-r--r--fxjs/cfxjse_class.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/fxjs/cfxjse_class.cpp b/fxjs/cfxjse_class.cpp
index 09976d1aa5..9515ef4b74 100644
--- a/fxjs/cfxjse_class.cpp
+++ b/fxjs/cfxjse_class.cpp
@@ -12,6 +12,8 @@
#include "fxjs/cfxjse_arguments.h"
#include "fxjs/cfxjse_context.h"
#include "fxjs/cfxjse_value.h"
+#include "fxjs/cjs_return.h"
+#include "fxjs/js_resources.h"
#include "third_party/base/ptr_util.h"
namespace {
@@ -78,15 +80,21 @@ void DynPropGetterAdapter_MethodCallback(
v8::Local<v8::String> hPropName =
hCallBackInfo->GetInternalField(1).As<v8::String>();
ASSERT(lpClass && !hPropName.IsEmpty());
+
v8::String::Utf8Value szPropName(hPropName);
- ByteStringView szFxPropName = *szPropName;
- auto lpThisValue = pdfium::MakeUnique<CFXJSE_Value>(info.GetIsolate());
- lpThisValue->ForceSetValue(info.Holder());
- auto lpRetValue = pdfium::MakeUnique<CFXJSE_Value>(info.GetIsolate());
- CFXJSE_Arguments impl(&info, lpRetValue.get());
- lpClass->dynMethodCall(lpThisValue.get(), szFxPropName, impl);
- if (!lpRetValue->DirectGetValue().IsEmpty())
- info.GetReturnValue().Set(lpRetValue->DirectGetValue());
+ WideString szFxPropName = WideString::FromUTF8(*szPropName);
+
+ CJS_Return result = lpClass->dynMethodCall(info, szFxPropName);
+ if (result.HasError()) {
+ WideString err = JSFormatErrorString(*szPropName, "", result.Error());
+ v8::MaybeLocal<v8::String> str = v8::String::NewFromUtf8(
+ info.GetIsolate(), ByteString::FromUnicode(err).c_str(),
+ v8::NewStringType::kNormal);
+ info.GetIsolate()->ThrowException(str.ToLocalChecked());
+ return;
+ }
+ if (result.HasReturn())
+ info.GetReturnValue().Set(result.Return());
}
void DynPropGetterAdapter(const FXJSE_CLASS_DESCRIPTOR* lpClass,
@@ -94,6 +102,7 @@ void DynPropGetterAdapter(const FXJSE_CLASS_DESCRIPTOR* lpClass,
const ByteStringView& szPropName,
CFXJSE_Value* pValue) {
ASSERT(lpClass);
+
int32_t nPropType =
lpClass->dynPropTypeGetter == nullptr
? FXJSE_ClassPropType_Property