diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-10-24 13:56:29 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-10-24 18:08:51 +0000 |
commit | 1b2a18ec4ed99fc2ac56b5fde230bc2b348d9725 (patch) | |
tree | a529fbb941a15197b050a0aa88e7a9403ff56152 /fpdfsdk/javascript/util.cpp | |
parent | 65f3162c91607071322967ea064a4a11e3904722 (diff) | |
download | pdfium-1b2a18ec4ed99fc2ac56b5fde230bc2b348d9725.tar.xz |
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 <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/javascript/util.cpp')
-rw-r--r-- | fpdfsdk/javascript/util.cpp | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/fpdfsdk/javascript/util.cpp b/fpdfsdk/javascript/util.cpp index 63179c84a8..96b2c8a6ef 100644 --- a/fpdfsdk/javascript/util.cpp +++ b/fpdfsdk/javascript/util.cpp @@ -81,7 +81,8 @@ bool util::printf(CJS_Runtime* pRuntime, if (iSize < 1) return false; - std::wstring unsafe_fmt_string(params[0].ToWideString(pRuntime).c_str()); + std::wstring unsafe_fmt_string( + pRuntime->ToWideString(params[0].ToV8Value()).c_str()); std::vector<std::wstring> unsafe_conversion_specifiers; int iOffset = 0; int iOffend = 0; @@ -114,15 +115,17 @@ bool util::printf(CJS_Runtime* pRuntime, WideString strSegment; switch (ParseDataType(&c_strFormat)) { case UTIL_INT: - strSegment.Format(c_strFormat.c_str(), params[iIndex].ToInt(pRuntime)); + strSegment.Format(c_strFormat.c_str(), + pRuntime->ToInt32(params[iIndex].ToV8Value())); break; case UTIL_DOUBLE: strSegment.Format(c_strFormat.c_str(), - params[iIndex].ToDouble(pRuntime)); + pRuntime->ToDouble(params[iIndex].ToV8Value())); break; case UTIL_STRING: - strSegment.Format(c_strFormat.c_str(), - params[iIndex].ToWideString(pRuntime).c_str()); + strSegment.Format( + c_strFormat.c_str(), + pRuntime->ToWideString(params[iIndex].ToV8Value()).c_str()); break; default: strSegment.Format(L"%ls", c_strFormat.c_str()); @@ -151,7 +154,9 @@ bool util::printd(CJS_Runtime* pRuntime, return false; } - CJS_Date jsDate = p2.ToDate(); + ASSERT(p2.IsDateObject()); + v8::Local<v8::Value> mutable_value = p2.ToV8Value(); + CJS_Date jsDate(mutable_value.As<v8::Date>()); if (!jsDate.IsValidDate(pRuntime)) { sError = JSGetStringFromID(IDS_STRING_JSPRINT2); return false; @@ -159,7 +164,7 @@ bool util::printd(CJS_Runtime* pRuntime, if (p1.GetType() == CJS_Value::VT_number) { WideString swResult; - switch (p1.ToInt(pRuntime)) { + switch (pRuntime->ToInt32(p1.ToV8Value())) { case 0: swResult.Format(L"D:%04d%02d%02d%02d%02d%02d", jsDate.GetYear(pRuntime), jsDate.GetMonth(pRuntime) + 1, jsDate.GetDay(pRuntime), @@ -190,14 +195,15 @@ bool util::printd(CJS_Runtime* pRuntime, } if (p1.GetType() == CJS_Value::VT_string) { - if (iSize > 2 && params[2].ToBool(pRuntime)) { + if (iSize > 2 && pRuntime->ToBoolean(params[2].ToV8Value())) { sError = JSGetStringFromID(IDS_STRING_JSNOTSUPPORT); return false; // currently, it doesn't support XFAPicture. } // Convert PDF-style format specifiers to wcsftime specifiers. Remove any // pre-existing %-directives before inserting our own. - std::basic_string<wchar_t> cFormat = p1.ToWideString(pRuntime).c_str(); + std::basic_string<wchar_t> cFormat = + pRuntime->ToWideString(p1.ToV8Value()).c_str(); cFormat.erase(std::remove(cFormat.begin(), cFormat.end(), '%'), cFormat.end()); @@ -276,9 +282,10 @@ bool util::printx(CJS_Runtime* pRuntime, return false; } - vRet = CJS_Value(pRuntime->NewString( - printx(params[0].ToWideString(pRuntime), params[1].ToWideString(pRuntime)) - .c_str())); + vRet = CJS_Value( + pRuntime->NewString(printx(pRuntime->ToWideString(params[0].ToV8Value()), + pRuntime->ToWideString(params[1].ToV8Value())) + .c_str())); return true; } @@ -388,15 +395,15 @@ bool util::scand(CJS_Runtime* pRuntime, if (params.size() < 2) return false; - WideString sFormat = params[0].ToWideString(pRuntime); - WideString sDate = params[1].ToWideString(pRuntime); + WideString sFormat = pRuntime->ToWideString(params[0].ToV8Value()); + WideString sDate = pRuntime->ToWideString(params[1].ToV8Value()); double dDate = JS_GetDateTime(); if (sDate.GetLength() > 0) { dDate = CJS_PublicMethods::MakeRegularDate(sDate, sFormat, nullptr); } if (!std::isnan(dDate)) { - vRet = CJS_Value(CJS_Date(pRuntime, dDate).ToV8Date()); + vRet = CJS_Value(CJS_Date(pRuntime, dDate).ToV8Value()); } else { vRet.Set(pRuntime->NewNull()); } @@ -413,7 +420,7 @@ bool util::byteToChar(CJS_Runtime* pRuntime, return false; } - int arg = params[0].ToInt(pRuntime); + int arg = pRuntime->ToInt32(params[0].ToV8Value()); if (arg < 0 || arg > 255) { sError = JSGetStringFromID(IDS_STRING_JSVALUEERROR); return false; |