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 CXFA_FMProgram()9CXFA_FMProgram::CXFA_FMProgram() : m_globalFunction(0) {} ~CXFA_FMProgram()10CXFA_FMProgram::~CXFA_FMProgram() { 11 if (m_globalFunction != 0) { 12 delete m_globalFunction; 13 m_globalFunction = 0; 14 } 15 } Init(const CFX_WideStringC & wsFormcalc)16int32_t CXFA_FMProgram::Init(const CFX_WideStringC& wsFormcalc) { 17 return m_parse.Init(wsFormcalc, &m_pErrorInfo); 18 } ParseProgram()19int32_t CXFA_FMProgram::ParseProgram() { 20 CFX_ArrayTemplate<CXFA_FMExpression*>* expressions = nullptr; 21 m_parse.NextToken(); 22 if (!m_pErrorInfo.message.IsEmpty()) { 23 return -1; 24 } 25 expressions = m_parse.ParseTopExpression(); 26 if (!m_pErrorInfo.message.IsEmpty()) { 27 for (int32_t u = 0; u < expressions->GetSize(); ++u) 28 delete expressions->GetAt(u); 29 30 delete expressions; 31 return -1; 32 } 33 m_globalFunction = 34 new CXFA_FMFunctionDefinition(1, 1, FX_WSTRC(L""), 0, expressions); 35 return 0; 36 } TranslateProgram(CFX_WideTextBuf & wsJavaScript)37int32_t CXFA_FMProgram::TranslateProgram(CFX_WideTextBuf& wsJavaScript) { 38 m_globalFunction->ToJavaScript(wsJavaScript); 39 wsJavaScript.AppendChar(0); 40 return 0; 41 } 42