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

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

Issue 2530933002: Use unique pointers in CXFA_FMParse (Closed)
Patch Set: Address comments 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_fmparse.cpp ('k') | xfa/fxfa/fm2js/xfa_simpleexpression.h » ('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_program.h" 7 #include "xfa/fxfa/fm2js/xfa_program.h"
8 8
9 #include <utility>
10 #include <vector>
11
12 #include "third_party/base/ptr_util.h"
13
9 CXFA_FMProgram::CXFA_FMProgram() {} 14 CXFA_FMProgram::CXFA_FMProgram() {}
10 15
11 CXFA_FMProgram::~CXFA_FMProgram() {} 16 CXFA_FMProgram::~CXFA_FMProgram() {}
12 17
13 int32_t CXFA_FMProgram::Init(const CFX_WideStringC& wsFormcalc) { 18 int32_t CXFA_FMProgram::Init(const CFX_WideStringC& wsFormcalc) {
14 return m_parse.Init(wsFormcalc, &m_pErrorInfo); 19 return m_parse.Init(wsFormcalc, &m_pErrorInfo);
15 } 20 }
16 21
17 int32_t CXFA_FMProgram::ParseProgram() { 22 int32_t CXFA_FMProgram::ParseProgram() {
18 CFX_ArrayTemplate<CXFA_FMExpression*>* expressions = nullptr;
19 m_parse.NextToken(); 23 m_parse.NextToken();
20 if (!m_pErrorInfo.message.IsEmpty()) { 24 if (!m_pErrorInfo.message.IsEmpty())
21 return -1; 25 return -1;
22 }
23 expressions = m_parse.ParseTopExpression();
24 if (!m_pErrorInfo.message.IsEmpty()) {
25 for (int32_t u = 0; u < expressions->GetSize(); ++u)
26 delete expressions->GetAt(u);
27 26
28 delete expressions; 27 std::vector<std::unique_ptr<CXFA_FMExpression>> expressions =
28 m_parse.ParseTopExpression();
29 if (!m_pErrorInfo.message.IsEmpty())
29 return -1; 30 return -1;
30 } 31
31 m_globalFunction.reset( 32 m_globalFunction = pdfium::MakeUnique<CXFA_FMFunctionDefinition>(
32 new CXFA_FMFunctionDefinition(1, 1, FX_WSTRC(L""), nullptr, expressions)); 33 1, true, L"", nullptr, std::move(expressions));
33 return 0; 34 return 0;
34 } 35 }
35 36
36 int32_t CXFA_FMProgram::TranslateProgram(CFX_WideTextBuf& wsJavaScript) { 37 int32_t CXFA_FMProgram::TranslateProgram(CFX_WideTextBuf& wsJavaScript) {
37 m_globalFunction->ToJavaScript(wsJavaScript); 38 m_globalFunction->ToJavaScript(wsJavaScript);
38 wsJavaScript.AppendChar(0); 39 wsJavaScript.AppendChar(0);
39 return 0; 40 return 0;
40 } 41 }
OLDNEW
« no previous file with comments | « xfa/fxfa/fm2js/xfa_fmparse.cpp ('k') | xfa/fxfa/fm2js/xfa_simpleexpression.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698