summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2016-12-01 15:15:49 -0500
committerChromium commit bot <commit-bot@chromium.org>2016-12-01 20:34:10 +0000
commit991f61869cfba58206cc7ec038fe8d5305bbb2ba (patch)
tree5935ae9cecb17d07cbd2023cefc429050fdb5319 /xfa/fxfa
parent8a463c5a1a2252b5fdbff3b5ab07d50273bbc391 (diff)
downloadpdfium-991f61869cfba58206cc7ec038fe8d5305bbb2ba.tar.xz
Move Init to constructor in CXFA_FMProgram
Change-Id: I6b2d1a5b06211b32f3053aad4d7ae7501ec8d8f6 Reviewed-on: https://pdfium-review.googlesource.com/2093 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/fm2js/xfa_fm2jscontext.cpp10
-rw-r--r--xfa/fxfa/fm2js/xfa_fmparse.cpp13
-rw-r--r--xfa/fxfa/fm2js/xfa_fmparse.h5
-rw-r--r--xfa/fxfa/fm2js/xfa_program.cpp7
-rw-r--r--xfa/fxfa/fm2js/xfa_program.h3
5 files changed, 12 insertions, 26 deletions
diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
index 4394455c74..8bcdcdda31 100644
--- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
@@ -6482,14 +6482,8 @@ int32_t CXFA_FM2JSContext::Translate(const CFX_WideStringC& wsFormcalc,
wsError.clear();
return 0;
}
- int32_t status = 0;
- CXFA_FMProgram program;
- status = program.Init(wsFormcalc);
- if (status) {
- wsError = program.GetError().message;
- return status;
- }
- status = program.ParseProgram();
+ CXFA_FMProgram program(wsFormcalc);
+ int32_t status = program.ParseProgram();
if (status) {
wsError = program.GetError().message;
return status;
diff --git a/xfa/fxfa/fm2js/xfa_fmparse.cpp b/xfa/fxfa/fm2js/xfa_fmparse.cpp
index 2d287da3b1..53e94666de 100644
--- a/xfa/fxfa/fm2js/xfa_fmparse.cpp
+++ b/xfa/fxfa/fm2js/xfa_fmparse.cpp
@@ -12,17 +12,14 @@
#include "third_party/base/ptr_util.h"
-CXFA_FMParse::CXFA_FMParse() : m_pToken(nullptr), m_pErrorInfo(0) {}
-
-CXFA_FMParse::~CXFA_FMParse() {}
-
-int32_t CXFA_FMParse::Init(const CFX_WideStringC& wsFormcalc,
- CXFA_FMErrorInfo* pErrorInfo) {
- m_pErrorInfo = pErrorInfo;
+CXFA_FMParse::CXFA_FMParse(const CFX_WideStringC& wsFormcalc,
+ CXFA_FMErrorInfo* pErrorInfo)
+ : m_pToken(nullptr), m_pErrorInfo(pErrorInfo) {
m_lexer = pdfium::MakeUnique<CXFA_FMLexer>(wsFormcalc, m_pErrorInfo);
- return 0;
}
+CXFA_FMParse::~CXFA_FMParse() {}
+
void CXFA_FMParse::NextToken() {
m_pToken = m_lexer->NextToken();
while (m_pToken->m_type == TOKreserver) {
diff --git a/xfa/fxfa/fm2js/xfa_fmparse.h b/xfa/fxfa/fm2js/xfa_fmparse.h
index 5f8022f270..8f2671d1b0 100644
--- a/xfa/fxfa/fm2js/xfa_fmparse.h
+++ b/xfa/fxfa/fm2js/xfa_fmparse.h
@@ -15,10 +15,9 @@
class CXFA_FMParse {
public:
- CXFA_FMParse();
+ CXFA_FMParse(const CFX_WideStringC& wsFormcalc, CXFA_FMErrorInfo* pErrorInfo);
~CXFA_FMParse();
- int32_t Init(const CFX_WideStringC& wsFormcalc, CXFA_FMErrorInfo* pErrorInfo);
void NextToken();
void Check(XFA_FM_TOKEN op);
void Error(uint32_t lineNum, const FX_WCHAR* msg, ...);
@@ -51,7 +50,7 @@ class CXFA_FMParse {
private:
std::unique_ptr<CXFA_FMLexer> m_lexer;
CXFA_FMToken* m_pToken;
- CXFA_FMErrorInfo* m_pErrorInfo;
+ CXFA_FMErrorInfo* const m_pErrorInfo;
};
#endif // XFA_FXFA_FM2JS_XFA_FMPARSE_H_
diff --git a/xfa/fxfa/fm2js/xfa_program.cpp b/xfa/fxfa/fm2js/xfa_program.cpp
index ac18c15e6d..4d37f74767 100644
--- a/xfa/fxfa/fm2js/xfa_program.cpp
+++ b/xfa/fxfa/fm2js/xfa_program.cpp
@@ -11,14 +11,11 @@
#include "third_party/base/ptr_util.h"
-CXFA_FMProgram::CXFA_FMProgram() {}
+CXFA_FMProgram::CXFA_FMProgram(const CFX_WideStringC& wsFormcalc)
+ : m_parse(wsFormcalc, &m_pErrorInfo) {}
CXFA_FMProgram::~CXFA_FMProgram() {}
-int32_t CXFA_FMProgram::Init(const CFX_WideStringC& wsFormcalc) {
- return m_parse.Init(wsFormcalc, &m_pErrorInfo);
-}
-
int32_t CXFA_FMProgram::ParseProgram() {
m_parse.NextToken();
if (!m_pErrorInfo.message.IsEmpty())
diff --git a/xfa/fxfa/fm2js/xfa_program.h b/xfa/fxfa/fm2js/xfa_program.h
index aa29bba87b..7a2dade6fd 100644
--- a/xfa/fxfa/fm2js/xfa_program.h
+++ b/xfa/fxfa/fm2js/xfa_program.h
@@ -14,10 +14,9 @@
class CXFA_FMProgram {
public:
- CXFA_FMProgram();
+ explicit CXFA_FMProgram(const CFX_WideStringC& wsFormcalc);
~CXFA_FMProgram();
- int32_t Init(const CFX_WideStringC& wsFormcalc);
int32_t ParseProgram();
int32_t TranslateProgram(CFX_WideTextBuf& wsJavaScript);