summaryrefslogtreecommitdiff
path: root/fxjs/cfxjse_formcalc_context.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-12-04 18:20:07 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-12-04 18:20:07 +0000
commit9256ad5784fc437f60fbeb836fe2ecd18e028a5d (patch)
tree484d9e9c4697d50800c574b58d5db4cfa349b27c /fxjs/cfxjse_formcalc_context.cpp
parent76e336d26e78f6c6b5cdede6bb4b94ebddf3a2b1 (diff)
downloadpdfium-9256ad5784fc437f60fbeb836fe2ecd18e028a5d.tar.xz
Cleanup ResolveObjects params and return
The return value of ResolveObjects is always used as a boolean, so change from int32_t. The XFA_RESOLVENODE_RS object was made a pointer from a ref. Change-Id: I030036c01101680e36f4ddf524b468354a2e6850 Reviewed-on: https://pdfium-review.googlesource.com/20331 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fxjs/cfxjse_formcalc_context.cpp')
-rw-r--r--fxjs/cfxjse_formcalc_context.cpp45
1 files changed, 22 insertions, 23 deletions
diff --git a/fxjs/cfxjse_formcalc_context.cpp b/fxjs/cfxjse_formcalc_context.cpp
index b396db39b1..4bfe7d8b8b 100644
--- a/fxjs/cfxjse_formcalc_context.cpp
+++ b/fxjs/cfxjse_formcalc_context.cpp
@@ -5263,7 +5263,7 @@ void CFXJSE_FormCalcContext::dot_accessor(CFXJSE_Value* pThis,
XFA_RESOLVENODE_RS resolveNodeRS;
if (ResolveObjects(pThis, hJSObjValue.get(), szSomExp.AsStringView(),
- resolveNodeRS, true, szName.IsEmpty()) > 0) {
+ &resolveNodeRS, true, szName.IsEmpty())) {
ParseResolveResult(pThis, resolveNodeRS, hJSObjValue.get(),
&resolveValues[i - 2], &bAttribute);
iCounter += resolveValues[i - 2].size();
@@ -5298,19 +5298,19 @@ void CFXJSE_FormCalcContext::dot_accessor(CFXJSE_Value* pThis,
}
XFA_RESOLVENODE_RS resolveNodeRS;
- int32_t iRet = 0;
+ bool iRet = false;
ByteString bsAccessorName = args.GetUTF8String(1);
if (argAccessor->IsObject() ||
(argAccessor->IsNull() && bsAccessorName.IsEmpty())) {
iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringView(),
- resolveNodeRS, true, szName.IsEmpty());
+ &resolveNodeRS, true, szName.IsEmpty());
} else if (!argAccessor->IsObject() && !bsAccessorName.IsEmpty() &&
GetObjectForName(pThis, argAccessor.get(),
bsAccessorName.AsStringView())) {
iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringView(),
- resolveNodeRS, true, szName.IsEmpty());
+ &resolveNodeRS, true, szName.IsEmpty());
}
- if (iRet < 1) {
+ if (!iRet) {
pContext->ThrowPropertyNotInObjectException(
WideString::FromUTF8(szName.AsStringView()),
WideString::FromUTF8(szSomExp.AsStringView()));
@@ -5381,7 +5381,7 @@ void CFXJSE_FormCalcContext::dotdot_accessor(CFXJSE_Value* pThis,
argAccessor->GetObjectPropertyByIdx(i, hJSObjValue.get());
XFA_RESOLVENODE_RS resolveNodeRS;
if (ResolveObjects(pThis, hJSObjValue.get(), szSomExp.AsStringView(),
- resolveNodeRS, false) > 0) {
+ &resolveNodeRS, false, false)) {
ParseResolveResult(pThis, resolveNodeRS, hJSObjValue.get(),
&resolveValues[i - 2], &bAttribute);
iCounter += resolveValues[i - 2].size();
@@ -5416,19 +5416,19 @@ void CFXJSE_FormCalcContext::dotdot_accessor(CFXJSE_Value* pThis,
}
XFA_RESOLVENODE_RS resolveNodeRS;
- int32_t iRet = 0;
+ bool iRet = false;
ByteString bsAccessorName = args.GetUTF8String(1);
if (argAccessor->IsObject() ||
(argAccessor->IsNull() && bsAccessorName.IsEmpty())) {
iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringView(),
- resolveNodeRS, false);
+ &resolveNodeRS, false, false);
} else if (!argAccessor->IsObject() && !bsAccessorName.IsEmpty() &&
GetObjectForName(pThis, argAccessor.get(),
bsAccessorName.AsStringView())) {
iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringView(),
- resolveNodeRS, false);
+ &resolveNodeRS, false, false);
}
- if (iRet < 1) {
+ if (!iRet) {
pContext->ThrowPropertyNotInObjectException(
WideString::FromUTF8(szName.AsStringView()),
WideString::FromUTF8(szSomExp.AsStringView()));
@@ -5913,11 +5913,11 @@ bool CFXJSE_FormCalcContext::GetObjectForName(
XFA_RESOLVENODE_RS resolveNodeRS;
uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent;
- int32_t iRet = pScriptContext->ResolveObjects(
+ bool iRet = pScriptContext->ResolveObjects(
pScriptContext->GetThisObject(),
- WideString::FromUTF8(szAccessorName).AsStringView(), resolveNodeRS,
- dwFlags);
- if (iRet >= 1 && resolveNodeRS.dwFlags == XFA_RESOLVENODE_RSTYPE_Nodes) {
+ WideString::FromUTF8(szAccessorName).AsStringView(), &resolveNodeRS,
+ dwFlags, nullptr);
+ if (iRet && resolveNodeRS.dwFlags == XFA_RESOLVENODE_RSTYPE_Nodes) {
accessorValue->Assign(
pScriptContext->GetJSValueFromMap(resolveNodeRS.objects.front()));
return true;
@@ -5926,16 +5926,15 @@ bool CFXJSE_FormCalcContext::GetObjectForName(
}
// static
-int32_t CFXJSE_FormCalcContext::ResolveObjects(
- CFXJSE_Value* pThis,
- CFXJSE_Value* pRefValue,
- const ByteStringView& bsSomExp,
- XFA_RESOLVENODE_RS& resolveNodeRS,
- bool bdotAccessor,
- bool bHasNoResolveName) {
+bool CFXJSE_FormCalcContext::ResolveObjects(CFXJSE_Value* pThis,
+ CFXJSE_Value* pRefValue,
+ const ByteStringView& bsSomExp,
+ XFA_RESOLVENODE_RS* resolveNodeRS,
+ bool bdotAccessor,
+ bool bHasNoResolveName) {
CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument();
if (!pDoc)
- return -1;
+ return false;
WideString wsSomExpression = WideString::FromUTF8(bsSomExp);
CFXJSE_Engine* pScriptContext = pDoc->GetScriptContext();
@@ -5973,7 +5972,7 @@ int32_t CFXJSE_FormCalcContext::ResolveObjects(
dFlags = XFA_RESOLVENODE_AnyChild;
}
return pScriptContext->ResolveObjects(pNode, wsSomExpression.AsStringView(),
- resolveNodeRS, dFlags);
+ resolveNodeRS, dFlags, nullptr);
}
// static