summaryrefslogtreecommitdiff
path: root/fxjs/cjs_util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fxjs/cjs_util.cpp')
-rw-r--r--fxjs/cjs_util.cpp48
1 files changed, 24 insertions, 24 deletions
diff --git a/fxjs/cjs_util.cpp b/fxjs/cjs_util.cpp
index 54a74f2952..0c40b10117 100644
--- a/fxjs/cjs_util.cpp
+++ b/fxjs/cjs_util.cpp
@@ -84,11 +84,11 @@ CJS_Util::CJS_Util(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime)
CJS_Util::~CJS_Util() = default;
-CJS_Return CJS_Util::printf(CJS_Runtime* pRuntime,
+CJS_Result CJS_Util::printf(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
const size_t iSize = params.size();
if (iSize < 1)
- return CJS_Return::Failure(JSMessage::kParamError);
+ return CJS_Result::Failure(JSMessage::kParamError);
std::wstring unsafe_fmt_string(pRuntime->ToWideString(params[0]).c_str());
std::vector<std::wstring> unsafe_conversion_specifiers;
@@ -143,21 +143,21 @@ CJS_Return CJS_Util::printf(CJS_Runtime* pRuntime,
}
c_strResult.erase(c_strResult.begin());
- return CJS_Return::Success(pRuntime->NewString(c_strResult.c_str()));
+ return CJS_Result::Success(pRuntime->NewString(c_strResult.c_str()));
}
-CJS_Return CJS_Util::printd(CJS_Runtime* pRuntime,
+CJS_Result CJS_Util::printd(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
const size_t iSize = params.size();
if (iSize < 2)
- return CJS_Return::Failure(JSMessage::kParamError);
+ return CJS_Result::Failure(JSMessage::kParamError);
if (params[1].IsEmpty() || !params[1]->IsDate())
- return CJS_Return::Failure(JSMessage::kSecondParamNotDateError);
+ return CJS_Result::Failure(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::Failure(JSMessage::kSecondParamInvalidDateError);
+ return CJS_Result::Failure(JSMessage::kSecondParamInvalidDateError);
double date = JS_LocalTime(pRuntime->ToDouble(v8_date));
int year = JS_GetYearFromTime(date);
@@ -183,18 +183,18 @@ CJS_Return CJS_Util::printd(CJS_Runtime* pRuntime,
month, day, hour, min, sec);
break;
default:
- return CJS_Return::Failure(JSMessage::kValueError);
+ return CJS_Result::Failure(JSMessage::kValueError);
}
- return CJS_Return::Success(pRuntime->NewString(swResult.AsStringView()));
+ return CJS_Result::Success(pRuntime->NewString(swResult.AsStringView()));
}
if (!params[0]->IsString())
- return CJS_Return::Failure(JSMessage::kTypeError);
+ return CJS_Result::Failure(JSMessage::kTypeError);
// We don't support XFAPicture at the moment.
if (iSize > 2 && pRuntime->ToBoolean(params[2]))
- return CJS_Return::Failure(JSMessage::kNotSupportedError);
+ return CJS_Result::Failure(JSMessage::kNotSupportedError);
// Convert PDF-style format specifiers to wcsftime specifiers. Remove any
// pre-existing %-directives before inserting our own.
@@ -214,7 +214,7 @@ CJS_Return CJS_Util::printd(CJS_Runtime* pRuntime,
}
if (year < 0)
- return CJS_Return::Failure(JSMessage::kValueError);
+ return CJS_Result::Failure(JSMessage::kValueError);
const TbConvertAdditional cTableAd[] = {
{L"m", month}, {L"d", day},
@@ -249,15 +249,15 @@ CJS_Return CJS_Util::printd(CJS_Runtime* pRuntime,
wchar_t buf[64] = {};
FXSYS_wcsftime(buf, 64, cFormat.c_str(), &time);
cFormat = buf;
- return CJS_Return::Success(pRuntime->NewString(cFormat.c_str()));
+ return CJS_Result::Success(pRuntime->NewString(cFormat.c_str()));
}
-CJS_Return CJS_Util::printx(CJS_Runtime* pRuntime,
+CJS_Result CJS_Util::printx(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() < 2)
- return CJS_Return::Failure(JSMessage::kParamError);
+ return CJS_Result::Failure(JSMessage::kParamError);
- return CJS_Return::Success(
+ return CJS_Result::Success(
pRuntime->NewString(printx(pRuntime->ToWideString(params[0]),
pRuntime->ToWideString(params[1]))
.AsStringView()));
@@ -361,10 +361,10 @@ WideString CJS_Util::printx(const WideString& wsFormat,
return wsResult;
}
-CJS_Return CJS_Util::scand(CJS_Runtime* pRuntime,
+CJS_Result CJS_Util::scand(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() < 2)
- return CJS_Return::Failure(JSMessage::kParamError);
+ return CJS_Result::Failure(JSMessage::kParamError);
WideString sFormat = pRuntime->ToWideString(params[0]);
WideString sDate = pRuntime->ToWideString(params[1]);
@@ -372,23 +372,23 @@ CJS_Return CJS_Util::scand(CJS_Runtime* pRuntime,
if (sDate.GetLength() > 0)
dDate = CJS_PublicMethods::MakeRegularDate(sDate, sFormat, nullptr);
if (std::isnan(dDate))
- return CJS_Return::Success(pRuntime->NewUndefined());
+ return CJS_Result::Success(pRuntime->NewUndefined());
- return CJS_Return::Success(pRuntime->NewDate(dDate));
+ return CJS_Result::Success(pRuntime->NewDate(dDate));
}
-CJS_Return CJS_Util::byteToChar(
+CJS_Result CJS_Util::byteToChar(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() < 1)
- return CJS_Return::Failure(JSMessage::kParamError);
+ return CJS_Result::Failure(JSMessage::kParamError);
int arg = pRuntime->ToInt32(params[0]);
if (arg < 0 || arg > 255)
- return CJS_Return::Failure(JSMessage::kValueError);
+ return CJS_Result::Failure(JSMessage::kValueError);
WideString wStr(static_cast<wchar_t>(arg));
- return CJS_Return::Success(pRuntime->NewString(wStr.AsStringView()));
+ return CJS_Result::Success(pRuntime->NewString(wStr.AsStringView()));
}
// Ensure that sFormat contains at most one well-understood printf formatting