1 // Copyright 2014 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #include "xfa/fxfa/fm2js/xfa_program.h" 8 9 #include <utility> 10 #include <vector> 11 12 #include "third_party/base/ptr_util.h" 13 CXFA_FMProgram(const CFX_WideStringC & wsFormcalc)14CXFA_FMProgram::CXFA_FMProgram(const CFX_WideStringC& wsFormcalc) 15 : m_parse(wsFormcalc, &m_pErrorInfo) {} 16 ~CXFA_FMProgram()17CXFA_FMProgram::~CXFA_FMProgram() {} 18 ParseProgram()19int32_t CXFA_FMProgram::ParseProgram() { 20 m_parse.NextToken(); 21 if (!m_pErrorInfo.message.IsEmpty()) 22 return -1; 23 24 std::vector<std::unique_ptr<CXFA_FMExpression>> expressions = 25 m_parse.ParseTopExpression(); 26 if (!m_pErrorInfo.message.IsEmpty()) 27 return -1; 28 29 std::vector<CFX_WideStringC> arguments; 30 m_globalFunction = pdfium::MakeUnique<CXFA_FMFunctionDefinition>( 31 1, true, L"", std::move(arguments), std::move(expressions)); 32 return 0; 33 } 34 TranslateProgram(CFX_WideTextBuf & wsJavaScript)35int32_t CXFA_FMProgram::TranslateProgram(CFX_WideTextBuf& wsJavaScript) { 36 m_globalFunction->ToJavaScript(wsJavaScript); 37 wsJavaScript.AppendChar(0); 38 return 0; 39 } 40