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

Side by Side Diff: xfa/fxfa/fm2js/xfa_expression.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.h ('k') | xfa/fxfa/fm2js/xfa_fmparse.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_expression.h" 7 #include "xfa/fxfa/fm2js/xfa_expression.h"
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 16 matching lines...) Expand all
27 : m_type(type), m_line(line) {} 27 : m_type(type), m_line(line) {}
28 28
29 void CXFA_FMExpression::ToJavaScript(CFX_WideTextBuf& javascript) {} 29 void CXFA_FMExpression::ToJavaScript(CFX_WideTextBuf& javascript) {}
30 30
31 void CXFA_FMExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {} 31 void CXFA_FMExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {}
32 32
33 CXFA_FMFunctionDefinition::CXFA_FMFunctionDefinition( 33 CXFA_FMFunctionDefinition::CXFA_FMFunctionDefinition(
34 uint32_t line, 34 uint32_t line,
35 bool isGlobal, 35 bool isGlobal,
36 const CFX_WideStringC& wsName, 36 const CFX_WideStringC& wsName,
37 std::unique_ptr<CFX_WideStringCArray> pArguments, 37 std::vector<CFX_WideStringC>&& arguments,
38 std::vector<std::unique_ptr<CXFA_FMExpression>>&& pExpressions) 38 std::vector<std::unique_ptr<CXFA_FMExpression>>&& expressions)
39 : CXFA_FMExpression(line, XFA_FM_EXPTYPE_FUNC), 39 : CXFA_FMExpression(line, XFA_FM_EXPTYPE_FUNC),
40 m_wsName(wsName), 40 m_wsName(wsName),
41 m_pArguments(std::move(pArguments)), 41 m_pArguments(std::move(arguments)),
42 m_pExpressions(std::move(pExpressions)), 42 m_pExpressions(std::move(expressions)),
43 m_isGlobal(isGlobal) {} 43 m_isGlobal(isGlobal) {}
44 44
45 CXFA_FMFunctionDefinition::~CXFA_FMFunctionDefinition() {} 45 CXFA_FMFunctionDefinition::~CXFA_FMFunctionDefinition() {}
46 46
47 void CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) { 47 void CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) {
48 if (m_isGlobal && m_pExpressions.empty()) { 48 if (m_isGlobal && m_pExpressions.empty()) {
49 javascript << FX_WSTRC(L"// comments only"); 49 javascript << FX_WSTRC(L"// comments only");
50 return; 50 return;
51 } 51 }
52 if (m_isGlobal) { 52 if (m_isGlobal) {
53 javascript << FX_WSTRC(L"(\n"); 53 javascript << FX_WSTRC(L"(\n");
54 } 54 }
55 javascript << FX_WSTRC(L"function "); 55 javascript << FX_WSTRC(L"function ");
56 if (m_wsName.GetAt(0) == L'!') { 56 if (m_wsName.GetAt(0) == L'!') {
57 CFX_WideString tempName = EXCLAMATION_IN_IDENTIFIER + m_wsName.Mid(1); 57 CFX_WideString tempName = EXCLAMATION_IN_IDENTIFIER + m_wsName.Mid(1);
58 javascript << tempName; 58 javascript << tempName;
59 } else { 59 } else {
60 javascript << m_wsName; 60 javascript << m_wsName;
61 } 61 }
62 javascript << FX_WSTRC(L"("); 62 javascript << FX_WSTRC(L"(");
63 if (m_pArguments != 0) { 63 bool bNeedComma = false;
64 CFX_WideStringC identifier = 0; 64 for (const auto& identifier : m_pArguments) {
65 for (int i = 0; i < m_pArguments->GetSize(); ++i) { 65 if (bNeedComma)
66 identifier = m_pArguments->GetAt(i); 66 javascript << FX_WSTRC(L", ");
67 if (identifier.GetAt(0) == L'!') { 67 if (identifier.GetAt(0) == L'!') {
68 CFX_WideString tempIdentifier = 68 CFX_WideString tempIdentifier =
69 EXCLAMATION_IN_IDENTIFIER + identifier.Mid(1); 69 EXCLAMATION_IN_IDENTIFIER + identifier.Mid(1);
70 javascript << tempIdentifier; 70 javascript << tempIdentifier;
71 } else { 71 } else {
72 javascript << identifier; 72 javascript << identifier;
73 }
74 if (i + 1 < m_pArguments->GetSize()) {
75 javascript << FX_WSTRC(L", ");
76 }
77 } 73 }
74 bNeedComma = true;
78 } 75 }
79 javascript << FX_WSTRC(L")\n{\n"); 76 javascript << FX_WSTRC(L")\n{\n");
80 javascript << FX_WSTRC(L"var "); 77 javascript << FX_WSTRC(L"var ");
81 javascript << RUNTIMEFUNCTIONRETURNVALUE; 78 javascript << RUNTIMEFUNCTIONRETURNVALUE;
82 javascript << FX_WSTRC(L" = null;\n"); 79 javascript << FX_WSTRC(L" = null;\n");
83 for (const auto& expr : m_pExpressions) { 80 for (const auto& expr : m_pExpressions) {
84 if (expr == m_pExpressions.back()) 81 if (expr == m_pExpressions.back())
85 expr->ToImpliedReturnJS(javascript); 82 expr->ToImpliedReturnJS(javascript);
86 else 83 else
87 expr->ToJavaScript(javascript); 84 expr->ToJavaScript(javascript);
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 } 587 }
591 javascript << FX_WSTRC(L" = "); 588 javascript << FX_WSTRC(L" = ");
592 javascript << RUNTIMEBLOCKTEMPARRAY; 589 javascript << RUNTIMEBLOCKTEMPARRAY;
593 javascript << FX_WSTRC(L"["); 590 javascript << FX_WSTRC(L"[");
594 javascript << RUNTIMEBLOCKTEMPARRAYINDEX; 591 javascript << RUNTIMEBLOCKTEMPARRAYINDEX;
595 javascript << FX_WSTRC(L"++];\n"); 592 javascript << FX_WSTRC(L"++];\n");
596 m_pList->ToImpliedReturnJS(javascript); 593 m_pList->ToImpliedReturnJS(javascript);
597 javascript << FX_WSTRC(L"}\n"); 594 javascript << FX_WSTRC(L"}\n");
598 javascript << FX_WSTRC(L"}\n"); 595 javascript << FX_WSTRC(L"}\n");
599 } 596 }
OLDNEW
« no previous file with comments | « xfa/fxfa/fm2js/xfa_expression.h ('k') | xfa/fxfa/fm2js/xfa_fmparse.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698