summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/JS_Value.cpp
diff options
context:
space:
mode:
authordan sinclair <dsinclair@chromium.org>2017-10-24 21:40:24 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-10-25 18:14:09 +0000
commit80435cb746fa7bd22cf062ab39829ec86000fd21 (patch)
tree9085fa57d5f49eac4b56b065ca572f424c9f744b /fpdfsdk/javascript/JS_Value.cpp
parente85107bc8ab5bbd5b2d3f97fd6071d7ce4a78bcc (diff)
downloadpdfium-80435cb746fa7bd22cf062ab39829ec86000fd21.tar.xz
Convert JS input params to v8::Local<v8::Value>>s
This CL converts the JS set_* methods and the JSMethod methods to accept v8::Local<v8::Value> objects instead of CJS_Value objects. Change-Id: I6de41305deff458eba515bdc3462522b502f74ad Reviewed-on: https://pdfium-review.googlesource.com/16670 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/javascript/JS_Value.cpp')
-rw-r--r--fpdfsdk/javascript/JS_Value.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/fpdfsdk/javascript/JS_Value.cpp b/fpdfsdk/javascript/JS_Value.cpp
index ddea0a4caa..bac338ad66 100644
--- a/fpdfsdk/javascript/JS_Value.cpp
+++ b/fpdfsdk/javascript/JS_Value.cpp
@@ -202,20 +202,20 @@ CJS_Array::CJS_Array(const CJS_Array& other) = default;
CJS_Array::~CJS_Array() {}
-CJS_Value CJS_Array::GetElement(CJS_Runtime* pRuntime, unsigned index) const {
+v8::Local<v8::Value> CJS_Array::GetElement(CJS_Runtime* pRuntime,
+ unsigned index) const {
if (!m_pArray.IsEmpty())
- return CJS_Value(
- v8::Local<v8::Value>(pRuntime->GetArrayElement(m_pArray, index)));
+ return {pRuntime->GetArrayElement(m_pArray, index)};
return {};
}
void CJS_Array::SetElement(CJS_Runtime* pRuntime,
unsigned index,
- const CJS_Value& value) {
+ v8::Local<v8::Value> value) {
if (m_pArray.IsEmpty())
m_pArray = pRuntime->NewArray();
- pRuntime->PutArrayElement(m_pArray, index, value.ToV8Value());
+ pRuntime->PutArrayElement(m_pArray, index, value);
}
int CJS_Array::GetLength(CJS_Runtime* pRuntime) const {
@@ -393,33 +393,34 @@ double JS_MakeDate(double day, double time) {
return day * 86400000 + time;
}
-std::vector<CJS_Value> ExpandKeywordParams(
+std::vector<v8::Local<v8::Value>> ExpandKeywordParams(
CJS_Runtime* pRuntime,
- const std::vector<CJS_Value>& originals,
+ const std::vector<v8::Local<v8::Value>>& originals,
size_t nKeywords,
...) {
ASSERT(nKeywords);
- std::vector<CJS_Value> result(nKeywords, CJS_Value());
+ std::vector<v8::Local<v8::Value>> result(nKeywords, v8::Local<v8::Value>());
size_t size = std::min(originals.size(), nKeywords);
for (size_t i = 0; i < size; ++i)
result[i] = originals[i];
- if (originals.size() != 1 || !originals[0].ToV8Value()->IsObject() ||
- originals[0].ToV8Value()->IsArray()) {
+ if (originals.size() != 1 || !originals[0]->IsObject() ||
+ originals[0]->IsArray()) {
return result;
}
- v8::Local<v8::Object> pObj = pRuntime->ToObject(originals[0].ToV8Value());
- result[0] = CJS_Value(); // Make unknown.
+ result[0] = v8::Local<v8::Value>(); // Make unknown.
+ v8::Local<v8::Object> pObj = pRuntime->ToObject(originals[0]);
va_list ap;
va_start(ap, nKeywords);
for (size_t i = 0; i < nKeywords; ++i) {
const wchar_t* property = va_arg(ap, const wchar_t*);
v8::Local<v8::Value> v8Value = pRuntime->GetObjectProperty(pObj, property);
if (!v8Value->IsUndefined())
- result[i] = CJS_Value(v8Value);
+ result[i] = v8Value;
}
va_end(ap);
+
return result;
}