summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-05-16 15:28:15 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-16 15:28:15 +0000
commitadbf41e6bfdf05ed514c561ea7926f45ae02b06c (patch)
tree7b6cf65121d133594bb833adcf9e599ad27cc8fe
parent99a046acd2d1ce1f093937642b6a9165f8f41986 (diff)
downloadpdfium-adbf41e6bfdf05ed514c561ea7926f45ae02b06c.tar.xz
Convert Formcalc ToJavascript to a pointer WideTextBuf
This CL converts the WidetextBuf reference to a pointer in the formcalc ToJavaScript methods. Change-Id: Ia05c7255a99a2eaa3d9a57f77580969896ad90a0 Reviewed-on: https://pdfium-review.googlesource.com/32612 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r--fxjs/cfxjse_formcalc_context.cpp4
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmexpression.cpp160
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmexpression.h26
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp16
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp203
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmsimpleexpression.h28
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmsimpleexpression_unittest.cpp13
7 files changed, 226 insertions, 224 deletions
diff --git a/fxjs/cfxjse_formcalc_context.cpp b/fxjs/cfxjse_formcalc_context.cpp
index a6d151b468..6a938a5da7 100644
--- a/fxjs/cfxjse_formcalc_context.cpp
+++ b/fxjs/cfxjse_formcalc_context.cpp
@@ -6185,12 +6185,12 @@ bool CFXJSE_FormCalcContext::Translate(const WideStringView& wsFormcalc,
return false;
CXFA_FMToJavaScriptDepth::Reset();
- if (!ast->ToJavaScript(*wsJavascript))
+ if (!ast->ToJavaScript(wsJavascript))
return false;
wsJavascript->AppendChar(0);
- return !CXFA_IsTooBig(*wsJavascript);
+ return !CXFA_IsTooBig(wsJavascript);
}
CFXJSE_FormCalcContext::CFXJSE_FormCalcContext(v8::Isolate* pScriptIsolate,
diff --git a/xfa/fxfa/fm2js/cxfa_fmexpression.cpp b/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
index ef2153d6be..9ff043a1ab 100644
--- a/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
@@ -44,7 +44,7 @@ CXFA_FMFunctionDefinition::CXFA_FMFunctionDefinition(
CXFA_FMFunctionDefinition::~CXFA_FMFunctionDefinition() = default;
-bool CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& js,
+bool CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf* js,
ReturnType type) {
CXFA_FMToJavaScriptDepth depthManager;
if (CXFA_IsTooBig(js) || !depthManager.IsWithinMaxDepth())
@@ -53,16 +53,16 @@ bool CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& js,
if (m_wsName.IsEmpty())
return false;
- js << L"function " << IdentifierToName(m_wsName) << L"(";
+ *js << L"function " << IdentifierToName(m_wsName) << L"(";
for (const auto& identifier : m_pArguments) {
if (identifier != m_pArguments.front())
- js << L", ";
+ *js << L", ";
- js << IdentifierToName(identifier);
+ *js << IdentifierToName(identifier);
}
- js << L") {\n";
+ *js << L") {\n";
- js << L"var pfm_ret = null;\n";
+ *js << L"var pfm_ret = null;\n";
for (const auto& expr : m_pExpressions) {
ReturnType ret_type = expr == m_pExpressions.back() ? ReturnType::kImplied
: ReturnType::kInfered;
@@ -70,8 +70,8 @@ bool CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& js,
return false;
}
- js << L"return pfm_ret;\n";
- js << L"}\n";
+ *js << L"return pfm_ret;\n";
+ *js << L"}\n";
return !CXFA_IsTooBig(js);
}
@@ -82,24 +82,24 @@ CXFA_FMAST::CXFA_FMAST(
CXFA_FMAST::~CXFA_FMAST() = default;
-bool CXFA_FMAST::ToJavaScript(CFX_WideTextBuf& js) {
+bool CXFA_FMAST::ToJavaScript(CFX_WideTextBuf* js) {
if (expressions_.empty()) {
- js << L"// comments only";
+ *js << L"// comments only";
return !CXFA_IsTooBig(js);
}
- js << L"(function() {\n";
- js << L"let pfm_method_runner = function(obj, cb) {\n";
- js << L" if (pfm_rt.is_ary(obj)) {\n";
- js << L" let pfm_method_return = null;\n";
- js << L" for (var idx = obj.length -1; idx > 1; idx--) {\n";
- js << L" pfm_method_return = cb(obj[idx]);\n";
- js << L" }\n";
- js << L" return pfm_method_return;\n";
- js << L" }\n";
- js << L" return cb(obj);\n";
- js << L"};\n";
- js << L"var pfm_ret = null;\n";
+ *js << L"(function() {\n";
+ *js << L"let pfm_method_runner = function(obj, cb) {\n";
+ *js << L" if (pfm_rt.is_ary(obj)) {\n";
+ *js << L" let pfm_method_return = null;\n";
+ *js << L" for (var idx = obj.length -1; idx > 1; idx--) {\n";
+ *js << L" pfm_method_return = cb(obj[idx]);\n";
+ *js << L" }\n";
+ *js << L" return pfm_method_return;\n";
+ *js << L" }\n";
+ *js << L" return cb(obj);\n";
+ *js << L"};\n";
+ *js << L"var pfm_ret = null;\n";
for (const auto& expr : expressions_) {
ReturnType ret_type = expr == expressions_.back() ? ReturnType::kImplied
@@ -108,8 +108,8 @@ bool CXFA_FMAST::ToJavaScript(CFX_WideTextBuf& js) {
return false;
}
- js << L"return pfm_rt.get_val(pfm_ret);\n";
- js << L"}).call(this);";
+ *js << L"return pfm_rt.get_val(pfm_ret);\n";
+ *js << L"}).call(this);";
return !CXFA_IsTooBig(js);
}
@@ -120,24 +120,24 @@ CXFA_FMVarExpression::CXFA_FMVarExpression(
CXFA_FMVarExpression::~CXFA_FMVarExpression() = default;
-bool CXFA_FMVarExpression::ToJavaScript(CFX_WideTextBuf& js, ReturnType type) {
+bool CXFA_FMVarExpression::ToJavaScript(CFX_WideTextBuf* js, ReturnType type) {
CXFA_FMToJavaScriptDepth depthManager;
if (CXFA_IsTooBig(js) || !depthManager.IsWithinMaxDepth())
return false;
WideString tempName = IdentifierToName(m_wsName);
- js << L"var " << tempName << L" = ";
+ *js << L"var " << tempName << L" = ";
if (m_pInit) {
if (!m_pInit->ToJavaScript(js, ReturnType::kInfered))
return false;
- js << tempName << L" = pfm_rt.var_filter(" << tempName << L");\n";
+ *js << tempName << L" = pfm_rt.var_filter(" << tempName << L");\n";
} else {
- js << L"\"\";\n";
+ *js << L"\"\";\n";
}
if (type == ReturnType::kImplied)
- js << L"pfm_ret = " << tempName << L";\n";
+ *js << L"pfm_ret = " << tempName << L";\n";
return !CXFA_IsTooBig(js);
}
@@ -148,7 +148,7 @@ CXFA_FMExpExpression::CXFA_FMExpExpression(
CXFA_FMExpExpression::~CXFA_FMExpExpression() = default;
-bool CXFA_FMExpExpression::ToJavaScript(CFX_WideTextBuf& js, ReturnType type) {
+bool CXFA_FMExpExpression::ToJavaScript(CFX_WideTextBuf* js, ReturnType type) {
CXFA_FMToJavaScriptDepth depthManager;
if (CXFA_IsTooBig(js) || !depthManager.IsWithinMaxDepth())
return false;
@@ -156,7 +156,7 @@ bool CXFA_FMExpExpression::ToJavaScript(CFX_WideTextBuf& js, ReturnType type) {
if (type == ReturnType::kInfered) {
bool ret = m_pExpression->ToJavaScript(js, ReturnType::kInfered);
if (m_pExpression->GetOperatorToken() != TOKassign)
- js << L";\n";
+ *js << L";\n";
return ret;
}
@@ -169,19 +169,19 @@ bool CXFA_FMExpExpression::ToJavaScript(CFX_WideTextBuf& js, ReturnType type) {
m_pExpression->GetOperatorToken() == TOKdotscream ||
m_pExpression->GetOperatorToken() == TOKdotdot ||
m_pExpression->GetOperatorToken() == TOKdot) {
- js << L"pfm_ret = pfm_rt.get_val(";
+ *js << L"pfm_ret = pfm_rt.get_val(";
if (!m_pExpression->ToJavaScript(js, ReturnType::kInfered))
return false;
- js << L");\n";
+ *js << L");\n";
return !CXFA_IsTooBig(js);
}
- js << L"pfm_ret = ";
+ *js << L"pfm_ret = ";
if (!m_pExpression->ToJavaScript(js, ReturnType::kInfered))
return false;
- js << L";\n";
+ *js << L";\n";
return !CXFA_IsTooBig(js);
}
@@ -191,13 +191,13 @@ CXFA_FMBlockExpression::CXFA_FMBlockExpression(
CXFA_FMBlockExpression::~CXFA_FMBlockExpression() = default;
-bool CXFA_FMBlockExpression::ToJavaScript(CFX_WideTextBuf& js,
+bool CXFA_FMBlockExpression::ToJavaScript(CFX_WideTextBuf* js,
ReturnType type) {
CXFA_FMToJavaScriptDepth depthManager;
if (CXFA_IsTooBig(js) || !depthManager.IsWithinMaxDepth())
return false;
- js << L"{\n";
+ *js << L"{\n";
for (const auto& expr : m_ExpressionList) {
if (type == ReturnType::kInfered) {
if (!expr->ToJavaScript(js, ReturnType::kInfered))
@@ -210,7 +210,7 @@ bool CXFA_FMBlockExpression::ToJavaScript(CFX_WideTextBuf& js,
return false;
}
}
- js << L"}\n";
+ *js << L"}\n";
return !CXFA_IsTooBig(js);
}
@@ -221,7 +221,7 @@ CXFA_FMDoExpression::CXFA_FMDoExpression(
CXFA_FMDoExpression::~CXFA_FMDoExpression() = default;
-bool CXFA_FMDoExpression::ToJavaScript(CFX_WideTextBuf& js, ReturnType type) {
+bool CXFA_FMDoExpression::ToJavaScript(CFX_WideTextBuf* js, ReturnType type) {
CXFA_FMToJavaScriptDepth depthManager;
if (CXFA_IsTooBig(js) || !depthManager.IsWithinMaxDepth())
return false;
@@ -244,18 +244,18 @@ CXFA_FMIfExpression::CXFA_FMIfExpression(
CXFA_FMIfExpression::~CXFA_FMIfExpression() = default;
-bool CXFA_FMIfExpression::ToJavaScript(CFX_WideTextBuf& js, ReturnType type) {
+bool CXFA_FMIfExpression::ToJavaScript(CFX_WideTextBuf* js, ReturnType type) {
CXFA_FMToJavaScriptDepth depthManager;
if (CXFA_IsTooBig(js) || !depthManager.IsWithinMaxDepth())
return false;
if (type == ReturnType::kImplied)
- js << L"pfm_ret = 0;\n";
+ *js << L"pfm_ret = 0;\n";
- js << L"if (pfm_rt.get_val(";
+ *js << L"if (pfm_rt.get_val(";
if (!m_pExpression->ToJavaScript(js, ReturnType::kInfered))
return false;
- js << L"))\n";
+ *js << L"))\n";
if (CXFA_IsTooBig(js))
return false;
@@ -268,13 +268,13 @@ bool CXFA_FMIfExpression::ToJavaScript(CFX_WideTextBuf& js, ReturnType type) {
}
for (auto& expr : m_pElseIfExpressions) {
- js << L"else ";
+ *js << L"else ";
if (!expr->ToJavaScript(js, ReturnType::kInfered))
return false;
}
if (m_pElseExpression) {
- js << L"else ";
+ *js << L"else ";
if (!m_pElseExpression->ToJavaScript(js, type))
return false;
}
@@ -290,20 +290,20 @@ CXFA_FMWhileExpression::CXFA_FMWhileExpression(
CXFA_FMWhileExpression::~CXFA_FMWhileExpression() = default;
-bool CXFA_FMWhileExpression::ToJavaScript(CFX_WideTextBuf& js,
+bool CXFA_FMWhileExpression::ToJavaScript(CFX_WideTextBuf* js,
ReturnType type) {
CXFA_FMToJavaScriptDepth depthManager;
if (CXFA_IsTooBig(js) || !depthManager.IsWithinMaxDepth())
return false;
if (type == ReturnType::kImplied)
- js << L"pfm_ret = 0;\n";
+ *js << L"pfm_ret = 0;\n";
- js << L"while (";
+ *js << L"while (";
if (!m_pCondition->ToJavaScript(js, ReturnType::kInfered))
return false;
- js << L")\n";
+ *js << L")\n";
if (CXFA_IsTooBig(js))
return false;
@@ -317,13 +317,13 @@ CXFA_FMBreakExpression::CXFA_FMBreakExpression() : CXFA_FMExpression() {}
CXFA_FMBreakExpression::~CXFA_FMBreakExpression() = default;
-bool CXFA_FMBreakExpression::ToJavaScript(CFX_WideTextBuf& js,
+bool CXFA_FMBreakExpression::ToJavaScript(CFX_WideTextBuf* js,
ReturnType type) {
CXFA_FMToJavaScriptDepth depthManager;
if (CXFA_IsTooBig(js) || !depthManager.IsWithinMaxDepth())
return false;
- js << L"pfm_ret = 0;\nbreak;\n";
+ *js << L"pfm_ret = 0;\nbreak;\n";
return !CXFA_IsTooBig(js);
}
@@ -331,13 +331,13 @@ CXFA_FMContinueExpression::CXFA_FMContinueExpression() : CXFA_FMExpression() {}
CXFA_FMContinueExpression::~CXFA_FMContinueExpression() = default;
-bool CXFA_FMContinueExpression::ToJavaScript(CFX_WideTextBuf& js,
+bool CXFA_FMContinueExpression::ToJavaScript(CFX_WideTextBuf* js,
ReturnType type) {
CXFA_FMToJavaScriptDepth depthManager;
if (CXFA_IsTooBig(js) || !depthManager.IsWithinMaxDepth())
return false;
- js << L"pfm_ret = 0;\ncontinue;\n";
+ *js << L"pfm_ret = 0;\ncontinue;\n";
return !CXFA_IsTooBig(js);
}
@@ -358,47 +358,47 @@ CXFA_FMForExpression::CXFA_FMForExpression(
CXFA_FMForExpression::~CXFA_FMForExpression() = default;
-bool CXFA_FMForExpression::ToJavaScript(CFX_WideTextBuf& js, ReturnType type) {
+bool CXFA_FMForExpression::ToJavaScript(CFX_WideTextBuf* js, ReturnType type) {
CXFA_FMToJavaScriptDepth depthManager;
if (CXFA_IsTooBig(js) || !depthManager.IsWithinMaxDepth())
return false;
if (type == ReturnType::kImplied)
- js << L"pfm_ret = 0;\n";
+ *js << L"pfm_ret = 0;\n";
- js << L"{\n";
+ *js << L"{\n";
WideString tmpName = IdentifierToName(m_wsVariant);
- js << L"var " << tmpName << L" = null;\n";
+ *js << L"var " << tmpName << L" = null;\n";
- js << L"for (" << tmpName << L" = pfm_rt.get_val(";
+ *js << L"for (" << tmpName << L" = pfm_rt.get_val(";
if (!m_pAssignment->ToJavaScript(js, ReturnType::kInfered))
return false;
- js << L"); ";
+ *js << L"); ";
- js << tmpName << (m_bDirection ? kLessEqual : kGreaterEqual);
- js << L"pfm_rt.get_val(";
+ *js << tmpName << (m_bDirection ? kLessEqual : kGreaterEqual);
+ *js << L"pfm_rt.get_val(";
if (!m_pAccessor->ToJavaScript(js, ReturnType::kInfered))
return false;
- js << L"); ";
+ *js << L"); ";
- js << tmpName << (m_bDirection ? kPlusEqual : kMinusEqual);
+ *js << tmpName << (m_bDirection ? kPlusEqual : kMinusEqual);
if (m_pStep) {
- js << L"pfm_rt.get_val(";
+ *js << L"pfm_rt.get_val(";
if (!m_pStep->ToJavaScript(js, ReturnType::kInfered))
return false;
- js << L")";
+ *js << L")";
} else {
- js << L"1";
+ *js << L"1";
}
- js << L")\n";
+ *js << L")\n";
if (CXFA_IsTooBig(js))
return false;
if (!m_pList->ToJavaScript(js, type))
return false;
- js << L"}\n";
+ *js << L"}\n";
return !CXFA_IsTooBig(js);
}
@@ -413,35 +413,35 @@ CXFA_FMForeachExpression::CXFA_FMForeachExpression(
CXFA_FMForeachExpression::~CXFA_FMForeachExpression() = default;
-bool CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf& js,
+bool CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf* js,
ReturnType type) {
CXFA_FMToJavaScriptDepth depthManager;
if (CXFA_IsTooBig(js) || !depthManager.IsWithinMaxDepth())
return false;
if (type == ReturnType::kImplied)
- js << L"pfm_ret = 0;\n";
+ *js << L"pfm_ret = 0;\n";
- js << L"{\n";
+ *js << L"{\n";
WideString tmpName = IdentifierToName(m_wsIdentifier);
- js << L"var " << tmpName << L" = null;\n";
- js << L"var pfm_ary = pfm_rt.concat_obj(";
+ *js << L"var " << tmpName << L" = null;\n";
+ *js << L"var pfm_ary = pfm_rt.concat_obj(";
for (const auto& expr : m_pAccessors) {
if (!expr->ToJavaScript(js, ReturnType::kInfered))
return false;
if (expr != m_pAccessors.back())
- js << L", ";
+ *js << L", ";
}
- js << L");\n";
+ *js << L");\n";
- js << L"var pfm_ary_idx = 0;\n";
- js << L"while(pfm_ary_idx < pfm_ary.length)\n{\n";
- js << tmpName << L" = pfm_ary[pfm_ary_idx++];\n";
+ *js << L"var pfm_ary_idx = 0;\n";
+ *js << L"while(pfm_ary_idx < pfm_ary.length)\n{\n";
+ *js << tmpName << L" = pfm_ary[pfm_ary_idx++];\n";
if (!m_pList->ToJavaScript(js, type))
return false;
- js << L"}\n"; // while
+ *js << L"}\n"; // while
- js << L"}\n"; // block
+ *js << L"}\n"; // block
return !CXFA_IsTooBig(js);
}
diff --git a/xfa/fxfa/fm2js/cxfa_fmexpression.h b/xfa/fxfa/fm2js/cxfa_fmexpression.h
index 32cbf96c95..bff62c185b 100644
--- a/xfa/fxfa/fm2js/cxfa_fmexpression.h
+++ b/xfa/fxfa/fm2js/cxfa_fmexpression.h
@@ -17,7 +17,7 @@ class CFX_WideTextBuf;
class CXFA_FMExpression {
public:
virtual ~CXFA_FMExpression() {}
- virtual bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) = 0;
+ virtual bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) = 0;
protected:
CXFA_FMExpression();
@@ -31,7 +31,7 @@ class CXFA_FMFunctionDefinition : public CXFA_FMExpression {
std::vector<std::unique_ptr<CXFA_FMExpression>>&& expressions);
~CXFA_FMFunctionDefinition() override;
- bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override;
+ bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) override;
private:
WideStringView m_wsName;
@@ -45,7 +45,7 @@ class CXFA_FMAST {
std::vector<std::unique_ptr<CXFA_FMExpression>> expressions);
~CXFA_FMAST();
- bool ToJavaScript(CFX_WideTextBuf& javascript);
+ bool ToJavaScript(CFX_WideTextBuf* js);
private:
std::vector<std::unique_ptr<CXFA_FMExpression>> expressions_;
@@ -57,7 +57,7 @@ class CXFA_FMVarExpression : public CXFA_FMExpression {
std::unique_ptr<CXFA_FMSimpleExpression> pInit);
~CXFA_FMVarExpression() override;
- bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override;
+ bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) override;
private:
WideStringView m_wsName;
@@ -70,7 +70,7 @@ class CXFA_FMExpExpression : public CXFA_FMExpression {
std::unique_ptr<CXFA_FMSimpleExpression> pExpression);
~CXFA_FMExpExpression() override;
- bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override;
+ bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) override;
private:
std::unique_ptr<CXFA_FMSimpleExpression> m_pExpression;
@@ -82,7 +82,7 @@ class CXFA_FMBlockExpression : public CXFA_FMExpression {
std::vector<std::unique_ptr<CXFA_FMExpression>>&& pExpressionList);
~CXFA_FMBlockExpression() override;
- bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override;
+ bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) override;
private:
std::vector<std::unique_ptr<CXFA_FMExpression>> m_ExpressionList;
@@ -93,7 +93,7 @@ class CXFA_FMDoExpression : public CXFA_FMExpression {
explicit CXFA_FMDoExpression(std::unique_ptr<CXFA_FMExpression> pList);
~CXFA_FMDoExpression() override;
- bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override;
+ bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) override;
private:
std::unique_ptr<CXFA_FMExpression> m_pList;
@@ -108,7 +108,7 @@ class CXFA_FMIfExpression : public CXFA_FMExpression {
std::unique_ptr<CXFA_FMExpression> pElseExpression);
~CXFA_FMIfExpression() override;
- bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override;
+ bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) override;
private:
std::unique_ptr<CXFA_FMSimpleExpression> m_pExpression;
@@ -123,7 +123,7 @@ class CXFA_FMWhileExpression : public CXFA_FMExpression {
std::unique_ptr<CXFA_FMExpression> pExpression);
~CXFA_FMWhileExpression() override;
- bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override;
+ bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) override;
private:
std::unique_ptr<CXFA_FMSimpleExpression> m_pCondition;
@@ -135,7 +135,7 @@ class CXFA_FMBreakExpression : public CXFA_FMExpression {
CXFA_FMBreakExpression();
~CXFA_FMBreakExpression() override;
- bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override;
+ bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) override;
};
class CXFA_FMContinueExpression : public CXFA_FMExpression {
@@ -143,7 +143,7 @@ class CXFA_FMContinueExpression : public CXFA_FMExpression {
CXFA_FMContinueExpression();
~CXFA_FMContinueExpression() override;
- bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override;
+ bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) override;
};
class CXFA_FMForExpression : public CXFA_FMExpression {
@@ -156,7 +156,7 @@ class CXFA_FMForExpression : public CXFA_FMExpression {
std::unique_ptr<CXFA_FMExpression> pList);
~CXFA_FMForExpression() override;
- bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override;
+ bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) override;
private:
WideStringView m_wsVariant;
@@ -176,7 +176,7 @@ class CXFA_FMForeachExpression : public CXFA_FMExpression {
std::unique_ptr<CXFA_FMExpression> pList);
~CXFA_FMForeachExpression() override;
- bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override;
+ bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) override;
private:
WideStringView m_wsIdentifier;
diff --git a/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp b/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp
index 81fae08384..9a9db21875 100644
--- a/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp
@@ -20,7 +20,7 @@ TEST(CXFA_FMParserTest, Empty) {
CXFA_FMToJavaScriptDepth::Reset();
CFX_WideTextBuf buf;
- EXPECT_TRUE(ast->ToJavaScript(buf));
+ EXPECT_TRUE(ast->ToJavaScript(&buf));
// TODO(dsinclair): This is a little weird .....
EXPECT_EQ(L"// comments only", buf.AsStringView());
}
@@ -35,7 +35,7 @@ TEST(CXFA_FMParserTest, CommentOnlyIsError) {
CXFA_FMToJavaScriptDepth::Reset();
CFX_WideTextBuf buf;
- EXPECT_TRUE(ast->ToJavaScript(buf));
+ EXPECT_TRUE(ast->ToJavaScript(&buf));
EXPECT_EQ(L"// comments only", buf.AsStringView());
}
@@ -64,7 +64,7 @@ TEST(CXFA_FMParserTest, CommentThenValue) {
CXFA_FMToJavaScriptDepth::Reset();
CFX_WideTextBuf buf;
- EXPECT_TRUE(ast->ToJavaScript(buf));
+ EXPECT_TRUE(ast->ToJavaScript(&buf));
EXPECT_EQ(ret, buf.AsStringView());
}
@@ -143,7 +143,7 @@ TEST(CXFA_FMParserTest, Parse) {
CXFA_FMToJavaScriptDepth::Reset();
CFX_WideTextBuf buf;
- EXPECT_TRUE(ast->ToJavaScript(buf));
+ EXPECT_TRUE(ast->ToJavaScript(&buf));
EXPECT_EQ(ret, buf.AsStringView());
}
@@ -205,7 +205,7 @@ TEST(CXFA_FMParserTest, ParseFuncWithParams) {
CXFA_FMToJavaScriptDepth::Reset();
CFX_WideTextBuf buf;
- EXPECT_TRUE(ast->ToJavaScript(buf));
+ EXPECT_TRUE(ast->ToJavaScript(&buf));
EXPECT_EQ(ret, buf.AsStringView());
}
@@ -243,7 +243,7 @@ TEST(CXFA_FMParserTest, ParseFuncWithoutParams) {
CXFA_FMToJavaScriptDepth::Reset();
CFX_WideTextBuf buf;
- EXPECT_TRUE(ast->ToJavaScript(buf));
+ EXPECT_TRUE(ast->ToJavaScript(&buf));
EXPECT_EQ(ret, buf.AsStringView());
}
@@ -327,7 +327,7 @@ TEST(CXFA_FMParserTest, ParseCallSmall) {
CXFA_FMToJavaScriptDepth::Reset();
CFX_WideTextBuf buf;
- EXPECT_TRUE(ast->ToJavaScript(buf));
+ EXPECT_TRUE(ast->ToJavaScript(&buf));
EXPECT_EQ(ret, buf.AsStringView());
}
@@ -368,6 +368,6 @@ TEST(CXFA_FMParserTest, ParseCallBig) {
CXFA_FMToJavaScriptDepth::Reset();
CFX_WideTextBuf buf;
- EXPECT_TRUE(ast->ToJavaScript(buf));
+ EXPECT_TRUE(ast->ToJavaScript(&buf));
EXPECT_EQ(ret, buf.AsStringView());
}
diff --git a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
index e34d4ba127..63d3d6a23b 100644
--- a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
@@ -80,12 +80,12 @@ XFA_FM_TOKEN CXFA_FMSimpleExpression::GetOperatorToken() const {
CXFA_FMNullExpression::CXFA_FMNullExpression()
: CXFA_FMSimpleExpression(TOKnull) {}
-bool CXFA_FMNullExpression::ToJavaScript(CFX_WideTextBuf& js, ReturnType type) {
+bool CXFA_FMNullExpression::ToJavaScript(CFX_WideTextBuf* js, ReturnType type) {
CXFA_FMToJavaScriptDepth depthManager;
if (CXFA_IsTooBig(js) || !depthManager.IsWithinMaxDepth())
return false;
- js << L"null";
+ *js << L"null";
return !CXFA_IsTooBig(js);
}
@@ -94,13 +94,13 @@ CXFA_FMNumberExpression::CXFA_FMNumberExpression(WideStringView wsNumber)
CXFA_FMNumberExpression::~CXFA_FMNumberExpression() = default;
-bool CXFA_FMNumberExpression::ToJavaScript(CFX_WideTextBuf& js,
+bool CXFA_FMNumberExpression::ToJavaScript(CFX_WideTextBuf* js,
ReturnType type) {
CXFA_FMToJavaScriptDepth depthManager;
if (CXFA_IsTooBig(js) || !depthManager.IsWithinMaxDepth())
return false;
- js << m_wsNumber;
+ *js << m_wsNumber;
return !CXFA_IsTooBig(js);
}
@@ -109,7 +109,7 @@ CXFA_FMStringExpression::CXFA_FMStringExpression(WideStringView wsString)
CXFA_FMStringExpression::~CXFA_FMStringExpression() = default;
-bool CXFA_FMStringExpression::ToJavaScript(CFX_WideTextBuf& js,
+bool CXFA_FMStringExpression::ToJavaScript(CFX_WideTextBuf* js,
ReturnType type) {
CXFA_FMToJavaScriptDepth depthManager;
if (CXFA_IsTooBig(js) || !depthManager.IsWithinMaxDepth())
@@ -117,29 +117,29 @@ bool CXFA_FMStringExpression::ToJavaScript(CFX_WideTextBuf& js,
WideString tempStr(m_wsString);
if (tempStr.GetLength() <= 2) {
- js << tempStr;
+ *js << tempStr;
return !CXFA_IsTooBig(js);
}
- js << L"\"";
+ *js << L"\"";
for (size_t i = 1; i < tempStr.GetLength() - 1; i++) {
wchar_t oneChar = tempStr[i];
switch (oneChar) {
case L'\"':
++i;
- js << L"\\\"";
+ *js << L"\\\"";
break;
case 0x0d:
break;
case 0x0a:
- js << L"\\n";
+ *js << L"\\n";
break;
default:
- js.AppendChar(oneChar);
+ js->AppendChar(oneChar);
break;
}
}
- js << L"\"";
+ *js << L"\"";
return !CXFA_IsTooBig(js);
}
@@ -149,32 +149,33 @@ CXFA_FMIdentifierExpression::CXFA_FMIdentifierExpression(
CXFA_FMIdentifierExpression::~CXFA_FMIdentifierExpression() = default;
-bool CXFA_FMIdentifierExpression::ToJavaScript(CFX_WideTextBuf& js,
+bool CXFA_FMIdentifierExpression::ToJavaScript(CFX_WideTextBuf* js,
ReturnType type) {
CXFA_FMToJavaScriptDepth depthManager;
if (CXFA_IsTooBig(js) || !depthManager.IsWithinMaxDepth())
return false;
if (m_wsIdentifier == L"$")
- js << L"this";
+ *js << L"this";
else if (m_wsIdentifier == L"!")
- js << L"xfa.datasets";
+ *js << L"xfa.datasets";
else if (m_wsIdentifier == L"$data")
- js << L"xfa.datasets.data";
+ *js << L"xfa.datasets.data";
else if (m_wsIdentifier == L"$event")
- js << L"xfa.event";
+ *js << L"xfa.event";
else if (m_wsIdentifier == L"$form")
- js << L"xfa.form";
+ *js << L"xfa.form";
else if (m_wsIdentifier == L"$host")
- js << L"xfa.host";
+ *js << L"xfa.host";
else if (m_wsIdentifier == L"$layout")
- js << L"xfa.layout";
+ *js << L"xfa.layout";
else if (m_wsIdentifier == L"$template")
- js << L"xfa.template";
+ *js << L"xfa.template";
else if (m_wsIdentifier[0] == L'!')
- js << L"pfm__excl__" + m_wsIdentifier.Right(m_wsIdentifier.GetLength() - 1);
+ *js << L"pfm__excl__" +
+ m_wsIdentifier.Right(m_wsIdentifier.GetLength() - 1);
else
- js << m_wsIdentifier;
+ *js << m_wsIdentifier;
return !CXFA_IsTooBig(js);
}
@@ -189,35 +190,35 @@ CXFA_FMAssignExpression::CXFA_FMAssignExpression(
CXFA_FMAssignExpression::~CXFA_FMAssignExpression() = default;
-bool CXFA_FMAssignExpression::ToJavaScript(CFX_WideTextBuf& js,
+bool CXFA_FMAssignExpression::ToJavaScript(CFX_WideTextBuf* js,
ReturnType type) {
CXFA_FMToJavaScriptDepth depthManager;
if (CXFA_IsTooBig(js) || !depthManager.IsWithinMaxDepth())
return false;
CFX_WideTextBuf tempExp1;
- if (!m_pExp1->ToJavaScript(tempExp1, ReturnType::kInfered))
+ if (!m_pExp1->ToJavaScript(&tempExp1, ReturnType::kInfered))
return false;
- js << L"if (pfm_rt.is_obj(" << tempExp1 << L"))\n{\n";
+ *js << L"if (pfm_rt.is_obj(" << tempExp1 << L"))\n{\n";
if (type == ReturnType::kImplied)
- js << L"pfm_ret = ";
+ *js << L"pfm_ret = ";
CFX_WideTextBuf tempExp2;
- if (!m_pExp2->ToJavaScript(tempExp2, ReturnType::kInfered))
+ if (!m_pExp2->ToJavaScript(&tempExp2, ReturnType::kInfered))
return false;
- js << L"pfm_rt.asgn_val_op(" << tempExp1 << L", " << tempExp2 << L");\n}\n";
+ *js << L"pfm_rt.asgn_val_op(" << tempExp1 << L", " << tempExp2 << L");\n}\n";
if (m_pExp1->GetOperatorToken() == TOKidentifier &&
tempExp1.AsStringView() != L"this") {
- js << L"else\n{\n";
+ *js << L"else\n{\n";
if (type == ReturnType::kImplied)
- js << L"pfm_ret = ";
+ *js << L"pfm_ret = ";
- js << tempExp1 << L" = pfm_rt.asgn_val_op";
- js << L"(" << tempExp1 << L", " << tempExp2 << L");\n";
- js << L"}\n";
+ *js << tempExp1 << L" = pfm_rt.asgn_val_op";
+ *js << L"(" << tempExp1 << L", " << tempExp2 << L");\n";
+ *js << L"}\n";
}
return !CXFA_IsTooBig(js);
}
@@ -234,18 +235,18 @@ CXFA_FMBinExpression::CXFA_FMBinExpression(
CXFA_FMBinExpression::~CXFA_FMBinExpression() = default;
-bool CXFA_FMBinExpression::ToJavaScript(CFX_WideTextBuf& js, ReturnType type) {
+bool CXFA_FMBinExpression::ToJavaScript(CFX_WideTextBuf* js, ReturnType type) {
CXFA_FMToJavaScriptDepth depthManager;
if (CXFA_IsTooBig(js) || !depthManager.IsWithinMaxDepth())
return false;
- js << L"pfm_rt." << m_OpName << L"(";
+ *js << L"pfm_rt." << m_OpName << L"(";
if (!m_pExp1->ToJavaScript(js, ReturnType::kInfered))
return false;
- js << L", ";
+ *js << L", ";
if (!m_pExp2->ToJavaScript(js, ReturnType::kInfered))
return false;
- js << L")";
+ *js << L")";
return !CXFA_IsTooBig(js);
}
@@ -365,16 +366,16 @@ CXFA_FMUnaryExpression::CXFA_FMUnaryExpression(
CXFA_FMUnaryExpression::~CXFA_FMUnaryExpression() = default;
-bool CXFA_FMUnaryExpression::ToJavaScript(CFX_WideTextBuf& js,
+bool CXFA_FMUnaryExpression::ToJavaScript(CFX_WideTextBuf* js,
ReturnType type) {
CXFA_FMToJavaScriptDepth depthManager;
if (CXFA_IsTooBig(js) || !depthManager.IsWithinMaxDepth())
return false;
- js << L"pfm_rt." << m_OpName.c_str() << L"(";
+ *js << L"pfm_rt." << m_OpName.c_str() << L"(";
if (!m_pExp->ToJavaScript(js, ReturnType::kInfered))
return false;
- js << L")";
+ *js << L")";
return !CXFA_IsTooBig(js);
}
@@ -434,47 +435,47 @@ uint32_t CXFA_FMCallExpression::IsMethodWithObjParam(
return 0;
}
-bool CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& js, ReturnType type) {
+bool CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf* js, ReturnType type) {
CXFA_FMToJavaScriptDepth depthManager;
if (CXFA_IsTooBig(js) || !depthManager.IsWithinMaxDepth())
return false;
CFX_WideTextBuf funcName;
- if (!m_pExp->ToJavaScript(funcName, ReturnType::kInfered))
+ if (!m_pExp->ToJavaScript(&funcName, ReturnType::kInfered))
return false;
if (m_bIsSomMethod) {
- js << funcName << L"(";
+ *js << funcName << L"(";
uint32_t methodPara = IsMethodWithObjParam(funcName.MakeString());
if (methodPara > 0) {
for (size_t i = 0; i < m_Arguments.size(); ++i) {
// Currently none of our expressions use objects for a parameter over
// the 6th. Make sure we don't overflow the shift when doing this
// check. If we ever need more the 32 object params we can revisit.
- js << L"pfm_rt.get_";
+ *js << L"pfm_rt.get_";
if (i < 32 && (methodPara & (0x01 << i)) > 0)
- js << L"jsobj";
+ *js << L"jsobj";
else
- js << L"val";
+ *js << L"val";
- js << L"(";
+ *js << L"(";
if (!m_Arguments[i]->ToJavaScript(js, ReturnType::kInfered))
return false;
- js << L")";
+ *js << L")";
if (i + 1 < m_Arguments.size())
- js << L", ";
+ *js << L", ";
}
} else {
for (const auto& expr : m_Arguments) {
- js << L"pfm_rt.get_val(";
+ *js << L"pfm_rt.get_val(";
if (!expr->ToJavaScript(js, ReturnType::kInfered))
return false;
- js << L")";
+ *js << L")";
if (expr != m_Arguments.back())
- js << L", ";
+ *js << L", ";
}
}
- js << L")";
+ *js << L")";
return !CXFA_IsTooBig(js);
}
@@ -490,38 +491,38 @@ bool CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& js, ReturnType type) {
if (funcName.AsStringView() == L"Eval") {
isEvalFunc = true;
- js << L"eval.call(this, pfm_rt.Translate";
+ *js << L"eval.call(this, pfm_rt.Translate";
} else {
if (funcName.AsStringView() == L"Exists")
isExistsFunc = true;
- js << L"pfm_rt." << funcName;
+ *js << L"pfm_rt." << funcName;
}
- js << L"(";
+ *js << L"(";
if (isExistsFunc) {
- js << L"\n(\nfunction ()\n{\ntry\n{\n";
+ *js << L"\n(\nfunction ()\n{\ntry\n{\n";
if (!m_Arguments.empty()) {
- js << L"return ";
+ *js << L"return ";
if (!m_Arguments[0]->ToJavaScript(js, ReturnType::kInfered))
return false;
- js << L";\n}\n";
+ *js << L";\n}\n";
} else {
- js << L"return 0;\n}\n";
+ *js << L"return 0;\n}\n";
}
- js << L"catch(accessExceptions)\n";
- js << L"{\nreturn 0;\n}\n}\n).call(this)\n";
+ *js << L"catch(accessExceptions)\n";
+ *js << L"{\nreturn 0;\n}\n}\n).call(this)\n";
} else {
for (const auto& expr : m_Arguments) {
if (!expr->ToJavaScript(js, ReturnType::kInfered))
return false;
if (expr != m_Arguments.back())
- js << L", ";
+ *js << L", ";
}
}
- js << L")";
+ *js << L")";
if (isEvalFunc)
- js << L")";
+ *js << L")";
return !CXFA_IsTooBig(js);
}
@@ -538,42 +539,42 @@ CXFA_FMDotAccessorExpression::CXFA_FMDotAccessorExpression(
CXFA_FMDotAccessorExpression::~CXFA_FMDotAccessorExpression() = default;
-bool CXFA_FMDotAccessorExpression::ToJavaScript(CFX_WideTextBuf& js,
+bool CXFA_FMDotAccessorExpression::ToJavaScript(CFX_WideTextBuf* js,
ReturnType type) {
CXFA_FMToJavaScriptDepth depthManager;
if (CXFA_IsTooBig(js) || !depthManager.IsWithinMaxDepth())
return false;
- js << L"pfm_rt.dot_acc(";
+ *js << L"pfm_rt.dot_acc(";
CFX_WideTextBuf tempExp1;
if (m_pExp1) {
- if (!m_pExp1->ToJavaScript(tempExp1, ReturnType::kInfered))
+ if (!m_pExp1->ToJavaScript(&tempExp1, ReturnType::kInfered))
return false;
- js << tempExp1;
+ *js << tempExp1;
} else {
- js << L"null";
+ *js << L"null";
}
- js << L", \"";
+ *js << L", \"";
if (m_pExp1 && m_pExp1->GetOperatorToken() == TOKidentifier)
- js << tempExp1;
+ *js << tempExp1;
- js << L"\", ";
+ *js << L"\", ";
if (m_op == TOKdotscream)
- js << L"\"#" << m_wsIdentifier << L"\", ";
+ *js << L"\"#" << m_wsIdentifier << L"\", ";
else if (m_op == TOKdotstar)
- js << L"\"*\", ";
+ *js << L"\"*\", ";
else if (m_op == TOKcall)
- js << L"\"\", ";
+ *js << L"\"\", ";
else
- js << L"\"" << m_wsIdentifier << L"\", ";
+ *js << L"\"" << m_wsIdentifier << L"\", ";
if (!m_pExp2->ToJavaScript(js, ReturnType::kInfered))
return false;
- js << L")";
+ *js << L")";
return !CXFA_IsTooBig(js);
}
@@ -588,7 +589,7 @@ CXFA_FMIndexExpression::CXFA_FMIndexExpression(
CXFA_FMIndexExpression::~CXFA_FMIndexExpression() = default;
-bool CXFA_FMIndexExpression::ToJavaScript(CFX_WideTextBuf& js,
+bool CXFA_FMIndexExpression::ToJavaScript(CFX_WideTextBuf* js,
ReturnType type) {
CXFA_FMToJavaScriptDepth depthManager;
if (CXFA_IsTooBig(js) || !depthManager.IsWithinMaxDepth())
@@ -596,29 +597,29 @@ bool CXFA_FMIndexExpression::ToJavaScript(CFX_WideTextBuf& js,
switch (m_accessorIndex) {
case ACCESSOR_NO_INDEX:
- js << L"0";
+ *js << L"0";
break;
case ACCESSOR_NO_RELATIVEINDEX:
- js << L"1";
+ *js << L"1";
break;
case ACCESSOR_POSITIVE_INDEX:
- js << L"2";
+ *js << L"2";
break;
case ACCESSOR_NEGATIVE_INDEX:
- js << L"3";
+ *js << L"3";
break;
default:
- js << L"0";
+ *js << L"0";
}
if (m_bIsStarIndex)
return !CXFA_IsTooBig(js);
- js << L", ";
+ *js << L", ";
if (m_pExp) {
if (!m_pExp->ToJavaScript(js, ReturnType::kInfered))
return false;
} else {
- js << L"0";
+ *js << L"0";
}
return !CXFA_IsTooBig(js);
}
@@ -635,25 +636,25 @@ CXFA_FMDotDotAccessorExpression::CXFA_FMDotDotAccessorExpression(
CXFA_FMDotDotAccessorExpression::~CXFA_FMDotDotAccessorExpression() = default;
-bool CXFA_FMDotDotAccessorExpression::ToJavaScript(CFX_WideTextBuf& js,
+bool CXFA_FMDotDotAccessorExpression::ToJavaScript(CFX_WideTextBuf* js,
ReturnType type) {
CXFA_FMToJavaScriptDepth depthManager;
if (CXFA_IsTooBig(js) || !depthManager.IsWithinMaxDepth())
return false;
- js << L"pfm_rt.dotdot_acc(";
+ *js << L"pfm_rt.dotdot_acc(";
if (!m_pExp1->ToJavaScript(js, ReturnType::kInfered))
return false;
- js << L", " << L"\"";
+ *js << L", " << L"\"";
if (m_pExp1->GetOperatorToken() == TOKidentifier) {
if (!m_pExp1->ToJavaScript(js, ReturnType::kInfered))
return false;
}
- js << L"\", \"" << m_wsIdentifier << L"\", ";
+ *js << L"\", \"" << m_wsIdentifier << L"\", ";
if (!m_pExp2->ToJavaScript(js, ReturnType::kInfered))
return false;
- js << L")";
+ *js << L")";
return !CXFA_IsTooBig(js);
}
@@ -666,27 +667,27 @@ CXFA_FMMethodCallExpression::CXFA_FMMethodCallExpression(
CXFA_FMMethodCallExpression::~CXFA_FMMethodCallExpression() = default;
-bool CXFA_FMMethodCallExpression::ToJavaScript(CFX_WideTextBuf& js,
+bool CXFA_FMMethodCallExpression::ToJavaScript(CFX_WideTextBuf* js,
ReturnType type) {
CXFA_FMToJavaScriptDepth depthManager;
if (CXFA_IsTooBig(js) || !depthManager.IsWithinMaxDepth())
return false;
CFX_WideTextBuf buf;
- if (!m_pExp1->ToJavaScript(buf, ReturnType::kInfered))
+ if (!m_pExp1->ToJavaScript(&buf, ReturnType::kInfered))
return false;
- js << L"(function() {\n";
- js << L" return pfm_method_runner(" << buf << L", function(obj) {\n";
- js << L" return obj.";
+ *js << L"(function() {\n";
+ *js << L" return pfm_method_runner(" << buf << L", function(obj) {\n";
+ *js << L" return obj.";
if (!m_pExp2->ToJavaScript(js, ReturnType::kInfered))
return false;
- js << L";\n";
- js << L" });\n";
- js << L"}).call(this)";
+ *js << L";\n";
+ *js << L" });\n";
+ *js << L"}).call(this)";
return !CXFA_IsTooBig(js);
}
-bool CXFA_IsTooBig(const CFX_WideTextBuf& javascript) {
- return javascript.GetSize() >= 256 * 1024 * 1024;
+bool CXFA_IsTooBig(const CFX_WideTextBuf* js) {
+ return js->GetSize() >= 256 * 1024 * 1024;
}
diff --git a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.h b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.h
index ede48ec2b6..0f3df31081 100644
--- a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.h
+++ b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.h
@@ -26,7 +26,7 @@ class CFX_WideTextBuf;
class CXFA_FMSimpleExpression {
public:
virtual ~CXFA_FMSimpleExpression() {}
- virtual bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) = 0;
+ virtual bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) = 0;
XFA_FM_TOKEN GetOperatorToken() const;
@@ -41,7 +41,7 @@ class CXFA_FMNullExpression : public CXFA_FMSimpleExpression {
CXFA_FMNullExpression();
~CXFA_FMNullExpression() override {}
- bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override;
+ bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) override;
};
class CXFA_FMNumberExpression : public CXFA_FMSimpleExpression {
@@ -49,7 +49,7 @@ class CXFA_FMNumberExpression : public CXFA_FMSimpleExpression {
explicit CXFA_FMNumberExpression(WideStringView wsNumber);
~CXFA_FMNumberExpression() override;
- bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override;
+ bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) override;
private:
WideStringView m_wsNumber;
@@ -60,7 +60,7 @@ class CXFA_FMStringExpression : public CXFA_FMSimpleExpression {
explicit CXFA_FMStringExpression(WideStringView wsString);
~CXFA_FMStringExpression() override;
- bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override;
+ bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) override;
private:
WideStringView m_wsString;
@@ -71,7 +71,7 @@ class CXFA_FMIdentifierExpression : public CXFA_FMSimpleExpression {
explicit CXFA_FMIdentifierExpression(WideStringView wsIdentifier);
~CXFA_FMIdentifierExpression() override;
- bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override;
+ bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) override;
private:
WideStringView m_wsIdentifier;
@@ -84,7 +84,7 @@ class CXFA_FMAssignExpression : public CXFA_FMSimpleExpression {
std::unique_ptr<CXFA_FMSimpleExpression> pExp2);
~CXFA_FMAssignExpression() override;
- bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override;
+ bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) override;
private:
std::unique_ptr<CXFA_FMSimpleExpression> m_pExp1;
@@ -95,7 +95,7 @@ class CXFA_FMBinExpression : public CXFA_FMSimpleExpression {
public:
~CXFA_FMBinExpression() override;
- bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override;
+ bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) override;
protected:
CXFA_FMBinExpression(const WideString& opName,
@@ -209,7 +209,7 @@ class CXFA_FMUnaryExpression : public CXFA_FMSimpleExpression {
public:
~CXFA_FMUnaryExpression() override;
- bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override;
+ bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) override;
protected:
CXFA_FMUnaryExpression(const WideString& opName,
@@ -249,7 +249,7 @@ class CXFA_FMCallExpression : public CXFA_FMSimpleExpression {
bool IsBuiltInFunc(CFX_WideTextBuf* funcName);
uint32_t IsMethodWithObjParam(const WideString& methodName);
- bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override;
+ bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) override;
private:
std::unique_ptr<CXFA_FMSimpleExpression> m_pExp;
@@ -266,7 +266,7 @@ class CXFA_FMDotAccessorExpression : public CXFA_FMSimpleExpression {
std::unique_ptr<CXFA_FMSimpleExpression> pIndexExp);
~CXFA_FMDotAccessorExpression() override;
- bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override;
+ bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) override;
private:
WideStringView m_wsIdentifier;
@@ -281,7 +281,7 @@ class CXFA_FMIndexExpression : public CXFA_FMSimpleExpression {
bool bIsStarIndex);
~CXFA_FMIndexExpression() override;
- bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override;
+ bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) override;
private:
std::unique_ptr<CXFA_FMSimpleExpression> m_pExp;
@@ -298,7 +298,7 @@ class CXFA_FMDotDotAccessorExpression : public CXFA_FMSimpleExpression {
std::unique_ptr<CXFA_FMSimpleExpression> pIndexExp);
~CXFA_FMDotDotAccessorExpression() override;
- bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override;
+ bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) override;
private:
WideStringView m_wsIdentifier;
@@ -313,13 +313,13 @@ class CXFA_FMMethodCallExpression : public CXFA_FMSimpleExpression {
std::unique_ptr<CXFA_FMSimpleExpression> pCallExp);
~CXFA_FMMethodCallExpression() override;
- bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override;
+ bool ToJavaScript(CFX_WideTextBuf* js, ReturnType type) override;
private:
std::unique_ptr<CXFA_FMSimpleExpression> m_pExp1;
std::unique_ptr<CXFA_FMSimpleExpression> m_pExp2;
};
-bool CXFA_IsTooBig(const CFX_WideTextBuf& javascript);
+bool CXFA_IsTooBig(const CFX_WideTextBuf* js);
#endif // XFA_FXFA_FM2JS_CXFA_FMSIMPLEEXPRESSION_H_
diff --git a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression_unittest.cpp b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression_unittest.cpp
index 3ff2b411f9..e5f78aaa56 100644
--- a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression_unittest.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression_unittest.cpp
@@ -27,7 +27,7 @@ TEST(FMCallExpressionTest, more_than_32_arguments) {
CXFA_FMCallExpression callExp(std::move(exp), std::move(args), true);
CFX_WideTextBuf js;
- callExp.ToJavaScript(js, ReturnType::kInfered);
+ callExp.ToJavaScript(&js, ReturnType::kInfered);
// Generate the result javascript string.
WideString result = L"sign(";
@@ -50,21 +50,22 @@ TEST(FMCallExpressionTest, more_than_32_arguments) {
TEST(FMStringExpressionTest, Empty) {
CXFA_FMToJavaScriptDepth::Reset();
CFX_WideTextBuf accumulator;
- CXFA_FMStringExpression(L"").ToJavaScript(accumulator, ReturnType::kInfered);
+ CXFA_FMStringExpression(L"").ToJavaScript(&accumulator, ReturnType::kInfered);
EXPECT_EQ(L"", accumulator.AsStringView());
}
TEST(FMStringExpressionTest, Short) {
CXFA_FMToJavaScriptDepth::Reset();
CFX_WideTextBuf accumulator;
- CXFA_FMStringExpression(L"a").ToJavaScript(accumulator, ReturnType::kInfered);
+ CXFA_FMStringExpression(L"a").ToJavaScript(&accumulator,
+ ReturnType::kInfered);
EXPECT_EQ(L"a", accumulator.AsStringView());
}
TEST(FMStringExpressionTest, Medium) {
CXFA_FMToJavaScriptDepth::Reset();
CFX_WideTextBuf accumulator;
- CXFA_FMStringExpression(L".abcd.").ToJavaScript(accumulator,
+ CXFA_FMStringExpression(L".abcd.").ToJavaScript(&accumulator,
ReturnType::kInfered);
EXPECT_EQ(L"\"abcd\"", accumulator.AsStringView());
}
@@ -74,7 +75,7 @@ TEST(FMStringExpressionTest, Long) {
CFX_WideTextBuf accumulator;
std::vector<WideStringView::UnsignedType> vec(140000, L'A');
CXFA_FMStringExpression(WideStringView(vec))
- .ToJavaScript(accumulator, ReturnType::kInfered);
+ .ToJavaScript(&accumulator, ReturnType::kInfered);
EXPECT_EQ(140000u, accumulator.GetLength());
}
@@ -82,6 +83,6 @@ TEST(FMStringExpressionTest, Quoted) {
CXFA_FMToJavaScriptDepth::Reset();
CFX_WideTextBuf accumulator;
CXFA_FMStringExpression(L".Simon says \"\"run\"\".")
- .ToJavaScript(accumulator, ReturnType::kInfered);
+ .ToJavaScript(&accumulator, ReturnType::kInfered);
EXPECT_EQ(L"\"Simon says \\\"run\\\"\"", accumulator.AsStringView());
}