From 1b2a18ec4ed99fc2ac56b5fde230bc2b348d9725 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 24 Oct 2017 13:56:29 -0400 Subject: Remove the CJS_Value To* methods. This CL removes all of the To* methods on the CJS classes except for ToV8Value. Change-Id: If01263c8cfa557ef7b00f573ddbf68b591d5ae9a Reviewed-on: https://pdfium-review.googlesource.com/16614 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- fpdfsdk/javascript/JS_Value.cpp | 68 ++--------------------------------------- 1 file changed, 3 insertions(+), 65 deletions(-) (limited to 'fpdfsdk/javascript/JS_Value.cpp') diff --git a/fpdfsdk/javascript/JS_Value.cpp b/fpdfsdk/javascript/JS_Value.cpp index fcf913a7fb..35a5b1c682 100644 --- a/fpdfsdk/javascript/JS_Value.cpp +++ b/fpdfsdk/javascript/JS_Value.cpp @@ -190,66 +190,15 @@ void CJS_Value::Set(v8::Local pValue) { m_pValue = pValue; } -int CJS_Value::ToInt(CJS_Runtime* pRuntime) const { - return pRuntime->ToInt32(m_pValue); -} - -bool CJS_Value::ToBool(CJS_Runtime* pRuntime) const { - return pRuntime->ToBoolean(m_pValue); -} - -double CJS_Value::ToDouble(CJS_Runtime* pRuntime) const { - return pRuntime->ToDouble(m_pValue); -} - -float CJS_Value::ToFloat(CJS_Runtime* pRuntime) const { - return static_cast(ToDouble(pRuntime)); -} - -CJS_Object* CJS_Value::ToObject(CJS_Runtime* pRuntime) const { - v8::Local pObj = pRuntime->ToObject(m_pValue); - return static_cast(pRuntime->GetObjectPrivate(pObj)); -} - -CJS_Document* CJS_Value::ToDocument(CJS_Runtime* pRuntime) const { - return static_cast(ToObject(pRuntime)); -} - -CJS_Array CJS_Value::ToArray(CJS_Runtime* pRuntime) const { - ASSERT(IsArrayObject()); - return CJS_Array(pRuntime->ToArray(m_pValue)); -} - -CJS_Date CJS_Value::ToDate() const { - ASSERT(IsDateObject()); - v8::Local mutable_value = m_pValue; - return CJS_Date(mutable_value.As()); -} - -v8::Local CJS_Value::ToV8Object(CJS_Runtime* pRuntime) const { - return pRuntime->ToObject(m_pValue); -} - -WideString CJS_Value::ToWideString(CJS_Runtime* pRuntime) const { - return pRuntime->ToWideString(m_pValue); -} - -ByteString CJS_Value::ToByteString(CJS_Runtime* pRuntime) const { - return ByteString::FromUnicode(ToWideString(pRuntime)); -} - v8::Local CJS_Value::ToV8Value() const { return m_pValue; } -v8::Local CJS_Value::ToV8Array(CJS_Runtime* pRuntime) const { - return pRuntime->ToArray(m_pValue); -} - void CJS_Value::MaybeCoerceToNumber(CJS_Runtime* pRuntime) { bool bAllowNaN = false; if (GetType() == VT_string) { - ByteString bstr = ToByteString(pRuntime); + ByteString bstr = + ByteString::FromUnicode(pRuntime->ToWideString(ToV8Value())); if (bstr.GetLength() == 0) return; if (bstr == "NaN") @@ -326,13 +275,6 @@ int CJS_Array::GetLength(CJS_Runtime* pRuntime) const { return pRuntime->GetArrayLength(m_pArray); } -v8::Local CJS_Array::ToV8Array(CJS_Runtime* pRuntime) const { - if (m_pArray.IsEmpty()) - m_pArray = pRuntime->NewArray(); - - return m_pArray; -} - CJS_Date::CJS_Date() {} CJS_Date::CJS_Date(v8::Local pDate) : m_pDate(pDate) {} @@ -398,10 +340,6 @@ int CJS_Date::GetSeconds(CJS_Runtime* pRuntime) const { return JS_GetSecFromTime(JS_LocalTime(pRuntime->ToDouble(m_pDate))); } -v8::Local CJS_Date::ToV8Date() const { - return m_pDate; -} - double JS_GetDateTime() { if (!FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) return 0; @@ -522,7 +460,7 @@ std::vector ExpandKeywordParams( originals[0].IsArrayObject()) { return result; } - v8::Local pObj = originals[0].ToV8Object(pRuntime); + v8::Local pObj = pRuntime->ToObject(originals[0].ToV8Value()); result[0] = CJS_Value(); // Make unknown. va_list ap; -- cgit v1.2.3