summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xfa/fxfa/fm2js/xfa_expression.cpp74
-rw-r--r--xfa/fxfa/fm2js/xfa_expression.h27
-rw-r--r--xfa/fxfa/fm2js/xfa_fmparse.cpp129
-rw-r--r--xfa/fxfa/fm2js/xfa_simpleexpression.cpp125
-rw-r--r--xfa/fxfa/fm2js/xfa_simpleexpression.h81
-rw-r--r--xfa/fxfa/fm2js/xfa_simpleexpression_unittest.cpp2
6 files changed, 229 insertions, 209 deletions
diff --git a/xfa/fxfa/fm2js/xfa_expression.cpp b/xfa/fxfa/fm2js/xfa_expression.cpp
index 8d1888a797..a668fc9089 100644
--- a/xfa/fxfa/fm2js/xfa_expression.cpp
+++ b/xfa/fxfa/fm2js/xfa_expression.cpp
@@ -103,12 +103,13 @@ void CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) {
void CXFA_FMFunctionDefinition::ToImpliedReturnJS(CFX_WideTextBuf&) {}
-CXFA_FMVarExpression::CXFA_FMVarExpression(uint32_t line,
- const CFX_WideStringC& wsName,
- CXFA_FMExpression* pInit)
+CXFA_FMVarExpression::CXFA_FMVarExpression(
+ uint32_t line,
+ const CFX_WideStringC& wsName,
+ std::unique_ptr<CXFA_FMExpression> pInit)
: CXFA_FMExpression(line, XFA_FM_EXPTYPE_VAR),
m_wsName(wsName),
- m_pInit(pInit) {}
+ m_pInit(std::move(pInit)) {}
CXFA_FMVarExpression::~CXFA_FMVarExpression() {}
@@ -158,9 +159,11 @@ void CXFA_FMVarExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
javascript << FX_WSTRC(L";\n");
}
-CXFA_FMExpExpression::CXFA_FMExpExpression(uint32_t line,
- CXFA_FMSimpleExpression* pExpression)
- : CXFA_FMExpression(line, XFA_FM_EXPTYPE_EXP), m_pExpression(pExpression) {}
+CXFA_FMExpExpression::CXFA_FMExpExpression(
+ uint32_t line,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExpression)
+ : CXFA_FMExpression(line, XFA_FM_EXPTYPE_EXP),
+ m_pExpression(std::move(pExpression)) {}
CXFA_FMExpExpression::~CXFA_FMExpExpression() {}
@@ -223,9 +226,10 @@ void CXFA_FMBlockExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
javascript << FX_WSTRC(L"}\n");
}
-CXFA_FMDoExpression::CXFA_FMDoExpression(uint32_t line,
- CXFA_FMExpression* pList)
- : CXFA_FMExpression(line), m_pList(pList) {}
+CXFA_FMDoExpression::CXFA_FMDoExpression(
+ uint32_t line,
+ std::unique_ptr<CXFA_FMExpression> pList)
+ : CXFA_FMExpression(line), m_pList(std::move(pList)) {}
CXFA_FMDoExpression::~CXFA_FMDoExpression() {}
@@ -237,14 +241,15 @@ void CXFA_FMDoExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
m_pList->ToImpliedReturnJS(javascript);
}
-CXFA_FMIfExpression::CXFA_FMIfExpression(uint32_t line,
- CXFA_FMSimpleExpression* pExpression,
- CXFA_FMExpression* pIfExpression,
- CXFA_FMExpression* pElseExpression)
+CXFA_FMIfExpression::CXFA_FMIfExpression(
+ uint32_t line,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExpression,
+ std::unique_ptr<CXFA_FMExpression> pIfExpression,
+ std::unique_ptr<CXFA_FMExpression> pElseExpression)
: CXFA_FMExpression(line, XFA_FM_EXPTYPE_IF),
- m_pExpression(pExpression),
- m_pIfExpression(pIfExpression),
- m_pElseExpression(pElseExpression) {}
+ m_pExpression(std::move(pExpression)),
+ m_pIfExpression(std::move(pIfExpression)),
+ m_pElseExpression(std::move(pElseExpression)) {}
CXFA_FMIfExpression::~CXFA_FMIfExpression() {}
@@ -308,11 +313,11 @@ void CXFA_FMLoopExpression::ToImpliedReturnJS(CFX_WideTextBuf&) {}
CXFA_FMWhileExpression::CXFA_FMWhileExpression(
uint32_t line,
- CXFA_FMSimpleExpression* pCondition,
- CXFA_FMExpression* pExpression)
+ std::unique_ptr<CXFA_FMSimpleExpression> pCondition,
+ std::unique_ptr<CXFA_FMExpression> pExpression)
: CXFA_FMLoopExpression(line),
- m_pCondition(pCondition),
- m_pExpression(pExpression) {}
+ m_pCondition(std::move(pCondition)),
+ m_pExpression(std::move(pExpression)) {}
CXFA_FMWhileExpression::~CXFA_FMWhileExpression() {}
@@ -366,20 +371,21 @@ void CXFA_FMContinueExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
javascript << FX_WSTRC(L"continue;\n");
}
-CXFA_FMForExpression::CXFA_FMForExpression(uint32_t line,
- const CFX_WideStringC& wsVariant,
- CXFA_FMSimpleExpression* pAssignment,
- CXFA_FMSimpleExpression* pAccessor,
- int32_t iDirection,
- CXFA_FMSimpleExpression* pStep,
- CXFA_FMExpression* pList)
+CXFA_FMForExpression::CXFA_FMForExpression(
+ uint32_t line,
+ const CFX_WideStringC& wsVariant,
+ std::unique_ptr<CXFA_FMSimpleExpression> pAssignment,
+ std::unique_ptr<CXFA_FMSimpleExpression> pAccessor,
+ int32_t iDirection,
+ std::unique_ptr<CXFA_FMSimpleExpression> pStep,
+ std::unique_ptr<CXFA_FMExpression> pList)
: CXFA_FMLoopExpression(line),
m_wsVariant(wsVariant),
- m_pAssignment(pAssignment),
- m_pAccessor(pAccessor),
+ m_pAssignment(std::move(pAssignment)),
+ m_pAccessor(std::move(pAccessor)),
m_iDirection(iDirection),
- m_pStep(pStep),
- m_pList(pList) {}
+ m_pStep(std::move(pStep)),
+ m_pList(std::move(pList)) {}
CXFA_FMForExpression::~CXFA_FMForExpression() {}
@@ -487,11 +493,11 @@ CXFA_FMForeachExpression::CXFA_FMForeachExpression(
uint32_t line,
const CFX_WideStringC& wsIdentifier,
std::vector<std::unique_ptr<CXFA_FMSimpleExpression>>&& pAccessors,
- CXFA_FMExpression* pList)
+ std::unique_ptr<CXFA_FMExpression> pList)
: CXFA_FMLoopExpression(line),
m_wsIdentifier(wsIdentifier),
m_pAccessors(std::move(pAccessors)),
- m_pList(pList) {}
+ m_pList(std::move(pList)) {}
CXFA_FMForeachExpression::~CXFA_FMForeachExpression() {}
diff --git a/xfa/fxfa/fm2js/xfa_expression.h b/xfa/fxfa/fm2js/xfa_expression.h
index f89a923565..a19df268b8 100644
--- a/xfa/fxfa/fm2js/xfa_expression.h
+++ b/xfa/fxfa/fm2js/xfa_expression.h
@@ -63,7 +63,7 @@ class CXFA_FMVarExpression : public CXFA_FMExpression {
public:
CXFA_FMVarExpression(uint32_t line,
const CFX_WideStringC& wsName,
- CXFA_FMExpression* pInit);
+ std::unique_ptr<CXFA_FMExpression> pInit);
~CXFA_FMVarExpression() override;
void ToJavaScript(CFX_WideTextBuf& javascript) override;
@@ -76,7 +76,8 @@ class CXFA_FMVarExpression : public CXFA_FMExpression {
class CXFA_FMExpExpression : public CXFA_FMExpression {
public:
- CXFA_FMExpExpression(uint32_t line, CXFA_FMSimpleExpression* pExpression);
+ CXFA_FMExpExpression(uint32_t line,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExpression);
~CXFA_FMExpExpression() override;
void ToJavaScript(CFX_WideTextBuf& javascript) override;
@@ -102,7 +103,7 @@ class CXFA_FMBlockExpression : public CXFA_FMExpression {
class CXFA_FMDoExpression : public CXFA_FMExpression {
public:
- CXFA_FMDoExpression(uint32_t line, CXFA_FMExpression* pList);
+ CXFA_FMDoExpression(uint32_t line, std::unique_ptr<CXFA_FMExpression> pList);
~CXFA_FMDoExpression() override;
void ToJavaScript(CFX_WideTextBuf& javascript) override;
@@ -115,9 +116,9 @@ class CXFA_FMDoExpression : public CXFA_FMExpression {
class CXFA_FMIfExpression : public CXFA_FMExpression {
public:
CXFA_FMIfExpression(uint32_t line,
- CXFA_FMSimpleExpression* pExpression,
- CXFA_FMExpression* pIfExpression,
- CXFA_FMExpression* pElseExpression);
+ std::unique_ptr<CXFA_FMSimpleExpression> pExpression,
+ std::unique_ptr<CXFA_FMExpression> pIfExpression,
+ std::unique_ptr<CXFA_FMExpression> pElseExpression);
~CXFA_FMIfExpression() override;
void ToJavaScript(CFX_WideTextBuf& javascript) override;
@@ -140,8 +141,8 @@ class CXFA_FMLoopExpression : public CXFA_FMExpression {
class CXFA_FMWhileExpression : public CXFA_FMLoopExpression {
public:
CXFA_FMWhileExpression(uint32_t line,
- CXFA_FMSimpleExpression* pCodition,
- CXFA_FMExpression* pExpression);
+ std::unique_ptr<CXFA_FMSimpleExpression> pCodition,
+ std::unique_ptr<CXFA_FMExpression> pExpression);
~CXFA_FMWhileExpression() override;
void ToJavaScript(CFX_WideTextBuf& javascript) override;
@@ -172,11 +173,11 @@ class CXFA_FMForExpression : public CXFA_FMLoopExpression {
public:
CXFA_FMForExpression(uint32_t line,
const CFX_WideStringC& wsVariant,
- CXFA_FMSimpleExpression* pAssignment,
- CXFA_FMSimpleExpression* pAccessor,
+ std::unique_ptr<CXFA_FMSimpleExpression> pAssignment,
+ std::unique_ptr<CXFA_FMSimpleExpression> pAccessor,
int32_t iDirection,
- CXFA_FMSimpleExpression* pStep,
- CXFA_FMExpression* pList);
+ std::unique_ptr<CXFA_FMSimpleExpression> pStep,
+ std::unique_ptr<CXFA_FMExpression> pList);
~CXFA_FMForExpression() override;
void ToJavaScript(CFX_WideTextBuf& javascript) override;
@@ -198,7 +199,7 @@ class CXFA_FMForeachExpression : public CXFA_FMLoopExpression {
uint32_t line,
const CFX_WideStringC& wsIdentifier,
std::vector<std::unique_ptr<CXFA_FMSimpleExpression>>&& pAccessors,
- CXFA_FMExpression* pList);
+ std::unique_ptr<CXFA_FMExpression> pList);
~CXFA_FMForeachExpression() override;
void ToJavaScript(CFX_WideTextBuf& javascript) override;
diff --git a/xfa/fxfa/fm2js/xfa_fmparse.cpp b/xfa/fxfa/fm2js/xfa_fmparse.cpp
index 07edc32c3d..2d287da3b1 100644
--- a/xfa/fxfa/fm2js/xfa_fmparse.cpp
+++ b/xfa/fxfa/fm2js/xfa_fmparse.cpp
@@ -192,7 +192,6 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseExpression() {
}
std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseVarExpression() {
- std::unique_ptr<CXFA_FMExpression> expr;
CFX_WideStringC ident;
uint32_t line = m_pToken->m_uLinenum;
NextToken();
@@ -204,17 +203,15 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseVarExpression() {
ident = m_pToken->m_wstring;
NextToken();
}
+ std::unique_ptr<CXFA_FMExpression> expr;
if (m_pToken->m_type == TOKassign) {
NextToken();
expr = ParseExpExpression();
}
- if (m_pErrorInfo->message.IsEmpty()) {
- expr =
- pdfium::MakeUnique<CXFA_FMVarExpression>(line, ident, expr.release());
- } else {
- expr.reset();
- }
- return expr;
+ if (!m_pErrorInfo->message.IsEmpty())
+ return nullptr;
+
+ return pdfium::MakeUnique<CXFA_FMVarExpression>(line, ident, std::move(expr));
}
std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParseSimpleExpression() {
@@ -225,7 +222,7 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParseSimpleExpression() {
std::unique_ptr<CXFA_FMSimpleExpression> pExp2 = ParseLogicalOrExpression();
if (m_pErrorInfo->message.IsEmpty()) {
pExp1 = pdfium::MakeUnique<CXFA_FMAssignExpression>(
- line, TOKassign, pExp1.release(), pExp2.release());
+ line, TOKassign, std::move(pExp1), std::move(pExp2));
} else {
pExp1.reset();
}
@@ -236,13 +233,10 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParseSimpleExpression() {
std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseExpExpression() {
uint32_t line = m_pToken->m_uLinenum;
std::unique_ptr<CXFA_FMSimpleExpression> pExp1 = ParseSimpleExpression();
- std::unique_ptr<CXFA_FMExpression> expr;
- if (m_pErrorInfo->message.IsEmpty()) {
- expr = pdfium::MakeUnique<CXFA_FMExpExpression>(line, pExp1.release());
- } else {
- expr.reset();
- }
- return expr;
+ if (!m_pErrorInfo->message.IsEmpty())
+ return nullptr;
+
+ return pdfium::MakeUnique<CXFA_FMExpExpression>(line, std::move(pExp1));
}
std::unique_ptr<CXFA_FMSimpleExpression>
@@ -258,7 +252,7 @@ CXFA_FMParse::ParseLogicalOrExpression() {
ParseLogicalAndExpression());
if (m_pErrorInfo->message.IsEmpty()) {
e1 = pdfium::MakeUnique<CXFA_FMLogicalOrExpression>(
- line, TOKor, e1.release(), e2.release());
+ line, TOKor, std::move(e1), std::move(e2));
} else {
e1.reset();
}
@@ -284,7 +278,7 @@ CXFA_FMParse::ParseLogicalAndExpression() {
std::unique_ptr<CXFA_FMSimpleExpression> e2 = ParseEqualityExpression();
if (m_pErrorInfo->message.IsEmpty()) {
e1 = pdfium::MakeUnique<CXFA_FMLogicalAndExpression>(
- line, TOKand, e1.release(), e2.release());
+ line, TOKand, std::move(e1), std::move(e2));
} else {
e1.reset();
}
@@ -311,7 +305,7 @@ CXFA_FMParse::ParseEqualityExpression() {
e2 = ParseRelationalExpression();
if (m_pErrorInfo->message.IsEmpty()) {
e1 = pdfium::MakeUnique<CXFA_FMEqualityExpression>(
- line, TOKeq, e1.release(), e2.release());
+ line, TOKeq, std::move(e1), std::move(e2));
} else {
e1.reset();
}
@@ -322,7 +316,7 @@ CXFA_FMParse::ParseEqualityExpression() {
e2 = ParseRelationalExpression();
if (m_pErrorInfo->message.IsEmpty()) {
e1 = pdfium::MakeUnique<CXFA_FMEqualityExpression>(
- line, TOKne, e1.release(), e2.release());
+ line, TOKne, std::move(e1), std::move(e2));
} else {
e1.reset();
}
@@ -348,7 +342,7 @@ CXFA_FMParse::ParseRelationalExpression() {
e2 = ParseAddtiveExpression();
if (m_pErrorInfo->message.IsEmpty()) {
e1 = pdfium::MakeUnique<CXFA_FMRelationalExpression>(
- line, TOKlt, e1.release(), e2.release());
+ line, TOKlt, std::move(e1), std::move(e2));
} else {
e1.reset();
}
@@ -359,7 +353,7 @@ CXFA_FMParse::ParseRelationalExpression() {
e2 = ParseAddtiveExpression();
if (m_pErrorInfo->message.IsEmpty()) {
e1 = pdfium::MakeUnique<CXFA_FMRelationalExpression>(
- line, TOKgt, e1.release(), e2.release());
+ line, TOKgt, std::move(e1), std::move(e2));
} else {
e1.reset();
}
@@ -370,7 +364,7 @@ CXFA_FMParse::ParseRelationalExpression() {
e2 = ParseAddtiveExpression();
if (m_pErrorInfo->message.IsEmpty()) {
e1 = pdfium::MakeUnique<CXFA_FMRelationalExpression>(
- line, TOKle, e1.release(), e2.release());
+ line, TOKle, std::move(e1), std::move(e2));
} else {
e1.reset();
}
@@ -381,7 +375,7 @@ CXFA_FMParse::ParseRelationalExpression() {
e2 = ParseAddtiveExpression();
if (m_pErrorInfo->message.IsEmpty()) {
e1 = pdfium::MakeUnique<CXFA_FMRelationalExpression>(
- line, TOKge, e1.release(), e2.release());
+ line, TOKge, std::move(e1), std::move(e2));
} else {
e1.reset();
}
@@ -406,7 +400,7 @@ CXFA_FMParse::ParseAddtiveExpression() {
e2 = ParseMultiplicativeExpression();
if (m_pErrorInfo->message.IsEmpty()) {
e1 = pdfium::MakeUnique<CXFA_FMAdditiveExpression>(
- line, TOKplus, e1.release(), e2.release());
+ line, TOKplus, std::move(e1), std::move(e2));
} else {
e1.reset();
}
@@ -416,7 +410,7 @@ CXFA_FMParse::ParseAddtiveExpression() {
e2 = ParseMultiplicativeExpression();
if (m_pErrorInfo->message.IsEmpty()) {
e1 = pdfium::MakeUnique<CXFA_FMAdditiveExpression>(
- line, TOKminus, e1.release(), e2.release());
+ line, TOKminus, std::move(e1), std::move(e2));
} else {
e1.reset();
}
@@ -441,7 +435,7 @@ CXFA_FMParse::ParseMultiplicativeExpression() {
e2 = ParseUnaryExpression();
if (m_pErrorInfo->message.IsEmpty()) {
e1 = pdfium::MakeUnique<CXFA_FMMultiplicativeExpression>(
- line, TOKmul, e1.release(), e2.release());
+ line, TOKmul, std::move(e1), std::move(e2));
} else {
e1.reset();
}
@@ -451,7 +445,7 @@ CXFA_FMParse::ParseMultiplicativeExpression() {
e2 = ParseUnaryExpression();
if (m_pErrorInfo->message.IsEmpty()) {
e1 = pdfium::MakeUnique<CXFA_FMMultiplicativeExpression>(
- line, TOKdiv, e1.release(), e2.release());
+ line, TOKdiv, std::move(e1), std::move(e2));
} else {
e1.reset();
}
@@ -471,29 +465,26 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParseUnaryExpression() {
case TOKplus:
NextToken();
expr = ParseUnaryExpression();
- if (m_pErrorInfo->message.IsEmpty()) {
- expr = pdfium::MakeUnique<CXFA_FMPosExpression>(line, expr.release());
- } else {
+ if (m_pErrorInfo->message.IsEmpty())
+ expr = pdfium::MakeUnique<CXFA_FMPosExpression>(line, std::move(expr));
+ else
expr.reset();
- }
break;
case TOKminus:
NextToken();
expr = ParseUnaryExpression();
- if (m_pErrorInfo->message.IsEmpty()) {
- expr = pdfium::MakeUnique<CXFA_FMNegExpression>(line, expr.release());
- } else {
+ if (m_pErrorInfo->message.IsEmpty())
+ expr = pdfium::MakeUnique<CXFA_FMNegExpression>(line, std::move(expr));
+ else
expr.reset();
- }
break;
case TOKksnot:
NextToken();
expr = ParseUnaryExpression();
- if (m_pErrorInfo->message.IsEmpty()) {
- expr = pdfium::MakeUnique<CXFA_FMNotExpression>(line, expr.release());
- } else {
+ if (m_pErrorInfo->message.IsEmpty())
+ expr = pdfium::MakeUnique<CXFA_FMNotExpression>(line, std::move(expr));
+ else
expr.reset();
- }
break;
default:
expr = ParsePrimaryExpression();
@@ -524,7 +515,7 @@ CXFA_FMParse::ParsePrimaryExpression() {
std::unique_ptr<CXFA_FMSimpleExpression> s = ParseIndexExpression();
if (s) {
expr = pdfium::MakeUnique<CXFA_FMDotAccessorExpression>(
- line, nullptr, TOKdot, wsIdentifier, s.release());
+ line, nullptr, TOKdot, wsIdentifier, std::move(s));
}
NextToken();
} else {
@@ -552,7 +543,7 @@ CXFA_FMParse::ParsePrimaryExpression() {
break;
}
expr = ParsePostExpression(std::move(expr));
- if (!(m_pErrorInfo->message.IsEmpty()))
+ if (!m_pErrorInfo->message.IsEmpty())
expr.reset();
return expr;
}
@@ -585,7 +576,7 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParsePostExpression(
}
if (m_pErrorInfo->message.IsEmpty()) {
expr = pdfium::MakeUnique<CXFA_FMCallExpression>(
- line, expr.release(), std::move(expressions), false);
+ line, std::move(expr), std::move(expressions), false);
NextToken();
if (m_pToken->m_type != TOKlbracket)
continue;
@@ -593,7 +584,7 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParsePostExpression(
std::unique_ptr<CXFA_FMSimpleExpression> s = ParseIndexExpression();
if (s) {
expr = pdfium::MakeUnique<CXFA_FMDotAccessorExpression>(
- line, expr.release(), TOKcall, FX_WSTRC(L""), s.release());
+ line, std::move(expr), TOKcall, L"", std::move(s));
} else {
expr.reset();
}
@@ -634,9 +625,9 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParsePostExpression(
pdfium::MakeUnique<CXFA_FMIdentifierExpression>(tempLine,
tempStr);
pExpCall = pdfium::MakeUnique<CXFA_FMCallExpression>(
- line, pIdentifier.release(), std::move(expressions), true);
+ line, std::move(pIdentifier), std::move(expressions), true);
expr = pdfium::MakeUnique<CXFA_FMMethodCallExpression>(
- line, expr.release(), pExpCall.release());
+ line, std::move(expr), std::move(pExpCall));
NextToken();
if (m_pToken->m_type != TOKlbracket)
continue;
@@ -645,7 +636,7 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParsePostExpression(
ParseIndexExpression();
if (s) {
expr = pdfium::MakeUnique<CXFA_FMDotAccessorExpression>(
- line, expr.release(), TOKcall, FX_WSTRC(L""), s.release());
+ line, std::move(expr), TOKcall, L"", std::move(s));
} else {
expr.reset();
}
@@ -658,13 +649,13 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParsePostExpression(
return nullptr;
expr = pdfium::MakeUnique<CXFA_FMDotAccessorExpression>(
- tempLine, expr.release(), TOKdot, tempStr, s.release());
+ tempLine, std::move(expr), TOKdot, tempStr, std::move(s));
} else {
std::unique_ptr<CXFA_FMSimpleExpression> s =
pdfium::MakeUnique<CXFA_FMIndexExpression>(
tempLine, ACCESSOR_NO_INDEX, nullptr, false);
expr = pdfium::MakeUnique<CXFA_FMDotAccessorExpression>(
- line, expr.release(), TOKdot, tempStr, s.release());
+ line, std::move(expr), TOKdot, tempStr, std::move(s));
continue;
}
} else {
@@ -686,13 +677,13 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParsePostExpression(
return nullptr;
}
expr = pdfium::MakeUnique<CXFA_FMDotDotAccessorExpression>(
- tempLine, expr.release(), TOKdotdot, tempStr, s.release());
+ tempLine, std::move(expr), TOKdotdot, tempStr, std::move(s));
} else {
std::unique_ptr<CXFA_FMSimpleExpression> s =
pdfium::MakeUnique<CXFA_FMIndexExpression>(
tempLine, ACCESSOR_NO_INDEX, nullptr, false);
expr = pdfium::MakeUnique<CXFA_FMDotDotAccessorExpression>(
- line, expr.release(), TOKdotdot, tempStr, s.release());
+ line, std::move(expr), TOKdotdot, tempStr, std::move(s));
continue;
}
} else {
@@ -714,13 +705,13 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParsePostExpression(
return nullptr;
expr = pdfium::MakeUnique<CXFA_FMDotAccessorExpression>(
- tempLine, expr.release(), TOKdotscream, tempStr, s.release());
+ tempLine, std::move(expr), TOKdotscream, tempStr, std::move(s));
} else {
std::unique_ptr<CXFA_FMSimpleExpression> s =
pdfium::MakeUnique<CXFA_FMIndexExpression>(
tempLine, ACCESSOR_NO_INDEX, nullptr, false);
expr = pdfium::MakeUnique<CXFA_FMDotAccessorExpression>(
- line, expr.release(), TOKdotscream, tempStr, s.release());
+ line, std::move(expr), TOKdotscream, tempStr, std::move(s));
continue;
}
} else {
@@ -735,7 +726,7 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParsePostExpression(
pdfium::MakeUnique<CXFA_FMIndexExpression>(line, ACCESSOR_NO_INDEX,
nullptr, false);
expr = pdfium::MakeUnique<CXFA_FMDotAccessorExpression>(
- line, expr.release(), TOKdotstar, FX_WSTRC(L"*"), s.release());
+ line, std::move(expr), TOKdotstar, L"*", std::move(s));
} break;
default:
return expr;
@@ -753,7 +744,7 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParseIndexExpression() {
XFA_FM_AccessorIndex accessorIndex = ACCESSOR_NO_RELATIVEINDEX;
if (m_pToken->m_type == TOKmul) {
pExp = pdfium::MakeUnique<CXFA_FMIndexExpression>(line, accessorIndex,
- s.release(), true);
+ std::move(s), true);
NextToken();
if (m_pToken->m_type != TOKrbracket) {
CFX_WideString ws_TempString(m_pToken->m_wstring);
@@ -777,7 +768,7 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParseIndexExpression() {
XFA_FM_KeywordToString(TOKrparen), ws_TempString.c_str());
} else {
pExp = pdfium::MakeUnique<CXFA_FMIndexExpression>(line, accessorIndex,
- s.release(), false);
+ std::move(s), false);
}
return pExp;
}
@@ -799,7 +790,7 @@ std::unique_ptr<CXFA_FMSimpleExpression> CXFA_FMParse::ParseParenExpression() {
std::unique_ptr<CXFA_FMSimpleExpression> pExp2 = ParseLogicalOrExpression();
if (m_pErrorInfo->message.IsEmpty()) {
pExp1 = pdfium::MakeUnique<CXFA_FMAssignExpression>(
- line, TOKassign, pExp1.release(), pExp2.release());
+ line, TOKassign, std::move(pExp1), std::move(pExp2));
} else {
pExp1.reset();
}
@@ -898,9 +889,9 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseIfExpression() {
}
std::unique_ptr<CXFA_FMIfExpression> pExp;
if (m_pErrorInfo->message.IsEmpty()) {
- pExp = pdfium::MakeUnique<CXFA_FMIfExpression>(line, pExpression.release(),
- pIfExpression.release(),
- pElseExpression.release());
+ pExp = pdfium::MakeUnique<CXFA_FMIfExpression>(line, std::move(pExpression),
+ std::move(pIfExpression),
+ std::move(pElseExpression));
}
return pExp;
}
@@ -915,7 +906,7 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseWhileExpression() {
std::unique_ptr<CXFA_FMExpression> expr;
if (m_pErrorInfo->message.IsEmpty()) {
expr = pdfium::MakeUnique<CXFA_FMWhileExpression>(
- line, pCondition.release(), pExpression.release());
+ line, std::move(pCondition), std::move(pExpression));
}
return expr;
}
@@ -980,8 +971,8 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseForExpression() {
std::unique_ptr<CXFA_FMExpression> expr;
if (m_pErrorInfo->message.IsEmpty()) {
expr = pdfium::MakeUnique<CXFA_FMForExpression>(
- line, wsVariant, pAssignment.release(), pAccessor.release(), iDirection,
- pStep.release(), pList.release());
+ line, wsVariant, std::move(pAssignment), std::move(pAccessor),
+ iDirection, std::move(pStep), std::move(pList));
}
return expr;
}
@@ -1023,7 +1014,7 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseForeachExpression() {
Check(TOKendfor);
if (m_pErrorInfo->message.IsEmpty()) {
expr = pdfium::MakeUnique<CXFA_FMForeachExpression>(
- line, wsIdentifier, std::move(pAccessors), pList.release());
+ line, wsIdentifier, std::move(pAccessors), std::move(pList));
}
return expr;
}
@@ -1033,10 +1024,8 @@ std::unique_ptr<CXFA_FMExpression> CXFA_FMParse::ParseDoExpression() {
NextToken();
std::unique_ptr<CXFA_FMExpression> expr = ParseBlockExpression();
Check(TOKend);
- if (m_pErrorInfo->message.IsEmpty()) {
- expr = pdfium::MakeUnique<CXFA_FMDoExpression>(line, expr.release());
- } else {
- expr.reset();
- }
- return expr;
+ if (!m_pErrorInfo->message.IsEmpty())
+ return nullptr;
+
+ return pdfium::MakeUnique<CXFA_FMDoExpression>(line, std::move(expr));
}
diff --git a/xfa/fxfa/fm2js/xfa_simpleexpression.cpp b/xfa/fxfa/fm2js/xfa_simpleexpression.cpp
index e52cd88979..342fe9f06c 100644
--- a/xfa/fxfa/fm2js/xfa_simpleexpression.cpp
+++ b/xfa/fxfa/fm2js/xfa_simpleexpression.cpp
@@ -209,30 +209,35 @@ void CXFA_FMIdentifierExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << tempStr;
}
-CXFA_FMUnaryExpression::CXFA_FMUnaryExpression(uint32_t line,
- XFA_FM_TOKEN op,
- CXFA_FMSimpleExpression* pExp)
- : CXFA_FMSimpleExpression(line, op), m_pExp(pExp) {}
+CXFA_FMUnaryExpression::CXFA_FMUnaryExpression(
+ uint32_t line,
+ XFA_FM_TOKEN op,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp)
+ : CXFA_FMSimpleExpression(line, op), m_pExp(std::move(pExp)) {}
CXFA_FMUnaryExpression::~CXFA_FMUnaryExpression() {}
void CXFA_FMUnaryExpression::ToJavaScript(CFX_WideTextBuf& javascript) {}
-CXFA_FMBinExpression::CXFA_FMBinExpression(uint32_t line,
- XFA_FM_TOKEN op,
- CXFA_FMSimpleExpression* pExp1,
- CXFA_FMSimpleExpression* pExp2)
- : CXFA_FMSimpleExpression(line, op), m_pExp1(pExp1), m_pExp2(pExp2) {}
+CXFA_FMBinExpression::CXFA_FMBinExpression(
+ uint32_t line,
+ XFA_FM_TOKEN op,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp1,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp2)
+ : CXFA_FMSimpleExpression(line, op),
+ m_pExp1(std::move(pExp1)),
+ m_pExp2(std::move(pExp2)) {}
CXFA_FMBinExpression::~CXFA_FMBinExpression() {}
void CXFA_FMBinExpression::ToJavaScript(CFX_WideTextBuf& javascript) {}
-CXFA_FMAssignExpression::CXFA_FMAssignExpression(uint32_t line,
- XFA_FM_TOKEN op,
- CXFA_FMSimpleExpression* pExp1,
- CXFA_FMSimpleExpression* pExp2)
- : CXFA_FMBinExpression(line, op, pExp1, pExp2) {}
+CXFA_FMAssignExpression::CXFA_FMAssignExpression(
+ uint32_t line,
+ XFA_FM_TOKEN op,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp1,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp2)
+ : CXFA_FMBinExpression(line, op, std::move(pExp1), std::move(pExp2)) {}
void CXFA_FMAssignExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << FX_WSTRC(L"if (");
@@ -297,9 +302,9 @@ void CXFA_FMAssignExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {
CXFA_FMLogicalOrExpression::CXFA_FMLogicalOrExpression(
uint32_t line,
XFA_FM_TOKEN op,
- CXFA_FMSimpleExpression* pExp1,
- CXFA_FMSimpleExpression* pExp2)
- : CXFA_FMBinExpression(line, op, pExp1, pExp2) {}
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp1,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp2)
+ : CXFA_FMBinExpression(line, op, std::move(pExp1), std::move(pExp2)) {}
void CXFA_FMLogicalOrExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << gs_lpStrExpFuncName[LOGICALOR];
@@ -313,9 +318,9 @@ void CXFA_FMLogicalOrExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMLogicalAndExpression::CXFA_FMLogicalAndExpression(
uint32_t line,
XFA_FM_TOKEN op,
- CXFA_FMSimpleExpression* pExp1,
- CXFA_FMSimpleExpression* pExp2)
- : CXFA_FMBinExpression(line, op, pExp1, pExp2) {}
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp1,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp2)
+ : CXFA_FMBinExpression(line, op, std::move(pExp1), std::move(pExp2)) {}
void CXFA_FMLogicalAndExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << gs_lpStrExpFuncName[LOGICALAND];
@@ -329,9 +334,9 @@ void CXFA_FMLogicalAndExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMEqualityExpression::CXFA_FMEqualityExpression(
uint32_t line,
XFA_FM_TOKEN op,
- CXFA_FMSimpleExpression* pExp1,
- CXFA_FMSimpleExpression* pExp2)
- : CXFA_FMBinExpression(line, op, pExp1, pExp2) {}
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp1,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp2)
+ : CXFA_FMBinExpression(line, op, std::move(pExp1), std::move(pExp2)) {}
void CXFA_FMEqualityExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
switch (m_op) {
@@ -357,9 +362,9 @@ void CXFA_FMEqualityExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMRelationalExpression::CXFA_FMRelationalExpression(
uint32_t line,
XFA_FM_TOKEN op,
- CXFA_FMSimpleExpression* pExp1,
- CXFA_FMSimpleExpression* pExp2)
- : CXFA_FMBinExpression(line, op, pExp1, pExp2) {}
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp1,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp2)
+ : CXFA_FMBinExpression(line, op, std::move(pExp1), std::move(pExp2)) {}
void CXFA_FMRelationalExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
switch (m_op) {
@@ -393,9 +398,9 @@ void CXFA_FMRelationalExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMAdditiveExpression::CXFA_FMAdditiveExpression(
uint32_t line,
XFA_FM_TOKEN op,
- CXFA_FMSimpleExpression* pExp1,
- CXFA_FMSimpleExpression* pExp2)
- : CXFA_FMBinExpression(line, op, pExp1, pExp2) {}
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp1,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp2)
+ : CXFA_FMBinExpression(line, op, std::move(pExp1), std::move(pExp2)) {}
void CXFA_FMAdditiveExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
switch (m_op) {
@@ -419,9 +424,9 @@ void CXFA_FMAdditiveExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMMultiplicativeExpression::CXFA_FMMultiplicativeExpression(
uint32_t line,
XFA_FM_TOKEN op,
- CXFA_FMSimpleExpression* pExp1,
- CXFA_FMSimpleExpression* pExp2)
- : CXFA_FMBinExpression(line, op, pExp1, pExp2) {}
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp1,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp2)
+ : CXFA_FMBinExpression(line, op, std::move(pExp1), std::move(pExp2)) {}
void CXFA_FMMultiplicativeExpression::ToJavaScript(
CFX_WideTextBuf& javascript) {
@@ -443,9 +448,10 @@ void CXFA_FMMultiplicativeExpression::ToJavaScript(
javascript << FX_WSTRC(L")");
}
-CXFA_FMPosExpression::CXFA_FMPosExpression(uint32_t line,
- CXFA_FMSimpleExpression* pExp)
- : CXFA_FMUnaryExpression(line, TOKplus, pExp) {}
+CXFA_FMPosExpression::CXFA_FMPosExpression(
+ uint32_t line,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp)
+ : CXFA_FMUnaryExpression(line, TOKplus, std::move(pExp)) {}
void CXFA_FMPosExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << gs_lpStrExpFuncName[POSITIVE];
@@ -454,9 +460,10 @@ void CXFA_FMPosExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << FX_WSTRC(L")");
}
-CXFA_FMNegExpression::CXFA_FMNegExpression(uint32_t line,
- CXFA_FMSimpleExpression* pExp)
- : CXFA_FMUnaryExpression(line, TOKminus, pExp) {}
+CXFA_FMNegExpression::CXFA_FMNegExpression(
+ uint32_t line,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp)
+ : CXFA_FMUnaryExpression(line, TOKminus, std::move(pExp)) {}
void CXFA_FMNegExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << gs_lpStrExpFuncName[NEGATIVE];
@@ -465,9 +472,10 @@ void CXFA_FMNegExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << FX_WSTRC(L")");
}
-CXFA_FMNotExpression::CXFA_FMNotExpression(uint32_t line,
- CXFA_FMSimpleExpression* pExp)
- : CXFA_FMUnaryExpression(line, TOKksnot, pExp) {}
+CXFA_FMNotExpression::CXFA_FMNotExpression(
+ uint32_t line,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp)
+ : CXFA_FMUnaryExpression(line, TOKksnot, std::move(pExp)) {}
void CXFA_FMNotExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << gs_lpStrExpFuncName[NOT];
@@ -478,10 +486,10 @@ void CXFA_FMNotExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMCallExpression::CXFA_FMCallExpression(
uint32_t line,
- CXFA_FMSimpleExpression* pExp,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp,
std::vector<std::unique_ptr<CXFA_FMSimpleExpression>>&& pArguments,
bool bIsSomMethod)
- : CXFA_FMUnaryExpression(line, TOKcall, pExp),
+ : CXFA_FMUnaryExpression(line, TOKcall, std::move(pExp)),
m_bIsSomMethod(bIsSomMethod),
m_Arguments(std::move(pArguments)) {}
@@ -611,11 +619,14 @@ void CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMDotAccessorExpression::CXFA_FMDotAccessorExpression(
uint32_t line,
- CXFA_FMSimpleExpression* pAccessor,
+ std::unique_ptr<CXFA_FMSimpleExpression> pAccessor,
XFA_FM_TOKEN op,
CFX_WideStringC wsIdentifier,
- CXFA_FMSimpleExpression* pIndexExp)
- : CXFA_FMBinExpression(line, op, pAccessor, pIndexExp),
+ std::unique_ptr<CXFA_FMSimpleExpression> pIndexExp)
+ : CXFA_FMBinExpression(line,
+ op,
+ std::move(pAccessor),
+ std::move(pIndexExp)),
m_wsIdentifier(wsIdentifier) {}
CXFA_FMDotAccessorExpression::~CXFA_FMDotAccessorExpression() {}
@@ -654,9 +665,9 @@ void CXFA_FMDotAccessorExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMIndexExpression::CXFA_FMIndexExpression(
uint32_t line,
XFA_FM_AccessorIndex accessorIndex,
- CXFA_FMSimpleExpression* pIndexExp,
+ std::unique_ptr<CXFA_FMSimpleExpression> pIndexExp,
bool bIsStarIndex)
- : CXFA_FMUnaryExpression(line, TOKlbracket, pIndexExp),
+ : CXFA_FMUnaryExpression(line, TOKlbracket, std::move(pIndexExp)),
m_accessorIndex(accessorIndex),
m_bIsStarIndex(bIsStarIndex) {}
@@ -689,11 +700,14 @@ void CXFA_FMIndexExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
CXFA_FMDotDotAccessorExpression::CXFA_FMDotDotAccessorExpression(
uint32_t line,
- CXFA_FMSimpleExpression* pAccessor,
+ std::unique_ptr<CXFA_FMSimpleExpression> pAccessor,
XFA_FM_TOKEN op,
CFX_WideStringC wsIdentifier,
- CXFA_FMSimpleExpression* pIndexExp)
- : CXFA_FMBinExpression(line, op, pAccessor, pIndexExp),
+ std::unique_ptr<CXFA_FMSimpleExpression> pIndexExp)
+ : CXFA_FMBinExpression(line,
+ op,
+ std::move(pAccessor),
+ std::move(pIndexExp)),
m_wsIdentifier(wsIdentifier) {}
CXFA_FMDotDotAccessorExpression::~CXFA_FMDotDotAccessorExpression() {}
@@ -718,9 +732,12 @@ void CXFA_FMDotDotAccessorExpression::ToJavaScript(
CXFA_FMMethodCallExpression::CXFA_FMMethodCallExpression(
uint32_t line,
- CXFA_FMSimpleExpression* pAccessorExp1,
- CXFA_FMSimpleExpression* pCallExp)
- : CXFA_FMBinExpression(line, TOKdot, pAccessorExp1, pCallExp) {}
+ std::unique_ptr<CXFA_FMSimpleExpression> pAccessorExp1,
+ std::unique_ptr<CXFA_FMSimpleExpression> pCallExp)
+ : CXFA_FMBinExpression(line,
+ TOKdot,
+ std::move(pAccessorExp1),
+ std::move(pCallExp)) {}
void CXFA_FMMethodCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) {
javascript << FX_WSTRC(L"(\nfunction ()\n{\n");
diff --git a/xfa/fxfa/fm2js/xfa_simpleexpression.h b/xfa/fxfa/fm2js/xfa_simpleexpression.h
index c96d990b08..28c37edfb1 100644
--- a/xfa/fxfa/fm2js/xfa_simpleexpression.h
+++ b/xfa/fxfa/fm2js/xfa_simpleexpression.h
@@ -111,7 +111,7 @@ class CXFA_FMUnaryExpression : public CXFA_FMSimpleExpression {
public:
CXFA_FMUnaryExpression(uint32_t line,
XFA_FM_TOKEN op,
- CXFA_FMSimpleExpression* pExp);
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp);
~CXFA_FMUnaryExpression() override;
void ToJavaScript(CFX_WideTextBuf& javascript) override;
@@ -124,8 +124,8 @@ class CXFA_FMBinExpression : public CXFA_FMSimpleExpression {
public:
CXFA_FMBinExpression(uint32_t line,
XFA_FM_TOKEN op,
- CXFA_FMSimpleExpression* pExp1,
- CXFA_FMSimpleExpression* pExp2);
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp1,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp2);
~CXFA_FMBinExpression() override;
void ToJavaScript(CFX_WideTextBuf& javascript) override;
@@ -139,8 +139,8 @@ class CXFA_FMAssignExpression : public CXFA_FMBinExpression {
public:
CXFA_FMAssignExpression(uint32_t line,
XFA_FM_TOKEN op,
- CXFA_FMSimpleExpression* pExp1,
- CXFA_FMSimpleExpression* pExp2);
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp1,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp2);
~CXFA_FMAssignExpression() override {}
void ToJavaScript(CFX_WideTextBuf& javascript) override;
void ToImpliedReturnJS(CFX_WideTextBuf& javascript) override;
@@ -150,8 +150,8 @@ class CXFA_FMLogicalOrExpression : public CXFA_FMBinExpression {
public:
CXFA_FMLogicalOrExpression(uint32_t line,
XFA_FM_TOKEN op,
- CXFA_FMSimpleExpression* pExp1,
- CXFA_FMSimpleExpression* pExp2);
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp1,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp2);
~CXFA_FMLogicalOrExpression() override {}
void ToJavaScript(CFX_WideTextBuf& javascript) override;
};
@@ -160,8 +160,8 @@ class CXFA_FMLogicalAndExpression : public CXFA_FMBinExpression {
public:
CXFA_FMLogicalAndExpression(uint32_t line,
XFA_FM_TOKEN op,
- CXFA_FMSimpleExpression* pExp1,
- CXFA_FMSimpleExpression* pExp2);
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp1,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp2);
~CXFA_FMLogicalAndExpression() override {}
void ToJavaScript(CFX_WideTextBuf& javascript) override;
};
@@ -170,8 +170,8 @@ class CXFA_FMEqualityExpression : public CXFA_FMBinExpression {
public:
CXFA_FMEqualityExpression(uint32_t line,
XFA_FM_TOKEN op,
- CXFA_FMSimpleExpression* pExp1,
- CXFA_FMSimpleExpression* pExp2);
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp1,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp2);
~CXFA_FMEqualityExpression() override {}
void ToJavaScript(CFX_WideTextBuf& javascript) override;
};
@@ -180,8 +180,8 @@ class CXFA_FMRelationalExpression : public CXFA_FMBinExpression {
public:
CXFA_FMRelationalExpression(uint32_t line,
XFA_FM_TOKEN op,
- CXFA_FMSimpleExpression* pExp1,
- CXFA_FMSimpleExpression* pExp2);
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp1,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp2);
~CXFA_FMRelationalExpression() override {}
void ToJavaScript(CFX_WideTextBuf& javascript) override;
};
@@ -190,39 +190,43 @@ class CXFA_FMAdditiveExpression : public CXFA_FMBinExpression {
public:
CXFA_FMAdditiveExpression(uint32_t line,
XFA_FM_TOKEN op,
- CXFA_FMSimpleExpression* pExp1,
- CXFA_FMSimpleExpression* pExp2);
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp1,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp2);
~CXFA_FMAdditiveExpression() override {}
void ToJavaScript(CFX_WideTextBuf& javascript) override;
};
class CXFA_FMMultiplicativeExpression : public CXFA_FMBinExpression {
public:
- CXFA_FMMultiplicativeExpression(uint32_t line,
- XFA_FM_TOKEN op,
- CXFA_FMSimpleExpression* pExp1,
- CXFA_FMSimpleExpression* pExp2);
+ CXFA_FMMultiplicativeExpression(
+ uint32_t line,
+ XFA_FM_TOKEN op,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp1,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp2);
~CXFA_FMMultiplicativeExpression() override {}
void ToJavaScript(CFX_WideTextBuf& javascript) override;
};
class CXFA_FMPosExpression : public CXFA_FMUnaryExpression {
public:
- CXFA_FMPosExpression(uint32_t line, CXFA_FMSimpleExpression* pExp);
+ CXFA_FMPosExpression(uint32_t line,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp);
~CXFA_FMPosExpression() override {}
void ToJavaScript(CFX_WideTextBuf& javascript) override;
};
class CXFA_FMNegExpression : public CXFA_FMUnaryExpression {
public:
- CXFA_FMNegExpression(uint32_t line, CXFA_FMSimpleExpression* pExp);
+ CXFA_FMNegExpression(uint32_t line,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp);
~CXFA_FMNegExpression() override {}
void ToJavaScript(CFX_WideTextBuf& javascript) override;
};
class CXFA_FMNotExpression : public CXFA_FMUnaryExpression {
public:
- CXFA_FMNotExpression(uint32_t line, CXFA_FMSimpleExpression* pExp);
+ CXFA_FMNotExpression(uint32_t line,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp);
~CXFA_FMNotExpression() override {}
void ToJavaScript(CFX_WideTextBuf& javascript) override;
};
@@ -231,7 +235,7 @@ class CXFA_FMCallExpression : public CXFA_FMUnaryExpression {
public:
CXFA_FMCallExpression(
uint32_t line,
- CXFA_FMSimpleExpression* pExp,
+ std::unique_ptr<CXFA_FMSimpleExpression> pExp,
std::vector<std::unique_ptr<CXFA_FMSimpleExpression>>&& pArguments,
bool bIsSomMethod);
~CXFA_FMCallExpression() override;
@@ -247,11 +251,12 @@ class CXFA_FMCallExpression : public CXFA_FMUnaryExpression {
class CXFA_FMDotAccessorExpression : public CXFA_FMBinExpression {
public:
- CXFA_FMDotAccessorExpression(uint32_t line,
- CXFA_FMSimpleExpression* pAccessor,
- XFA_FM_TOKEN op,
- CFX_WideStringC wsIdentifier,
- CXFA_FMSimpleExpression* pIndexExp);
+ CXFA_FMDotAccessorExpression(
+ uint32_t line,
+ std::unique_ptr<CXFA_FMSimpleExpression> pAccessor,
+ XFA_FM_TOKEN op,
+ CFX_WideStringC wsIdentifier,
+ std::unique_ptr<CXFA_FMSimpleExpression> pIndexExp);
~CXFA_FMDotAccessorExpression() override;
void ToJavaScript(CFX_WideTextBuf& javascript) override;
@@ -263,7 +268,7 @@ class CXFA_FMIndexExpression : public CXFA_FMUnaryExpression {
public:
CXFA_FMIndexExpression(uint32_t line,
XFA_FM_AccessorIndex accessorIndex,
- CXFA_FMSimpleExpression* pIndexExp,
+ std::unique_ptr<CXFA_FMSimpleExpression> pIndexExp,
bool bIsStarIndex);
~CXFA_FMIndexExpression() override {}
void ToJavaScript(CFX_WideTextBuf& javascript) override;
@@ -275,11 +280,12 @@ class CXFA_FMIndexExpression : public CXFA_FMUnaryExpression {
class CXFA_FMDotDotAccessorExpression : public CXFA_FMBinExpression {
public:
- CXFA_FMDotDotAccessorExpression(uint32_t line,
- CXFA_FMSimpleExpression* pAccessor,
- XFA_FM_TOKEN op,
- CFX_WideStringC wsIdentifier,
- CXFA_FMSimpleExpression* pIndexExp);
+ CXFA_FMDotDotAccessorExpression(
+ uint32_t line,
+ std::unique_ptr<CXFA_FMSimpleExpression> pAccessor,
+ XFA_FM_TOKEN op,
+ CFX_WideStringC wsIdentifier,
+ std::unique_ptr<CXFA_FMSimpleExpression> pIndexExp);
~CXFA_FMDotDotAccessorExpression() override;
void ToJavaScript(CFX_WideTextBuf& javascript) override;
@@ -290,9 +296,10 @@ class CXFA_FMDotDotAccessorExpression : public CXFA_FMBinExpression {
class CXFA_FMMethodCallExpression : public CXFA_FMBinExpression {
public:
- CXFA_FMMethodCallExpression(uint32_t line,
- CXFA_FMSimpleExpression* pAccessorExp1,
- CXFA_FMSimpleExpression* pCallExp);
+ CXFA_FMMethodCallExpression(
+ uint32_t line,
+ std::unique_ptr<CXFA_FMSimpleExpression> pAccessorExp1,
+ std::unique_ptr<CXFA_FMSimpleExpression> pCallExp);
~CXFA_FMMethodCallExpression() override {}
void ToJavaScript(CFX_WideTextBuf& javascript) override;
};
diff --git a/xfa/fxfa/fm2js/xfa_simpleexpression_unittest.cpp b/xfa/fxfa/fm2js/xfa_simpleexpression_unittest.cpp
index d54921f99a..7826d9b53c 100644
--- a/xfa/fxfa/fm2js/xfa_simpleexpression_unittest.cpp
+++ b/xfa/fxfa/fm2js/xfa_simpleexpression_unittest.cpp
@@ -19,7 +19,7 @@ TEST(FMCallExpression, more_than_32_arguments) {
for (size_t i = 0; i < 50; i++)
args.push_back(pdfium::MakeUnique<CXFA_FMSimpleExpression>(0, TOKnan));
- CXFA_FMCallExpression callExp(0, exp.release(), std::move(args), true);
+ CXFA_FMCallExpression callExp(0, std::move(exp), std::move(args), true);
CFX_WideTextBuf js;
callExp.ToJavaScript(js);