From 80435cb746fa7bd22cf062ab39829ec86000fd21 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Tue, 24 Oct 2017 21:40:24 -0400 Subject: Convert JS input params to v8::Local>s This CL converts the JS set_* methods and the JSMethod methods to accept v8::Local objects instead of CJS_Value objects. Change-Id: I6de41305deff458eba515bdc3462522b502f74ad Reviewed-on: https://pdfium-review.googlesource.com/16670 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- fpdfsdk/javascript/JS_Value.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'fpdfsdk/javascript/JS_Value.cpp') 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 CJS_Array::GetElement(CJS_Runtime* pRuntime, + unsigned index) const { if (!m_pArray.IsEmpty()) - return CJS_Value( - v8::Local(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 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 ExpandKeywordParams( +std::vector> ExpandKeywordParams( CJS_Runtime* pRuntime, - const std::vector& originals, + const std::vector>& originals, size_t nKeywords, ...) { ASSERT(nKeywords); - std::vector result(nKeywords, CJS_Value()); + std::vector> result(nKeywords, v8::Local()); 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 pObj = pRuntime->ToObject(originals[0].ToV8Value()); - result[0] = CJS_Value(); // Make unknown. + result[0] = v8::Local(); // Make unknown. + v8::Local 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 v8Value = pRuntime->GetObjectProperty(pObj, property); if (!v8Value->IsUndefined()) - result[i] = CJS_Value(v8Value); + result[i] = v8Value; } va_end(ap); + return result; } -- cgit v1.2.3