Replace CFX_WideStringCArray with std::vector.

Review-Url: https://codereview.chromium.org/2562833002
diff --git a/core/fxcrt/fx_basic.h b/core/fxcrt/fx_basic.h
index 30673f6..d320e7d 100644
--- a/core/fxcrt/fx_basic.h
+++ b/core/fxcrt/fx_basic.h
@@ -317,7 +317,6 @@
 };
 
 #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 a668fc9..a4d1195 100644
--- a/xfa/fxfa/fm2js/xfa_expression.cpp
+++ b/xfa/fxfa/fm2js/xfa_expression.cpp
@@ -34,12 +34,12 @@
     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 @@
     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 a19df26..6b55ea5 100644
--- a/xfa/fxfa/fm2js/xfa_expression.h
+++ b/xfa/fxfa/fm2js/xfa_expression.h
@@ -40,13 +40,13 @@
 
 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 @@
 
  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 53e9466..2dfdfdb 100644
--- a/xfa/fxfa/fm2js/xfa_fmparse.cpp
+++ b/xfa/fxfa/fm2js/xfa_fmparse.cpp
@@ -78,9 +78,8 @@
 }
 
 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 @@
   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 @@
     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 4d37f74..514b7a6 100644
--- a/xfa/fxfa/fm2js/xfa_program.cpp
+++ b/xfa/fxfa/fm2js/xfa_program.cpp
@@ -26,8 +26,9 @@
   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;
 }