Chromium Code Reviews| OLD | NEW |
|---|---|
| 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()) { |
|
Tom Sepez
2016/11/28 18:09:12
nit: no {}
npm
2016/11/28 20:04:39
Done.
| |
| 21 return -1; | 25 return -1; |
| 22 } | 26 } |
| 23 expressions = m_parse.ParseTopExpression(); | 27 std::vector<std::unique_ptr<CXFA_FMExpression>> expressions = |
| 24 if (!m_pErrorInfo.message.IsEmpty()) { | 28 m_parse.ParseTopExpression(); |
| 25 for (int32_t u = 0; u < expressions->GetSize(); ++u) | 29 if (!m_pErrorInfo.message.IsEmpty()) |
| 26 delete expressions->GetAt(u); | 30 return -1; |
| 27 | 31 |
| 28 delete expressions; | 32 m_globalFunction = pdfium::MakeUnique<CXFA_FMFunctionDefinition>( |
| 29 return -1; | 33 1, true, FX_WSTRC(L""), nullptr, std::move(expressions)); |
|
Tom Sepez
2016/11/28 18:09:12
nit: I think you can just pass L"" here, the ctor
npm
2016/11/28 20:04:39
Done.
| |
| 30 } | |
| 31 m_globalFunction.reset( | |
| 32 new CXFA_FMFunctionDefinition(1, 1, FX_WSTRC(L""), nullptr, 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 } |
| OLD | NEW |