Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: xfa/fxfa/fm2js/xfa_fmparse.cpp

Issue 2562833002: Replace CFX_WideStringCArray with std::vector. (Closed)
Patch Set: comment Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/fm2js/xfa_expression.cpp ('k') | xfa/fxfa/fm2js/xfa_program.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fxfa/fm2js/xfa_fmparse.h" 7 #include "xfa/fxfa/fm2js/xfa_fmparse.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 expressions.push_back(std::move(expr)); 71 expressions.push_back(std::move(expr));
72 } else { 72 } else {
73 break; 73 break;
74 } 74 }
75 } 75 }
76 } 76 }
77 return expressions; 77 return expressions;
78 } 78 }
79 79
80 std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseFunction() { 80 std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseFunction() {
81 std::unique_ptr<CXFA_FMExpression> expr;
82 CFX_WideStringC ident; 81 CFX_WideStringC ident;
83 std::unique_ptr<CFX_WideStringCArray> pArguments; 82 std::vector<CFX_WideStringC> arguments;
84 std::vector<std::unique_ptr<CXFA_FMExpression>> expressions; 83 std::vector<std::unique_ptr<CXFA_FMExpression>> expressions;
85 uint32_t line = m_pToken->m_uLinenum; 84 uint32_t line = m_pToken->m_uLinenum;
86 NextToken(); 85 NextToken();
87 if (m_pToken->m_type != TOKidentifier) { 86 if (m_pToken->m_type != TOKidentifier) {
88 CFX_WideString ws_TempString(m_pToken->m_wstring); 87 CFX_WideString ws_TempString(m_pToken->m_wstring);
89 Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier, 88 Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier,
90 ws_TempString.c_str()); 89 ws_TempString.c_str());
91 } else { 90 } else {
92 ident = m_pToken->m_wstring; 91 ident = m_pToken->m_wstring;
93 NextToken(); 92 NextToken();
94 } 93 }
95 Check(TOKlparen); 94 Check(TOKlparen);
96 if (m_pToken->m_type == TOKrparen) { 95 if (m_pToken->m_type == TOKrparen) {
97 NextToken(); 96 NextToken();
98 } else { 97 } else {
99 pArguments = pdfium::MakeUnique<CFX_WideStringCArray>();
100 CFX_WideStringC p;
101 while (1) { 98 while (1) {
102 if (m_pToken->m_type == TOKidentifier) { 99 if (m_pToken->m_type == TOKidentifier) {
103 p = m_pToken->m_wstring; 100 arguments.push_back(m_pToken->m_wstring);
104 pArguments->Add(p);
105 NextToken(); 101 NextToken();
106 if (m_pToken->m_type == TOKcomma) { 102 if (m_pToken->m_type == TOKcomma) {
107 NextToken(); 103 NextToken();
108 continue; 104 continue;
109 } else if (m_pToken->m_type == TOKrparen) { 105 } else if (m_pToken->m_type == TOKrparen) {
110 NextToken(); 106 NextToken();
111 break; 107 break;
112 } else { 108 } else {
113 Check(TOKrparen); 109 Check(TOKrparen);
114 break; 110 break;
115 } 111 }
116 } else { 112 } else {
117 CFX_WideString ws_TempString(m_pToken->m_wstring); 113 CFX_WideString ws_TempString(m_pToken->m_wstring);
118 Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier, 114 Error(m_pToken->m_uLinenum, kFMErrExpectedIdentifier,
119 ws_TempString.c_str()); 115 ws_TempString.c_str());
120 NextToken(); 116 NextToken();
121 break; 117 break;
122 } 118 }
123 } 119 }
124 } 120 }
125 Check(TOKdo); 121 Check(TOKdo);
126 if (m_pToken->m_type == TOKendfunc) { 122 if (m_pToken->m_type == TOKendfunc) {
127 NextToken(); 123 NextToken();
128 } else { 124 } else {
129 expressions = ParseTopExpression(); 125 expressions = ParseTopExpression();
130 Check(TOKendfunc); 126 Check(TOKendfunc);
131 } 127 }
132 if (m_pErrorInfo->message.IsEmpty()) { 128 if (!m_pErrorInfo->message.IsEmpty())
133 expr = pdfium::MakeUnique<CXFA_FMFunctionDefinition>( 129 return nullptr;
134 line, false, ident, std::move(pArguments), std::move(expressions)); 130
135 } else if (pArguments) { 131 return pdfium::MakeUnique<CXFA_FMFunctionDefinition>(
136 pArguments->RemoveAll(); 132 line, false, ident, std::move(arguments), std::move(expressions));
137 }
138 return expr;
139 } 133 }
140 134
141 std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseExpression() { 135 std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseExpression() {
142 std::unique_ptr<CXFA_FMExpression> expr; 136 std::unique_ptr<CXFA_FMExpression> expr;
143 uint32_t line = m_pToken->m_uLinenum; 137 uint32_t line = m_pToken->m_uLinenum;
144 switch (m_pToken->m_type) { 138 switch (m_pToken->m_type) {
145 case TOKvar: 139 case TOKvar:
146 expr = ParseVarExpression(); 140 expr = ParseVarExpression();
147 break; 141 break;
148 case TOKnull: 142 case TOKnull:
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseDoExpression() { 1013 std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseDoExpression() {
1020 uint32_t line = m_pToken->m_uLinenum; 1014 uint32_t line = m_pToken->m_uLinenum;
1021 NextToken(); 1015 NextToken();
1022 std::unique_ptr<CXFA_FMExpression> expr = ParseBlockExpression(); 1016 std::unique_ptr<CXFA_FMExpression> expr = ParseBlockExpression();
1023 Check(TOKend); 1017 Check(TOKend);
1024 if (!m_pErrorInfo->message.IsEmpty()) 1018 if (!m_pErrorInfo->message.IsEmpty())
1025 return nullptr; 1019 return nullptr;
1026 1020
1027 return pdfium::MakeUnique<CXFA_FMDoExpression>(line, std::move(expr)); 1021 return pdfium::MakeUnique<CXFA_FMDoExpression>(line, std::move(expr));
1028 } 1022 }
OLDNEW
« no previous file with comments | « xfa/fxfa/fm2js/xfa_expression.cpp ('k') | xfa/fxfa/fm2js/xfa_program.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698