summaryrefslogtreecommitdiff
path: root/fxjs/cjs_util.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-10-30 21:19:42 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-10-30 21:19:42 +0000
commitd6e9cfaab0555c34783dd05261329866b4da1b9f (patch)
treef123e3ee82017c1e14a07306f54381ea9bf2966c /fxjs/cjs_util.cpp
parentcaee9596e926a41a23fa0ddebd10d509db4b23ab (diff)
downloadpdfium-d6e9cfaab0555c34783dd05261329866b4da1b9f.tar.xz
Convert JS resource into enum classchromium/3254
This CL converts the #defines into an enum class. Change-Id: I895e29e1d46a7a82d7be896f5776eb00d28559f5 Reviewed-on: https://pdfium-review.googlesource.com/17091 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs/cjs_util.cpp')
-rw-r--r--fxjs/cjs_util.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/fxjs/cjs_util.cpp b/fxjs/cjs_util.cpp
index 7a80700e7d..9fc1093158 100644
--- a/fxjs/cjs_util.cpp
+++ b/fxjs/cjs_util.cpp
@@ -144,11 +144,13 @@ CJS_Return util::printd(CJS_Runtime* pRuntime,
return CJS_Return(false);
if (params[1].IsEmpty() || !params[1]->IsDate())
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPRINT1));
+ return CJS_Return(JSGetStringFromID(JSMessage::kSecondParamNotDateError));
v8::Local<v8::Date> v8_date = params[1].As<v8::Date>();
- if (v8_date.IsEmpty() || std::isnan(pRuntime->ToDouble(v8_date)))
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPRINT2));
+ if (v8_date.IsEmpty() || std::isnan(pRuntime->ToDouble(v8_date))) {
+ return CJS_Return(
+ JSGetStringFromID(JSMessage::kSecondParamInvalidDateError));
+ }
double date = JS_LocalTime(pRuntime->ToDouble(v8_date));
int year = JS_GetYearFromTime(date);
@@ -174,7 +176,7 @@ CJS_Return util::printd(CJS_Runtime* pRuntime,
hour, min, sec);
break;
default:
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSVALUEERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
}
return CJS_Return(pRuntime->NewString(swResult.c_str()));
@@ -183,7 +185,7 @@ CJS_Return util::printd(CJS_Runtime* pRuntime,
if (params[0]->IsString()) {
// We don't support XFAPicture at the moment.
if (iSize > 2 && pRuntime->ToBoolean(params[2]))
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSNOTSUPPORT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kNotSupportedError));
// Convert PDF-style format specifiers to wcsftime specifiers. Remove any
// pre-existing %-directives before inserting our own.
@@ -204,7 +206,7 @@ CJS_Return util::printd(CJS_Runtime* pRuntime,
}
if (year < 0)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSVALUEERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
static const TbConvertAdditional cTableAd[] = {
{L"m", month}, {L"d", day},
@@ -244,13 +246,13 @@ CJS_Return util::printd(CJS_Runtime* pRuntime,
return CJS_Return(pRuntime->NewString(cFormat.c_str()));
}
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSTYPEERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kTypeError));
}
CJS_Return util::printx(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() < 2)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
return CJS_Return(
pRuntime->NewString(printx(pRuntime->ToWideString(params[0]),
@@ -375,11 +377,11 @@ CJS_Return util::scand(CJS_Runtime* pRuntime,
CJS_Return util::byteToChar(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() < 1)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
int arg = pRuntime->ToInt32(params[0]);
if (arg < 0 || arg > 255)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSVALUEERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
WideString wStr(static_cast<wchar_t>(arg));
return CJS_Return(pRuntime->NewString(wStr.c_str()));