summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fxjs/cfxjse_formcalc_context.cpp32
-rw-r--r--fxjs/cfxjse_formcalc_context.h6
2 files changed, 17 insertions, 21 deletions
diff --git a/fxjs/cfxjse_formcalc_context.cpp b/fxjs/cfxjse_formcalc_context.cpp
index 94f3256a37..55233c1265 100644
--- a/fxjs/cfxjse_formcalc_context.cpp
+++ b/fxjs/cfxjse_formcalc_context.cpp
@@ -3336,8 +3336,8 @@ void CFXJSE_FormCalcContext::Oneof(CFXJSE_Value* pThis,
bool bFlags = false;
std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
- std::vector<std::unique_ptr<CFXJSE_Value>> parameterValues;
- unfoldArgs(pThis, args, &parameterValues, 1);
+ std::vector<std::unique_ptr<CFXJSE_Value>> parameterValues =
+ unfoldArgs(pThis, args);
for (const auto& value : parameterValues) {
if (simpleValueCompare(pThis, argOne.get(), value.get())) {
bFlags = true;
@@ -5764,19 +5764,18 @@ bool CFXJSE_FormCalcContext::simpleValueCompare(CFXJSE_Value* pThis,
}
// static
-void CFXJSE_FormCalcContext::unfoldArgs(
+std::vector<std::unique_ptr<CFXJSE_Value>> CFXJSE_FormCalcContext::unfoldArgs(
CFXJSE_Value* pThis,
- CFXJSE_Arguments& args,
- std::vector<std::unique_ptr<CFXJSE_Value>>* resultValues,
- int32_t iStart) {
- resultValues->clear();
+ CFXJSE_Arguments& args) {
+ std::vector<std::unique_ptr<CFXJSE_Value>> results;
int32_t iCount = 0;
v8::Isolate* pIsolate = ToFormCalcContext(pThis)->GetScriptRuntime();
int32_t argc = args.GetLength();
std::vector<std::unique_ptr<CFXJSE_Value>> argsValue;
- for (int32_t i = 0; i < argc - iStart; i++) {
- argsValue.push_back(args.GetValue(i + iStart));
+ static constexpr int kStart = 1;
+ for (int32_t i = 0; i < argc - kStart; i++) {
+ argsValue.push_back(args.GetValue(i + kStart));
if (argsValue[i]->IsArray()) {
auto lengthValue = pdfium::MakeUnique<CFXJSE_Value>(pIsolate);
argsValue[i]->GetObjectProperty("length", lengthValue.get());
@@ -5788,10 +5787,10 @@ void CFXJSE_FormCalcContext::unfoldArgs(
}
for (int32_t i = 0; i < iCount; i++)
- resultValues->push_back(pdfium::MakeUnique<CFXJSE_Value>(pIsolate));
+ results.push_back(pdfium::MakeUnique<CFXJSE_Value>(pIsolate));
int32_t index = 0;
- for (int32_t i = 0; i < argc - iStart; i++) {
+ for (int32_t i = 0; i < argc - kStart; i++) {
if (argsValue[i]->IsArray()) {
auto lengthValue = pdfium::MakeUnique<CFXJSE_Value>(pIsolate);
argsValue[i]->GetObjectProperty("length", lengthValue.get());
@@ -5805,27 +5804,26 @@ void CFXJSE_FormCalcContext::unfoldArgs(
if (propertyValue->IsNull()) {
for (int32_t j = 2; j < iLength; j++) {
argsValue[i]->GetObjectPropertyByIdx(j, jsObjectValue.get());
- GetObjectDefaultValue(jsObjectValue.get(),
- (*resultValues)[index].get());
+ GetObjectDefaultValue(jsObjectValue.get(), results[index].get());
index++;
}
} else {
for (int32_t j = 2; j < iLength; j++) {
argsValue[i]->GetObjectPropertyByIdx(j, jsObjectValue.get());
jsObjectValue->GetObjectProperty(
- propertyValue->ToString().AsStringView(),
- (*resultValues)[index].get());
+ propertyValue->ToString().AsStringView(), results[index].get());
index++;
}
}
} else if (argsValue[i]->IsObject()) {
- GetObjectDefaultValue(argsValue[i].get(), (*resultValues)[index].get());
+ GetObjectDefaultValue(argsValue[i].get(), results[index].get());
index++;
} else {
- (*resultValues)[index]->Assign(argsValue[i].get());
+ results[index]->Assign(argsValue[i].get());
index++;
}
}
+ return results;
}
// static
diff --git a/fxjs/cfxjse_formcalc_context.h b/fxjs/cfxjse_formcalc_context.h
index f60560315e..e95cc5f98c 100644
--- a/fxjs/cfxjse_formcalc_context.h
+++ b/fxjs/cfxjse_formcalc_context.h
@@ -343,11 +343,9 @@ class CFXJSE_FormCalcContext : public CFXJSE_HostObject {
static bool simpleValueCompare(CFXJSE_Value* pThis,
CFXJSE_Value* firstValue,
CFXJSE_Value* secondValue);
- static void unfoldArgs(
+ static std::vector<std::unique_ptr<CFXJSE_Value>> unfoldArgs(
CFXJSE_Value* pThis,
- CFXJSE_Arguments& args,
- std::vector<std::unique_ptr<CFXJSE_Value>>* resultValues,
- int32_t iStart = 0);
+ CFXJSE_Arguments& args);
static void GetObjectDefaultValue(CFXJSE_Value* pObjectValue,
CFXJSE_Value* pDefaultValue);
static bool SetObjectDefaultValue(CFXJSE_Value* pObjectValue,