summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fxcrt/fx_basic.h1
-rw-r--r--xfa/fxfa/fm2js/xfa_expression.cpp33
-rw-r--r--xfa/fxfa/fm2js/xfa_expression.h8
-rw-r--r--xfa/fxfa/fm2js/xfa_fmparse.cpp20
-rw-r--r--xfa/fxfa/fm2js/xfa_program.cpp3
5 files changed, 28 insertions, 37 deletions
diff --git a/core/fxcrt/fx_basic.h b/core/fxcrt/fx_basic.h
index 30673f6525..d320e7d786 100644
--- a/core/fxcrt/fx_basic.h
+++ b/core/fxcrt/fx_basic.h
@@ -317,7 +317,6 @@ class CFX_ArrayTemplate : public CFX_BasicArray {
};
#ifdef PDF_ENABLE_XFA
-typedef CFX_ArrayTemplate<CFX_WideStringC> CFX_WideStringCArray;
typedef CFX_ArrayTemplate<FX_FLOAT> CFX_FloatArray;
typedef CFX_ArrayTemplate<uint8_t> CFX_ByteArray;
typedef CFX_ArrayTemplate<int32_t> CFX_Int32Array;
diff --git a/xfa/fxfa/fm2js/xfa_expression.cpp b/xfa/fxfa/fm2js/xfa_expression.cpp
index a668fc9089..a4d1195933 100644
--- a/xfa/fxfa/fm2js/xfa_expression.cpp
+++ b/xfa/fxfa/fm2js/xfa_expression.cpp
@@ -34,12 +34,12 @@ CXFA_FMFunctionDefinition::CXFA_FMFunctionDefinition(
uint32_t line,
bool isGlobal,
const CFX_WideStringC& wsName,
- std::unique_ptr<CFX_WideStringCArray> pArguments,
- std::vector<std::unique_ptr<CXFA_FMExpression>>&& pExpressions)
+ std::vector<CFX_WideStringC>&& arguments,
+ std::vector<std::unique_ptr<CXFA_FMExpression>>&& expressions)
: CXFA_FMExpression(line, XFA_FM_EXPTYPE_FUNC),
m_wsName(wsName),
- m_pArguments(std::move(pArguments)),
- m_pExpressions(std::move(pExpressions)),
+ m_pArguments(std::move(arguments)),
+ m_pExpressions(std::move(expressions)),
m_isGlobal(isGlobal) {}
CXFA_FMFunctionDefinition::~CXFA_FMFunctionDefinition() {}
@@ -60,21 +60,18 @@ void CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << m_wsName;
}
javascript << FX_WSTRC(L"(");
- if (m_pArguments != 0) {
- CFX_WideStringC identifier = 0;
- for (int i = 0; i < m_pArguments->GetSize(); ++i) {
- identifier = m_pArguments->GetAt(i);
- if (identifier.GetAt(0) == L'!') {
- CFX_WideString tempIdentifier =
- EXCLAMATION_IN_IDENTIFIER + identifier.Mid(1);
- javascript << tempIdentifier;
- } else {
- javascript << identifier;
- }
- if (i + 1 < m_pArguments->GetSize()) {
- javascript << FX_WSTRC(L", ");
- }
+ bool bNeedComma = false;
+ for (const auto& identifier : m_pArguments) {
+ if (bNeedComma)
+ javascript << FX_WSTRC(L", ");
+ if (identifier.GetAt(0) == L'!') {
+ CFX_WideString tempIdentifier =
+ EXCLAMATION_IN_IDENTIFIER + identifier.Mid(1);
+ javascript << tempIdentifier;
+ } else {
+ javascript << identifier;
}
+ bNeedComma = true;
}
javascript << FX_WSTRC(L")\n{\n");
javascript << FX_WSTRC(L"var ");
diff --git a/xfa/fxfa/fm2js/xfa_expression.h b/xfa/fxfa/fm2js/xfa_expression.h
index a19df268b8..6b55ea5815 100644
--- a/xfa/fxfa/fm2js/xfa_expression.h
+++ b/xfa/fxfa/fm2js/xfa_expression.h
@@ -40,13 +40,13 @@ class CXFA_FMExpression {
class CXFA_FMFunctionDefinition : public CXFA_FMExpression {
public:
- // Takes ownership of |pExpressions|.
+ // Takes ownership of |arguments| and |expressions|.
CXFA_FMFunctionDefinition(
uint32_t line,
bool isGlobal,
const CFX_WideStringC& wsName,
- std::unique_ptr<CFX_WideStringCArray> pArguments,
- std::vector<std::unique_ptr<CXFA_FMExpression>>&& pExpressions);
+ std::vector<CFX_WideStringC>&& arguments,
+ std::vector<std::unique_ptr<CXFA_FMExpression>>&& expressions);
~CXFA_FMFunctionDefinition() override;
void ToJavaScript(CFX_WideTextBuf& javascript) override;
@@ -54,7 +54,7 @@ class CXFA_FMFunctionDefinition : public CXFA_FMExpression {
private:
CFX_WideStringC m_wsName;
- std::unique_ptr<CFX_WideStringCArray> m_pArguments;
+ std::vector<CFX_WideStringC> m_pArguments;
std::vector<std::unique_ptr<CXFA_FMExpression>> m_pExpressions;
bool m_isGlobal;
};
diff --git a/xfa/fxfa/fm2js/xfa_fmparse.cpp b/xfa/fxfa/fm2js/xfa_fmparse.cpp
index 53e94666de..2dfdfdb4d2 100644
--- a/xfa/fxfa/fm2js/xfa_fmparse.cpp
+++ b/xfa/fxfa/fm2js/xfa_fmparse.cpp
@@ -78,9 +78,8 @@ CXFA_FMParse::ParseTopExpression() {
}
std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseFunction() {
- std::unique_ptr<CXFA_FMExpression> expr;
CFX_WideStringC ident;
- std::unique_ptr<CFX_WideStringCArray> pArguments;
+ std::vector<CFX_WideStringC> arguments;
std::vector<std::unique_ptr<CXFA_FMExpression>> expressions;
uint32_t line = m_pToken->m_uLinenum;
NextToken();
@@ -96,12 +95,9 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseFunction() {
if (m_pToken->m_type == TOKrparen) {
NextToken();
} else {
- pArguments = pdfium::MakeUnique<CFX_WideStringCArray>();
- CFX_WideStringC p;
while (1) {
if (m_pToken->m_type == TOKidentifier) {
- p = m_pToken->m_wstring;
- pArguments->Add(p);
+ arguments.push_back(m_pToken->m_wstring);
NextToken();
if (m_pToken->m_type == TOKcomma) {
NextToken();
@@ -129,13 +125,11 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseFunction() {
expressions = ParseTopExpression();
Check(TOKendfunc);
}
- if (m_pErrorInfo->message.IsEmpty()) {
- expr = pdfium::MakeUnique<CXFA_FMFunctionDefinition>(
- line, false, ident, std::move(pArguments), std::move(expressions));
- } else if (pArguments) {
- pArguments->RemoveAll();
- }
- return expr;
+ if (!m_pErrorInfo->message.IsEmpty())
+ return nullptr;
+
+ return pdfium::MakeUnique<CXFA_FMFunctionDefinition>(
+ line, false, ident, std::move(arguments), std::move(expressions));
}
std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseExpression() {
diff --git a/xfa/fxfa/fm2js/xfa_program.cpp b/xfa/fxfa/fm2js/xfa_program.cpp
index 4d37f74767..514b7a6a23 100644
--- a/xfa/fxfa/fm2js/xfa_program.cpp
+++ b/xfa/fxfa/fm2js/xfa_program.cpp
@@ -26,8 +26,9 @@ int32_t CXFA_FMProgram::ParseProgram() {
if (!m_pErrorInfo.message.IsEmpty())
return -1;
+ std::vector<CFX_WideStringC> arguments;
m_globalFunction = pdfium::MakeUnique<CXFA_FMFunctionDefinition>(
- 1, true, L"", nullptr, std::move(expressions));
+ 1, true, L"", std::move(arguments), std::move(expressions));
return 0;
}