Chromium Code Reviews| Index: xfa/fxfa/fm2js/xfa_simpleexpression.cpp |
| diff --git a/xfa/fxfa/fm2js/xfa_simpleexpression.cpp b/xfa/fxfa/fm2js/xfa_simpleexpression.cpp |
| index be02e51ec486cba27197aa8dc7bb097b12e7dbbf..4640585815c68291614b74002937eb75c1b1d71d 100644 |
| --- a/xfa/fxfa/fm2js/xfa_simpleexpression.cpp |
| +++ b/xfa/fxfa/fm2js/xfa_simpleexpression.cpp |
| @@ -6,6 +6,8 @@ |
| #include "xfa/fxfa/fm2js/xfa_simpleexpression.h" |
| +#include <utility> |
| + |
| #include "core/fxcrt/fx_ext.h" |
| namespace { |
| @@ -477,20 +479,13 @@ void CXFA_FMNotExpression::ToJavaScript(CFX_WideTextBuf& javascript) { |
| CXFA_FMCallExpression::CXFA_FMCallExpression( |
| uint32_t line, |
| CXFA_FMSimpleExpression* pExp, |
| - CFX_ArrayTemplate<CXFA_FMSimpleExpression*>* pArguments, |
| + std::vector<std::unique_ptr<CXFA_FMSimpleExpression>>&& pArguments, |
| bool bIsSomMethod) |
| : CXFA_FMUnaryExpression(line, TOKcall, pExp), |
| m_bIsSomMethod(bIsSomMethod), |
| - m_pArguments(pArguments) {} |
| - |
| -CXFA_FMCallExpression::~CXFA_FMCallExpression() { |
| - if (m_pArguments) { |
| - for (int i = 0; i < m_pArguments->GetSize(); ++i) |
| - delete m_pArguments->GetAt(i); |
| + m_Arguments(std::move(pArguments)) {} |
| - delete m_pArguments; |
| - } |
| -} |
| +CXFA_FMCallExpression::~CXFA_FMCallExpression() {} |
| bool CXFA_FMCallExpression::IsBuildInFunc(CFX_WideTextBuf* funcName) { |
| uint32_t uHash = FX_HashCode_GetW(funcName->AsStringC(), true); |
| @@ -537,36 +532,34 @@ void CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) { |
| if (m_bIsSomMethod) { |
| javascript << funcName; |
| javascript << FX_WSTRC(L"("); |
| - if (m_pArguments) { |
| - uint32_t methodPara = IsMethodWithObjParam(funcName.AsStringC()); |
| - if (methodPara > 0) { |
| - for (int i = 0; i < m_pArguments->GetSize(); ++i) { |
| - // Currently none of our expressions use objects for a parameter over |
| - // the 6th. Make sure we don't overflow the shift when doing this |
| - // check. If we ever need more the 32 object params we can revisit. |
| - if (i < 32 && (methodPara & (0x01 << i)) > 0) { |
| - javascript << gs_lpStrExpFuncName[GETFMJSOBJ]; |
| - } else { |
| - javascript << gs_lpStrExpFuncName[GETFMVALUE]; |
| - } |
| - javascript << FX_WSTRC(L"("); |
| - CXFA_FMSimpleExpression* e = m_pArguments->GetAt(i); |
| - e->ToJavaScript(javascript); |
| - javascript << FX_WSTRC(L")"); |
| - if (i + 1 < m_pArguments->GetSize()) { |
| - javascript << FX_WSTRC(L", "); |
| - } |
| - } |
| - } else { |
| - for (int i = 0; i < m_pArguments->GetSize(); ++i) { |
| + uint32_t methodPara = IsMethodWithObjParam(funcName.AsStringC()); |
| + if (methodPara > 0) { |
| + for (size_t i = 0; i < m_Arguments.size(); ++i) { |
| + // Currently none of our expressions use objects for a parameter over |
| + // the 6th. Make sure we don't overflow the shift when doing this |
| + // check. If we ever need more the 32 object params we can revisit. |
| + if (i < 32 && (methodPara & (0x01 << i)) > 0) { |
|
npm
2016/11/28 20:04:39
Leaving i in this for loop for now because it is b
|
| + javascript << gs_lpStrExpFuncName[GETFMJSOBJ]; |
| + } else { |
| javascript << gs_lpStrExpFuncName[GETFMVALUE]; |
| - javascript << FX_WSTRC(L"("); |
| - CXFA_FMSimpleExpression* e = m_pArguments->GetAt(i); |
| - e->ToJavaScript(javascript); |
| - javascript << FX_WSTRC(L")"); |
| - if (i + 1 < m_pArguments->GetSize()) { |
| - javascript << FX_WSTRC(L", "); |
| - } |
| + } |
| + javascript << FX_WSTRC(L"("); |
| + CXFA_FMSimpleExpression* e = m_Arguments.at(i).get(); |
| + e->ToJavaScript(javascript); |
| + javascript << FX_WSTRC(L")"); |
| + if (i + 1 < m_Arguments.size()) { |
| + javascript << FX_WSTRC(L", "); |
| + } |
| + } |
| + } else { |
| + for (size_t i = 0; i < m_Arguments.size(); ++i) { |
| + javascript << gs_lpStrExpFuncName[GETFMVALUE]; |
| + javascript << FX_WSTRC(L"("); |
| + CXFA_FMSimpleExpression* e = m_Arguments.at(i).get(); |
| + e->ToJavaScript(javascript); |
| + javascript << FX_WSTRC(L")"); |
| + if (i + 1 < m_Arguments.size()) { |
| + javascript << FX_WSTRC(L", "); |
| } |
| } |
| } |
| @@ -594,8 +587,8 @@ void CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) { |
| javascript << FX_WSTRC(L"("); |
| if (isExistsFunc) { |
| javascript << FX_WSTRC(L"\n(\nfunction ()\n{\ntry\n{\n"); |
| - if (m_pArguments && m_pArguments->GetSize() > 0) { |
| - CXFA_FMSimpleExpression* e = m_pArguments->GetAt(0); |
| + if (!m_Arguments.empty()) { |
| + CXFA_FMSimpleExpression* e = m_Arguments.at(0).get(); |
|
Tom Sepez
2016/11/28 18:09:12
nit: same comments as before, also above loops.
|
| javascript << FX_WSTRC(L"return "); |
| e->ToJavaScript(javascript); |
| javascript << FX_WSTRC(L";\n}\n"); |
| @@ -604,11 +597,11 @@ void CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) { |
| } |
| javascript << FX_WSTRC( |
| L"catch(accessExceptions)\n{\nreturn 0;\n}\n}\n).call(this)\n"); |
| - } else if (m_pArguments) { |
| - for (int i = 0; i < m_pArguments->GetSize(); ++i) { |
| - CXFA_FMSimpleExpression* e = m_pArguments->GetAt(i); |
| + } else { |
| + for (size_t i = 0; i < m_Arguments.size(); ++i) { |
| + CXFA_FMSimpleExpression* e = m_Arguments.at(i).get(); |
| e->ToJavaScript(javascript); |
| - if (i + 1 < m_pArguments->GetSize()) { |
| + if (i + 1 < m_Arguments.size()) { |
| javascript << FX_WSTRC(L", "); |
| } |
| } |