summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp48
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmexpression.cpp6
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmparse_unittest.cpp104
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp34
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmsimpleexpression.h5
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmsimpleexpression_unittest.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_scriptcontext.cpp2
7 files changed, 81 insertions, 122 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
index b074a9aa57..f191707ca3 100644
--- a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
@@ -324,30 +324,30 @@ const FXJSE_FUNCTION_DESCRIPTOR formcalc_fm2js_functions[] = {
{"Get", CXFA_FM2JSContext::Get},
{"Post", CXFA_FM2JSContext::Post},
{"Put", CXFA_FM2JSContext::Put},
- {"positive_operator", CXFA_FM2JSContext::positive_operator},
- {"negative_operator", CXFA_FM2JSContext::negative_operator},
- {"logical_or_operator", CXFA_FM2JSContext::logical_or_operator},
- {"logical_and_operator", CXFA_FM2JSContext::logical_and_operator},
- {"logical_not_operator", CXFA_FM2JSContext::logical_not_operator},
- {"equality_operator", CXFA_FM2JSContext::equality_operator},
- {"notequality_operator", CXFA_FM2JSContext::notequality_operator},
- {"less_operator", CXFA_FM2JSContext::less_operator},
- {"lessequal_operator", CXFA_FM2JSContext::lessequal_operator},
- {"greater_operator", CXFA_FM2JSContext::greater_operator},
- {"greaterequal_operator", CXFA_FM2JSContext::greaterequal_operator},
- {"plus_operator", CXFA_FM2JSContext::plus_operator},
- {"minus_operator", CXFA_FM2JSContext::minus_operator},
- {"multiple_operator", CXFA_FM2JSContext::multiple_operator},
- {"divide_operator", CXFA_FM2JSContext::divide_operator},
- {"assign_value_operator", CXFA_FM2JSContext::assign_value_operator},
- {"dot_accessor", CXFA_FM2JSContext::dot_accessor},
- {"dotdot_accessor", CXFA_FM2JSContext::dotdot_accessor},
- {"concat_fm_object", CXFA_FM2JSContext::concat_fm_object},
- {"is_fm_object", CXFA_FM2JSContext::is_fm_object},
- {"is_fm_array", CXFA_FM2JSContext::is_fm_array},
- {"get_fm_value", CXFA_FM2JSContext::get_fm_value},
- {"get_fm_jsobj", CXFA_FM2JSContext::get_fm_jsobj},
- {"fm_var_filter", CXFA_FM2JSContext::fm_var_filter},
+ {"pos_op", CXFA_FM2JSContext::positive_operator},
+ {"neg_op", CXFA_FM2JSContext::negative_operator},
+ {"log_or_op", CXFA_FM2JSContext::logical_or_operator},
+ {"log_and_op", CXFA_FM2JSContext::logical_and_operator},
+ {"log_not_op", CXFA_FM2JSContext::logical_not_operator},
+ {"eq_op", CXFA_FM2JSContext::equality_operator},
+ {"neq_op", CXFA_FM2JSContext::notequality_operator},
+ {"lt_op", CXFA_FM2JSContext::less_operator},
+ {"le_op", CXFA_FM2JSContext::lessequal_operator},
+ {"gt_op", CXFA_FM2JSContext::greater_operator},
+ {"gteq_op", CXFA_FM2JSContext::greaterequal_operator},
+ {"plus_op", CXFA_FM2JSContext::plus_operator},
+ {"minus_op", CXFA_FM2JSContext::minus_operator},
+ {"mul_op", CXFA_FM2JSContext::multiple_operator},
+ {"div_op", CXFA_FM2JSContext::divide_operator},
+ {"asgn_val_op", CXFA_FM2JSContext::assign_value_operator},
+ {"dot_acc", CXFA_FM2JSContext::dot_accessor},
+ {"dotdot_acc", CXFA_FM2JSContext::dotdot_accessor},
+ {"concat_obj", CXFA_FM2JSContext::concat_fm_object},
+ {"is_obj", CXFA_FM2JSContext::is_fm_object},
+ {"is_ary", CXFA_FM2JSContext::is_fm_array},
+ {"get_val", CXFA_FM2JSContext::get_fm_value},
+ {"get_jsobj", CXFA_FM2JSContext::get_fm_jsobj},
+ {"var_filter", CXFA_FM2JSContext::fm_var_filter},
};
const FXJSE_CLASS_DESCRIPTOR formcalc_fm2js_descriptor = {
diff --git a/xfa/fxfa/fm2js/cxfa_fmexpression.cpp b/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
index 78f6a1f340..7e6e0954aa 100644
--- a/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
@@ -12,11 +12,9 @@
namespace {
-const wchar_t RUNTIMEBLOCKTEMPARRAY[] =
- L"foxit_xfa_formcalc_runtime_block_temp_array";
+const wchar_t RUNTIMEBLOCKTEMPARRAY[] = L"pfm_ary";
-const wchar_t RUNTIMEBLOCKTEMPARRAYINDEX[] =
- L"foxit_xfa_formcalc_runtime_block_temp_array_index";
+const wchar_t RUNTIMEBLOCKTEMPARRAYINDEX[] = L"pfm_ary_idx";
const wchar_t kLessEqual[] = L" <= ";
const wchar_t kGreaterEqual[] = L" >= ";
diff --git a/xfa/fxfa/fm2js/cxfa_fmparse_unittest.cpp b/xfa/fxfa/fm2js/cxfa_fmparse_unittest.cpp
index a17808ae88..c98cd227ce 100644
--- a/xfa/fxfa/fm2js/cxfa_fmparse_unittest.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmparse_unittest.cpp
@@ -38,6 +38,13 @@ TEST(CXFA_FMParseTest, CommentOnlyIsError) {
}
TEST(CXFA_FMParseTest, CommentThenValue) {
+ const wchar_t ret[] =
+ L"(\nfunction ()\n{\n"
+ L"var pfm_ret = null;\n"
+ L"pfm_ret = 12;\n"
+ L"return pfm_rt.get_val(pfm_ret);\n"
+ L"}\n).call(this);\n";
+
CXFA_FMErrorInfo errorInfo;
auto parser =
pdfium::MakeUnique<CXFA_FMParse>(L"; Just comment\n12", &errorInfo);
@@ -47,15 +54,7 @@ TEST(CXFA_FMParseTest, CommentThenValue) {
CFX_WideTextBuf buf;
EXPECT_TRUE(ast->ToJavaScript(buf));
- EXPECT_EQ(L"(\n"
- L"function ()\n"
- L"{\n"
- L"var foxit_xfa_formcalc_runtime_func_return_value = null;\n"
- L"foxit_xfa_formcalc_runtime_func_return_value = 12;\n"
- L"return foxit_xfa_formcalc_runtime.get_fm_value("
- L"foxit_xfa_formcalc_runtime_func_return_value);\n"
- L"}\n"
- L").call(this);\n", buf.AsStringC());
+ EXPECT_EQ(ret, buf.AsStringC());
}
TEST(CXFA_FMParseTest, Parse) {
@@ -70,6 +69,38 @@ TEST(CXFA_FMParseTest, Parse) {
L"\n"
L"$";
+ const wchar_t ret[] =
+ L"(\nfunction ()\n{\n"
+ L"var pfm_ret = null;\n"
+ L"if (pfm_rt.is_obj(this))\n{\n"
+ L"pfm_rt.asgn_val_op(this, pfm_rt.Avg(pfm_rt.neg_op(3), 5, "
+ L"pfm_rt.neg_op(6), 12, pfm_rt.neg_op(13)));\n"
+ L"}\n"
+ L"if (pfm_rt.is_obj(this))\n{\n"
+ L"pfm_rt.asgn_val_op(this, pfm_rt.Avg(pfm_rt.dot_acc(pfm_rt.dotdot_acc("
+ L"Table2, \"Table2\", \"Row\", 1), \"\", \"Cell1\", 0, 0)));\n"
+ L"}\n"
+ L"if (pfm_rt.get_val(pfm_rt.neq_op(this, pfm_rt.neg_op(1))))\n{\n"
+ L"if (pfm_rt.is_obj(pfm_rt.dot_acc(pfm_rt.dot_acc(pfm_rt.dot_acc("
+ L"border, \"border\", \"fill\", 0, 0), \"\", \"color\", 0, 0), \"\", "
+ L"\"value\", 0, 0)))\n{\n"
+ L"pfm_rt.asgn_val_op(pfm_rt.dot_acc(pfm_rt.dot_acc("
+ L"pfm_rt.dot_acc(border, \"border\", \"fill\", 0, 0), \"\", "
+ L"\"color\", 0, 0), \"\", \"value\", 0, 0), \"255,64,64\");\n"
+ L"}\n"
+ L"}\nelse\n{\n"
+ L"if (pfm_rt.is_obj(pfm_rt.dot_acc(pfm_rt.dot_acc(pfm_rt.dot_acc("
+ L"border, \"border\", \"fill\", 0, 0), \"\", \"color\", 0, 0), \"\", "
+ L"\"value\", 0, 0)))\n{\n"
+ L"pfm_rt.asgn_val_op(pfm_rt.dot_acc(pfm_rt.dot_acc("
+ L"pfm_rt.dot_acc(border, \"border\", \"fill\", 0, 0), \"\", "
+ L"\"color\", 0, 0), \"\", \"value\", 0, 0), \"20,170,13\");\n"
+ L"}\n"
+ L"}\n"
+ L"pfm_ret = this;\n"
+ L"return pfm_rt.get_val(pfm_ret);\n"
+ L"}\n).call(this);\n";
+
CXFA_FMErrorInfo errorInfo;
auto parser = pdfium::MakeUnique<CXFA_FMParse>(input, &errorInfo);
std::unique_ptr<CXFA_FMFunctionDefinition> ast = parser->Parse();
@@ -78,58 +109,5 @@ TEST(CXFA_FMParseTest, Parse) {
CFX_WideTextBuf buf;
EXPECT_TRUE(ast->ToJavaScript(buf));
- EXPECT_EQ(
- L"(\nfunction ()\n{\n"
- L"var foxit_xfa_formcalc_runtime_func_return_value = null;\n"
- L"if (foxit_xfa_formcalc_runtime.is_fm_object(this))\n{\n"
- L"foxit_xfa_formcalc_runtime.assign_value_operator(this, "
- L"foxit_xfa_formcalc_runtime.Avg("
- L"foxit_xfa_formcalc_runtime.negative_operator(3), 5, "
- L"foxit_xfa_formcalc_runtime.negative_operator(6), 12, "
- L"foxit_xfa_formcalc_runtime.negative_operator(13)));\n"
- L"}\n"
- L"if (foxit_xfa_formcalc_runtime.is_fm_object(this))\n{\n"
- L"foxit_xfa_formcalc_runtime.assign_value_operator(this, "
- L"foxit_xfa_formcalc_runtime.Avg("
- L"foxit_xfa_formcalc_runtime.dot_accessor("
- L"foxit_xfa_formcalc_runtime.dotdot_accessor(Table2, \"Table2\", "
- L"\"Row\", 1), \"\", \"Cell1\", 0, 0)));\n"
- L"}\n"
- L"if (foxit_xfa_formcalc_runtime.get_fm_value("
- L"foxit_xfa_formcalc_runtime.notequality_operator(this, "
- L"foxit_xfa_formcalc_runtime.negative_operator(1))))\n{\n"
- L"if (foxit_xfa_formcalc_runtime.is_fm_object("
- L"foxit_xfa_formcalc_runtime.dot_accessor("
- L"foxit_xfa_formcalc_runtime.dot_accessor("
- L"foxit_xfa_formcalc_runtime.dot_accessor(border, "
- L"\"border\", \"fill\", 0, 0), \"\", \"color\", 0, 0), "
- L"\"\", \"value\", 0, 0)))\n{\n"
- L"foxit_xfa_formcalc_runtime.assign_value_operator("
- L"foxit_xfa_formcalc_runtime.dot_accessor("
- L"foxit_xfa_formcalc_runtime.dot_accessor("
- L"foxit_xfa_formcalc_runtime.dot_accessor("
- L"border, \"border\", \"fill\", 0, 0), \"\", "
- L"\"color\", 0, 0), \"\", \"value\", 0, 0), "
- L"\"255,64,64\");\n"
- L"}\n"
- L"}\nelse\n{\n"
- L"if (foxit_xfa_formcalc_runtime.is_fm_object("
- L"foxit_xfa_formcalc_runtime.dot_accessor("
- L"foxit_xfa_formcalc_runtime.dot_accessor("
- L"foxit_xfa_formcalc_runtime.dot_accessor("
- L"border, \"border\", \"fill\", 0, 0), \"\", \"color\", "
- L"0, 0), \"\", \"value\", 0, 0)))\n{\n"
- L"foxit_xfa_formcalc_runtime.assign_value_operator("
- L"foxit_xfa_formcalc_runtime.dot_accessor("
- L"foxit_xfa_formcalc_runtime.dot_accessor("
- L"foxit_xfa_formcalc_runtime.dot_accessor("
- L"border, \"border\", \"fill\", 0, 0), \"\", "
- L"\"color\", 0, 0), \"\", \"value\", 0, 0), "
- L"\"20,170,13\");\n"
- L"}\n"
- L"}\n"
- L"foxit_xfa_formcalc_runtime_func_return_value = this;\n"
- L"return foxit_xfa_formcalc_runtime.get_fm_value("
- L"foxit_xfa_formcalc_runtime_func_return_value);\n"
- L"}\n).call(this);\n", buf.AsStringC());
+ EXPECT_EQ(ret, buf.AsStringC());
}
diff --git a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
index 3b4dc7017d..fdcb200a2b 100644
--- a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
@@ -13,31 +13,15 @@
namespace {
const wchar_t* const gs_lpStrExpFuncName[] = {
- L"foxit_xfa_formcalc_runtime.assign_value_operator",
- L"foxit_xfa_formcalc_runtime.logical_or_operator",
- L"foxit_xfa_formcalc_runtime.logical_and_operator",
- L"foxit_xfa_formcalc_runtime.equality_operator",
- L"foxit_xfa_formcalc_runtime.notequality_operator",
- L"foxit_xfa_formcalc_runtime.less_operator",
- L"foxit_xfa_formcalc_runtime.lessequal_operator",
- L"foxit_xfa_formcalc_runtime.greater_operator",
- L"foxit_xfa_formcalc_runtime.greaterequal_operator",
- L"foxit_xfa_formcalc_runtime.plus_operator",
- L"foxit_xfa_formcalc_runtime.minus_operator",
- L"foxit_xfa_formcalc_runtime.multiple_operator",
- L"foxit_xfa_formcalc_runtime.divide_operator",
- L"foxit_xfa_formcalc_runtime.positive_operator",
- L"foxit_xfa_formcalc_runtime.negative_operator",
- L"foxit_xfa_formcalc_runtime.logical_not_operator",
- L"foxit_xfa_formcalc_runtime.",
- L"foxit_xfa_formcalc_runtime.dot_accessor",
- L"foxit_xfa_formcalc_runtime.dotdot_accessor",
- L"foxit_xfa_formcalc_runtime.concat_fm_object",
- L"foxit_xfa_formcalc_runtime.is_fm_object",
- L"foxit_xfa_formcalc_runtime.is_fm_array",
- L"foxit_xfa_formcalc_runtime.get_fm_value",
- L"foxit_xfa_formcalc_runtime.get_fm_jsobj",
- L"foxit_xfa_formcalc_runtime.fm_var_filter",
+ L"pfm_rt.asgn_val_op", L"pfm_rt.log_or_op", L"pfm_rt.log_and_op",
+ L"pfm_rt.eq_op", L"pfm_rt.neq_op", L"pfm_rt.lt_op",
+ L"pfm_rt.le_op", L"pfm_rt.gt_op", L"pfm_rt.ge_op",
+ L"pfm_rt.plus_op", L"pfm_rt.minus_op", L"pfm_rt.mul_op",
+ L"pfm_rt.div_op", L"pfm_rt.pos_op", L"pfm_rt.neg_op",
+ L"pfm_rt.log_not_op", L"pfm_rt.", L"pfm_rt.dot_acc",
+ L"pfm_rt.dotdot_acc", L"pfm_rt.concat_obj", L"pfm_rt.is_obj",
+ L"pfm_rt.is_ary", L"pfm_rt.get_val", L"pfm_rt.get_jsobj",
+ L"pfm_rt.var_filter",
};
struct XFA_FMBuildInFunc {
diff --git a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.h b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.h
index e6d39419ed..8cdaf35b0f 100644
--- a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.h
+++ b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.h
@@ -13,9 +13,8 @@
#include "core/fxcrt/fx_basic.h"
#include "xfa/fxfa/fm2js/cxfa_fmlexer.h"
-#define RUNTIMEFUNCTIONRETURNVALUE \
- (L"foxit_xfa_formcalc_runtime_func_return_value")
-#define EXCLAMATION_IN_IDENTIFIER (L"foxit_xfa_formcalc__exclamation__")
+#define RUNTIMEFUNCTIONRETURNVALUE L"pfm_ret"
+#define EXCLAMATION_IN_IDENTIFIER L"pfm__excl__"
enum XFA_FM_SimpleExpressionType {
ASSIGN,
diff --git a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression_unittest.cpp b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression_unittest.cpp
index f11459b107..18a67f4c39 100644
--- a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression_unittest.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression_unittest.cpp
@@ -31,12 +31,12 @@ TEST(FMCallExpressionTest, more_than_32_arguments) {
if (i > 0)
result += L", ";
- result += L"foxit_xfa_formcalc_runtime.get_fm_";
+ result += L"pfm_rt.get_";
// Object positions for sign() method.
if (i == 0 || i == 5 || i == 6)
result += L"jsobj()";
else
- result += L"value()";
+ result += L"val()";
}
result += L")";
diff --git a/xfa/fxfa/parser/cxfa_scriptcontext.cpp b/xfa/fxfa/parser/cxfa_scriptcontext.cpp
index cf6cb14fb9..cf6467e240 100644
--- a/xfa/fxfa/parser/cxfa_scriptcontext.cpp
+++ b/xfa/fxfa/parser/cxfa_scriptcontext.cpp
@@ -72,7 +72,7 @@ const FXJSE_CLASS_DESCRIPTOR VariablesClassDescriptor = {
CXFA_ScriptContext::NormalMethodCall,
};
-const char kFormCalcRuntime[] = "foxit_xfa_formcalc_runtime";
+const char kFormCalcRuntime[] = "pfm_rt";
CXFA_ThisProxy* ToThisProxy(CFXJSE_Value* pValue, CFXJSE_Class* pClass) {
return static_cast<CXFA_ThisProxy*>(pValue->ToHostObject(pClass));