diff options
Diffstat (limited to 'xfa/src')
-rw-r--r-- | xfa/src/fxfa/src/fm2js/xfa_expression.cpp | 213 | ||||
-rw-r--r-- | xfa/src/fxfa/src/fm2js/xfa_expression.h | 115 | ||||
-rw-r--r-- | xfa/src/fxfa/src/fm2js/xfa_simpleexpression.cpp | 100 | ||||
-rw-r--r-- | xfa/src/fxfa/src/fm2js/xfa_simpleexpression.h | 10 |
4 files changed, 211 insertions, 227 deletions
diff --git a/xfa/src/fxfa/src/fm2js/xfa_expression.cpp b/xfa/src/fxfa/src/fm2js/xfa_expression.cpp index 6f135c8645..93b604df7e 100644 --- a/xfa/src/fxfa/src/fm2js/xfa_expression.cpp +++ b/xfa/src/fxfa/src/fm2js/xfa_expression.cpp @@ -8,19 +8,28 @@ #include "core/include/fxcrt/fx_basic.h" -static CFX_WideStringC RUNTIMEBLOCKTEMPARRAY = +namespace { + +const CFX_WideStringC RUNTIMEBLOCKTEMPARRAY = FX_WSTRC(L"foxit_xfa_formcalc_runtime_block_temp_array"); -static CFX_WideStringC RUNTIMEBLOCKTEMPARRAYINDEX = + +const CFX_WideStringC RUNTIMEBLOCKTEMPARRAYINDEX = FX_WSTRC(L"foxit_xfa_formcalc_runtime_block_temp_array_index"); +} // namespace + CXFA_FMExpression::CXFA_FMExpression(FX_DWORD line) : m_type(XFA_FM_EXPTYPE_UNKNOWN), m_line(line) { } + CXFA_FMExpression::CXFA_FMExpression(FX_DWORD line, XFA_FM_EXPTYPE type) : m_type(type), m_line(line) { } + void CXFA_FMExpression::ToJavaScript(CFX_WideTextBuf& javascript) {} + void CXFA_FMExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {} + CXFA_FMFunctionDefinition::CXFA_FMFunctionDefinition( FX_DWORD line, FX_BOOL isGlobal, @@ -33,26 +42,21 @@ CXFA_FMFunctionDefinition::CXFA_FMFunctionDefinition( m_pExpressions(pExpressions), m_isGlobal(isGlobal) { } + CXFA_FMFunctionDefinition::~CXFA_FMFunctionDefinition() { if (m_pArguments) { m_pArguments->RemoveAll(); delete m_pArguments; - m_pArguments = 0; } if (m_pExpressions) { - int32_t expc = m_pExpressions->GetSize(); - int32_t index = 0; - CXFA_FMExpression* e = 0; - while (index < expc) { - e = (CXFA_FMExpression*)m_pExpressions->GetAt(index); - delete e; - index++; + for (int i = 0; i < m_pExpressions->GetSize(); ++i) { + delete reinterpret_cast<CXFA_FMExpression*>(m_pExpressions->GetAt(i)); } m_pExpressions->RemoveAll(); delete m_pExpressions; - m_pExpressions = 0; } } + void CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) { if (m_isGlobal && (!m_pExpressions || m_pExpressions->GetSize() == 0)) { javascript << FX_WSTRC(L"// comments only"); @@ -70,11 +74,9 @@ void CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) { } javascript << FX_WSTRC(L"("); if (m_pArguments != 0) { - int32_t argc = m_pArguments->GetSize(); - int32_t index = 0; CFX_WideStringC identifier = 0; - while (index < argc) { - identifier = m_pArguments->GetAt(index); + for (int i = 0; i < m_pArguments->GetSize(); ++i) { + identifier = m_pArguments->GetAt(i); if (identifier.GetAt(0) == L'!') { CFX_WideString tempIdentifier = EXCLAMATION_IN_IDENTIFIER + identifier.Mid(1); @@ -82,10 +84,9 @@ void CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) { } else { javascript << identifier; } - if (index + 1 < argc) { + if (i + 1 < m_pArguments->GetSize()) { javascript << FX_WSTRC(L", "); } - index++; } } javascript << FX_WSTRC(L")\n{\n"); @@ -93,17 +94,14 @@ void CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << RUNTIMEFUNCTIONRETURNVALUE; javascript << FX_WSTRC(L" = null;\n"); if (m_pExpressions) { - int32_t expc = m_pExpressions->GetSize(); - int32_t index = 0; - CXFA_FMExpression* e = 0; - while (index < expc) { - e = (CXFA_FMExpression*)m_pExpressions->GetAt(index); - if (index + 1 < expc) { + for (int i = 0; i < m_pExpressions->GetSize(); ++i) { + CXFA_FMExpression* e = + reinterpret_cast<CXFA_FMExpression*>(m_pExpressions->GetAt(i)); + if (i + 1 < m_pExpressions->GetSize()) { e->ToJavaScript(javascript); } else { e->ToImpliedReturnJS(javascript); } - index++; } } javascript << FX_WSTRC(L"return "); @@ -120,19 +118,16 @@ void CXFA_FMFunctionDefinition::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC(L").call(this);\n"); } } + void CXFA_FMFunctionDefinition::ToImpliedReturnJS(CFX_WideTextBuf&) {} + CXFA_FMVarExpression::CXFA_FMVarExpression(FX_DWORD line, const CFX_WideStringC& wsName, CXFA_FMExpression* pInit) : CXFA_FMExpression(line, XFA_FM_EXPTYPE_VAR), m_wsName(wsName), m_pInit(pInit) {} -CXFA_FMVarExpression::~CXFA_FMVarExpression() { - if (m_pInit) { - delete m_pInit; - m_pInit = 0; - } -} + void CXFA_FMVarExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC(L"var "); CFX_WideString tempName = m_wsName; @@ -153,6 +148,7 @@ void CXFA_FMVarExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC(L"\"\";\n"); } } + void CXFA_FMVarExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC(L"var "); CFX_WideString tempName = m_wsName; @@ -177,15 +173,11 @@ void CXFA_FMVarExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << tempName; javascript << FX_WSTRC(L";\n"); } + CXFA_FMExpExpression::CXFA_FMExpExpression(FX_DWORD line, CXFA_FMSimpleExpression* pExpression) : CXFA_FMExpression(line, XFA_FM_EXPTYPE_EXP), m_pExpression(pExpression) {} -CXFA_FMExpExpression::~CXFA_FMExpExpression() { - if (m_pExpression) { - delete m_pExpression; - m_pExpression = 0; - } -} + void CXFA_FMExpExpression::ToJavaScript(CFX_WideTextBuf& javascript) { if (m_pExpression->GetOperatorToken() == TOKassign) { m_pExpression->ToJavaScript(javascript); @@ -194,6 +186,7 @@ void CXFA_FMExpExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC(L";\n"); } } + void CXFA_FMExpExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { if (m_pExpression->GetOperatorToken() == TOKassign) { m_pExpression->ToImpliedReturnJS(javascript); @@ -217,72 +210,62 @@ void CXFA_FMExpExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { } } } + CXFA_FMBlockExpression::CXFA_FMBlockExpression(FX_DWORD line, CFX_PtrArray* pExpressionList) : CXFA_FMExpression(line, XFA_FM_EXPTYPE_BLOCK), m_pExpressionList(pExpressionList) {} + CXFA_FMBlockExpression::~CXFA_FMBlockExpression() { if (m_pExpressionList) { - int32_t expc = m_pExpressionList->GetSize(); - int32_t index = 0; - CXFA_FMExpression* e = 0; - while (index < expc) { - e = (CXFA_FMExpression*)m_pExpressionList->GetAt(index); - delete e; - index++; + for (int i = 0; i < m_pExpressionList->GetSize(); ++i) { + delete reinterpret_cast<CXFA_FMExpression*>(m_pExpressionList->GetAt(i)); } m_pExpressionList->RemoveAll(); delete m_pExpressionList; - m_pExpressionList = 0; } } + void CXFA_FMBlockExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC(L"{\n"); if (m_pExpressionList) { - int32_t expc = m_pExpressionList->GetSize(); - int32_t index = 0; - CXFA_FMExpression* e = 0; - while (index < expc) { - e = (CXFA_FMExpression*)m_pExpressionList->GetAt(index); + for (int i = 0; i < m_pExpressionList->GetSize(); ++i) { + CXFA_FMExpression* e = + reinterpret_cast<CXFA_FMExpression*>(m_pExpressionList->GetAt(i)); e->ToJavaScript(javascript); - index++; } } javascript << FX_WSTRC(L"}\n"); } + void CXFA_FMBlockExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC(L"{\n"); if (m_pExpressionList) { - int32_t expc = m_pExpressionList->GetSize(); - int32_t index = 0; - CXFA_FMExpression* e = 0; - while (index < expc) { - e = (CXFA_FMExpression*)m_pExpressionList->GetAt(index); - if (index + 1 == expc) { + for (int i = 0; i < m_pExpressionList->GetSize(); ++i) { + CXFA_FMExpression* e = + reinterpret_cast<CXFA_FMExpression*>(m_pExpressionList->GetAt(i)); + if (i + 1 == m_pExpressionList->GetSize()) { e->ToImpliedReturnJS(javascript); } else { e->ToJavaScript(javascript); } - index++; } } javascript << FX_WSTRC(L"}\n"); } + CXFA_FMDoExpression::CXFA_FMDoExpression(FX_DWORD line, CXFA_FMExpression* pList) : CXFA_FMExpression(line), m_pList(pList) {} -CXFA_FMDoExpression::~CXFA_FMDoExpression() { - if (m_pList) { - delete m_pList; - m_pList = 0; - } -} + void CXFA_FMDoExpression::ToJavaScript(CFX_WideTextBuf& javascript) { m_pList->ToJavaScript(javascript); } + void CXFA_FMDoExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { m_pList->ToImpliedReturnJS(javascript); } + CXFA_FMIfExpression::CXFA_FMIfExpression(FX_DWORD line, CXFA_FMSimpleExpression* pExpression, CXFA_FMExpression* pIfExpression, @@ -291,20 +274,7 @@ CXFA_FMIfExpression::CXFA_FMIfExpression(FX_DWORD line, m_pExpression(pExpression), m_pIfExpression(pIfExpression), m_pElseExpression(pElseExpression) {} -CXFA_FMIfExpression::~CXFA_FMIfExpression() { - if (m_pExpression) { - delete m_pExpression; - m_pExpression = 0; - } - if (m_pIfExpression) { - delete m_pIfExpression; - m_pIfExpression = 0; - } - if (m_pElseExpression) { - delete m_pElseExpression; - m_pElseExpression = 0; - } -} + void CXFA_FMIfExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC(L"if ("); if (m_pExpression) { @@ -329,6 +299,7 @@ void CXFA_FMIfExpression::ToJavaScript(CFX_WideTextBuf& javascript) { } } } + void CXFA_FMIfExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << RUNTIMEFUNCTIONRETURNVALUE; javascript << FX_WSTRC(L" = 0;\n"); @@ -355,9 +326,13 @@ void CXFA_FMIfExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { } } } + CXFA_FMLoopExpression::~CXFA_FMLoopExpression() {} + void CXFA_FMLoopExpression::ToJavaScript(CFX_WideTextBuf& javascript) {} + void CXFA_FMLoopExpression::ToImpliedReturnJS(CFX_WideTextBuf&) {} + CXFA_FMWhileExpression::CXFA_FMWhileExpression( FX_DWORD line, CXFA_FMSimpleExpression* pCondition, @@ -365,22 +340,14 @@ CXFA_FMWhileExpression::CXFA_FMWhileExpression( : CXFA_FMLoopExpression(line), m_pCondition(pCondition), m_pExpression(pExpression) {} -CXFA_FMWhileExpression::~CXFA_FMWhileExpression() { - if (m_pCondition) { - delete m_pCondition; - m_pCondition = 0; - } - if (m_pExpression) { - delete m_pExpression; - m_pExpression = 0; - } -} + void CXFA_FMWhileExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC(L"while ("); m_pCondition->ToJavaScript(javascript); javascript << FX_WSTRC(L")\n"); m_pExpression->ToJavaScript(javascript); } + void CXFA_FMWhileExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << RUNTIMEFUNCTIONRETURNVALUE; javascript << FX_WSTRC(L" = 0;\n"); @@ -389,34 +356,43 @@ void CXFA_FMWhileExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC(L")\n"); m_pExpression->ToImpliedReturnJS(javascript); } + CXFA_FMBreakExpression::CXFA_FMBreakExpression(FX_DWORD line) : CXFA_FMExpression(line, XFA_FM_EXPTYPE_BREAK) { } + CXFA_FMBreakExpression::~CXFA_FMBreakExpression() {} + void CXFA_FMBreakExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << RUNTIMEFUNCTIONRETURNVALUE; javascript << FX_WSTRC(L" = 0;\n"); javascript << FX_WSTRC(L"break;\n"); } + void CXFA_FMBreakExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << RUNTIMEFUNCTIONRETURNVALUE; javascript << FX_WSTRC(L" = 0;\n"); javascript << FX_WSTRC(L"break;\n"); } + CXFA_FMContinueExpression::CXFA_FMContinueExpression(FX_DWORD line) : CXFA_FMExpression(line, XFA_FM_EXPTYPE_CONTINUE) { } + CXFA_FMContinueExpression::~CXFA_FMContinueExpression() {} + void CXFA_FMContinueExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << RUNTIMEFUNCTIONRETURNVALUE; javascript << FX_WSTRC(L" = 0;\n"); javascript << FX_WSTRC(L"continue;\n"); } + void CXFA_FMContinueExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << RUNTIMEFUNCTIONRETURNVALUE; javascript << FX_WSTRC(L" = 0;\n"); javascript << FX_WSTRC(L"continue;\n"); } + CXFA_FMForExpression::CXFA_FMForExpression(FX_DWORD line, const CFX_WideStringC& wsVariant, CXFA_FMSimpleExpression* pAssignment, @@ -431,24 +407,7 @@ CXFA_FMForExpression::CXFA_FMForExpression(FX_DWORD line, m_iDirection(iDirection), m_pStep(pStep), m_pList(pList) {} -CXFA_FMForExpression::~CXFA_FMForExpression() { - if (m_pAssignment) { - delete m_pAssignment; - m_pAssignment = 0; - } - if (m_pAccessor) { - delete m_pAccessor; - m_pAccessor = 0; - } - if (m_pStep) { - delete m_pStep; - m_pStep = 0; - } - if (m_pList) { - delete m_pList; - m_pList = 0; - } -} + void CXFA_FMForExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC(L"{\nvar "); CFX_WideString tempVariant; @@ -497,6 +456,7 @@ void CXFA_FMForExpression::ToJavaScript(CFX_WideTextBuf& javascript) { m_pList->ToJavaScript(javascript); javascript << FX_WSTRC(L"}\n"); } + void CXFA_FMForExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << RUNTIMEFUNCTIONRETURNVALUE; javascript << FX_WSTRC(L" = 0;\n"); @@ -547,6 +507,7 @@ void CXFA_FMForExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { m_pList->ToImpliedReturnJS(javascript); javascript << FX_WSTRC(L"}\n"); } + CXFA_FMForeachExpression::CXFA_FMForeachExpression( FX_DWORD line, const CFX_WideStringC& wsIdentifier, @@ -556,25 +517,17 @@ CXFA_FMForeachExpression::CXFA_FMForeachExpression( m_wsIdentifier(wsIdentifier), m_pAccessors(pAccessors), m_pList(pList) {} + CXFA_FMForeachExpression::~CXFA_FMForeachExpression() { - if (m_pList) { - delete m_pList; - m_pList = 0; - } if (m_pAccessors) { - int32_t size = m_pAccessors->GetSize(); - int32_t index = 0; - CXFA_FMSimpleExpression* e = 0; - while (index < size) { - e = (CXFA_FMSimpleExpression*)m_pAccessors->GetAt(index); - delete e; - index++; + for (int i = 0; i < m_pAccessors->GetSize(); ++i) { + delete reinterpret_cast<CXFA_FMSimpleExpression*>(m_pAccessors->GetAt(i)); } m_pAccessors->RemoveAll(); delete m_pAccessors; - m_pAccessors = 0; } } + void CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC(L"{\n"); javascript << FX_WSTRC(L"var "); @@ -591,18 +544,15 @@ void CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC(L" = "); javascript << XFA_FM_EXPTypeToString(CONCATFMOBJECT); javascript << FX_WSTRC(L"("); - int32_t iSize = m_pAccessors->GetSize(); - int32_t index = 0; - CXFA_FMSimpleExpression* s = 0; - while (index < iSize) { - s = (CXFA_FMSimpleExpression*)m_pAccessors->GetAt(index); + + for (int i = 0; i < m_pAccessors->GetSize(); ++i) { + CXFA_FMSimpleExpression* s = + reinterpret_cast<CXFA_FMSimpleExpression*>(m_pAccessors->GetAt(i)); s->ToJavaScript(javascript); - if (index + 1 < iSize) { + if (i + 1 < m_pAccessors->GetSize()) { javascript << FX_WSTRC(L", "); } - index++; } - s = 0; javascript << FX_WSTRC(L");\n"); javascript << FX_WSTRC(L"var "); javascript << RUNTIMEBLOCKTEMPARRAYINDEX; @@ -628,6 +578,7 @@ void CXFA_FMForeachExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC(L"}\n"); javascript << FX_WSTRC(L"}\n"); } + void CXFA_FMForeachExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << RUNTIMEFUNCTIONRETURNVALUE; javascript << FX_WSTRC(L" = 0;\n"); @@ -646,18 +597,14 @@ void CXFA_FMForeachExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC(L" = "); javascript << XFA_FM_EXPTypeToString(CONCATFMOBJECT); javascript << FX_WSTRC(L"("); - int32_t iSize = m_pAccessors->GetSize(); - int32_t index = 0; - CXFA_FMSimpleExpression* s = 0; - while (index < iSize) { - s = (CXFA_FMSimpleExpression*)m_pAccessors->GetAt(index); + for (int i = 0; i < m_pAccessors->GetSize(); ++i) { + CXFA_FMSimpleExpression* s = + reinterpret_cast<CXFA_FMSimpleExpression*>(m_pAccessors->GetAt(i)); s->ToJavaScript(javascript); - if (index + 1 < iSize) { + if (i + 1 < m_pAccessors->GetSize()) { javascript << FX_WSTRC(L", "); } - index++; } - s = 0; javascript << FX_WSTRC(L");\n"); javascript << FX_WSTRC(L"var "); javascript << RUNTIMEBLOCKTEMPARRAYINDEX; diff --git a/xfa/src/fxfa/src/fm2js/xfa_expression.h b/xfa/src/fxfa/src/fm2js/xfa_expression.h index 2d2da0cb89..8fe251271b 100644 --- a/xfa/src/fxfa/src/fm2js/xfa_expression.h +++ b/xfa/src/fxfa/src/fm2js/xfa_expression.h @@ -7,6 +7,8 @@ #ifndef XFA_SRC_FXFA_SRC_FM2JS_XFA_EXPRESSION_H_ #define XFA_SRC_FXFA_SRC_FM2JS_XFA_EXPRESSION_H_ +#include <memory> + #include "xfa/src/fxfa/src/fm2js/xfa_simpleexpression.h" enum XFA_FM_EXPTYPE { @@ -19,9 +21,10 @@ enum XFA_FM_EXPTYPE { XFA_FM_EXPTYPE_BREAK, XFA_FM_EXPTYPE_CONTINUE, }; + class CXFA_FMExpression { public: - CXFA_FMExpression(FX_DWORD line); + explicit CXFA_FMExpression(FX_DWORD line); CXFA_FMExpression(FX_DWORD line, XFA_FM_EXPTYPE type); virtual ~CXFA_FMExpression() {} virtual void ToJavaScript(CFX_WideTextBuf& javascript); @@ -33,6 +36,7 @@ class CXFA_FMExpression { XFA_FM_EXPTYPE m_type; FX_DWORD m_line; }; + class CXFA_FMFunctionDefinition : public CXFA_FMExpression { public: CXFA_FMFunctionDefinition(FX_DWORD line, @@ -40,9 +44,9 @@ class CXFA_FMFunctionDefinition : public CXFA_FMExpression { const CFX_WideStringC& wsName, CFX_WideStringCArray* pArguments, CFX_PtrArray* pExpressions); - virtual ~CXFA_FMFunctionDefinition(); - virtual void ToJavaScript(CFX_WideTextBuf& javascript); - virtual void ToImpliedReturnJS(CFX_WideTextBuf&); + ~CXFA_FMFunctionDefinition() override; + void ToJavaScript(CFX_WideTextBuf& javascript) override; + void ToImpliedReturnJS(CFX_WideTextBuf&) override; private: CFX_WideStringC m_wsName; @@ -50,98 +54,103 @@ class CXFA_FMFunctionDefinition : public CXFA_FMExpression { CFX_PtrArray* m_pExpressions; FX_BOOL m_isGlobal; }; + class CXFA_FMVarExpression : public CXFA_FMExpression { public: CXFA_FMVarExpression(FX_DWORD line, const CFX_WideStringC& wsName, CXFA_FMExpression* pInit); - virtual ~CXFA_FMVarExpression(); - virtual void ToJavaScript(CFX_WideTextBuf& javascript); - virtual void ToImpliedReturnJS(CFX_WideTextBuf&); + void ToJavaScript(CFX_WideTextBuf& javascript) override; + void ToImpliedReturnJS(CFX_WideTextBuf&) override; private: CFX_WideStringC m_wsName; - CXFA_FMExpression* m_pInit; + std::unique_ptr<CXFA_FMExpression> m_pInit; }; + class CXFA_FMExpExpression : public CXFA_FMExpression { public: CXFA_FMExpExpression(FX_DWORD line, CXFA_FMSimpleExpression* pExpression); - virtual ~CXFA_FMExpExpression(); - virtual void ToJavaScript(CFX_WideTextBuf& javascript); - virtual void ToImpliedReturnJS(CFX_WideTextBuf&); + void ToJavaScript(CFX_WideTextBuf& javascript) override; + void ToImpliedReturnJS(CFX_WideTextBuf&) override; private: - CXFA_FMSimpleExpression* m_pExpression; + std::unique_ptr<CXFA_FMSimpleExpression> m_pExpression; }; + class CXFA_FMBlockExpression : public CXFA_FMExpression { public: CXFA_FMBlockExpression(FX_DWORD line, CFX_PtrArray* pExpressionList); - virtual ~CXFA_FMBlockExpression(); - virtual void ToJavaScript(CFX_WideTextBuf& javascript); - virtual void ToImpliedReturnJS(CFX_WideTextBuf&); + ~CXFA_FMBlockExpression() override; + void ToJavaScript(CFX_WideTextBuf& javascript) override; + void ToImpliedReturnJS(CFX_WideTextBuf&) override; private: CFX_PtrArray* m_pExpressionList; }; + class CXFA_FMDoExpression : public CXFA_FMExpression { public: CXFA_FMDoExpression(FX_DWORD line, CXFA_FMExpression* pList); - virtual ~CXFA_FMDoExpression(); - virtual void ToJavaScript(CFX_WideTextBuf& javascript); - virtual void ToImpliedReturnJS(CFX_WideTextBuf&); + void ToJavaScript(CFX_WideTextBuf& javascript) override; + void ToImpliedReturnJS(CFX_WideTextBuf&) override; private: - CXFA_FMExpression* m_pList; + std::unique_ptr<CXFA_FMExpression> m_pList; }; + class CXFA_FMIfExpression : public CXFA_FMExpression { public: CXFA_FMIfExpression(FX_DWORD line, CXFA_FMSimpleExpression* pExpression, CXFA_FMExpression* pIfExpression, CXFA_FMExpression* pElseExpression); - virtual ~CXFA_FMIfExpression(); - virtual void ToJavaScript(CFX_WideTextBuf& javascript); - virtual void ToImpliedReturnJS(CFX_WideTextBuf&); + void ToJavaScript(CFX_WideTextBuf& javascript) override; + void ToImpliedReturnJS(CFX_WideTextBuf&) override; private: - CXFA_FMSimpleExpression* m_pExpression; - CXFA_FMExpression* m_pIfExpression; - CXFA_FMExpression* m_pElseExpression; + std::unique_ptr<CXFA_FMSimpleExpression> m_pExpression; + std::unique_ptr<CXFA_FMExpression> m_pIfExpression; + std::unique_ptr<CXFA_FMExpression> m_pElseExpression; }; + class CXFA_FMLoopExpression : public CXFA_FMExpression { public: - CXFA_FMLoopExpression(FX_DWORD line) : CXFA_FMExpression(line) {} - virtual ~CXFA_FMLoopExpression(); - virtual void ToJavaScript(CFX_WideTextBuf& javascript); - virtual void ToImpliedReturnJS(CFX_WideTextBuf&); + explicit CXFA_FMLoopExpression(FX_DWORD line) : CXFA_FMExpression(line) {} + ~CXFA_FMLoopExpression() override; + void ToJavaScript(CFX_WideTextBuf& javascript) override; + void ToImpliedReturnJS(CFX_WideTextBuf&) override; }; + class CXFA_FMWhileExpression : public CXFA_FMLoopExpression { public: CXFA_FMWhileExpression(FX_DWORD line, CXFA_FMSimpleExpression* pCodition, CXFA_FMExpression* pExpression); - virtual ~CXFA_FMWhileExpression(); - virtual void ToJavaScript(CFX_WideTextBuf& javascript); - virtual void ToImpliedReturnJS(CFX_WideTextBuf&); + void ToJavaScript(CFX_WideTextBuf& javascript) override; + void ToImpliedReturnJS(CFX_WideTextBuf&) override; private: - CXFA_FMSimpleExpression* m_pCondition; - CXFA_FMExpression* m_pExpression; + std::unique_ptr<CXFA_FMSimpleExpression> m_pCondition; + std::unique_ptr<CXFA_FMExpression> m_pExpression; }; + class CXFA_FMBreakExpression : public CXFA_FMExpression { public: - CXFA_FMBreakExpression(FX_DWORD line); - virtual ~CXFA_FMBreakExpression(); - virtual void ToJavaScript(CFX_WideTextBuf& javascript); - virtual void ToImpliedReturnJS(CFX_WideTextBuf&); + explicit CXFA_FMBreakExpression(FX_DWORD line); + ~CXFA_FMBreakExpression() override; + void ToJavaScript(CFX_WideTextBuf& javascript) override; + void ToImpliedReturnJS(CFX_WideTextBuf&) override; }; + class CXFA_FMContinueExpression : public CXFA_FMExpression { public: - CXFA_FMContinueExpression(FX_DWORD line); - virtual ~CXFA_FMContinueExpression(); - virtual void ToJavaScript(CFX_WideTextBuf& javascript); - virtual void ToImpliedReturnJS(CFX_WideTextBuf&); + explicit CXFA_FMContinueExpression(FX_DWORD line); + ~CXFA_FMContinueExpression() override; + void ToJavaScript(CFX_WideTextBuf& javascript) override; + void ToImpliedReturnJS(CFX_WideTextBuf&) override; }; + class CXFA_FMForExpression : public CXFA_FMLoopExpression { public: CXFA_FMForExpression(FX_DWORD line, @@ -151,32 +160,32 @@ class CXFA_FMForExpression : public CXFA_FMLoopExpression { int32_t iDirection, CXFA_FMSimpleExpression* pStep, CXFA_FMExpression* pList); - virtual ~CXFA_FMForExpression(); - virtual void ToJavaScript(CFX_WideTextBuf& javascript); - virtual void ToImpliedReturnJS(CFX_WideTextBuf&); + void ToJavaScript(CFX_WideTextBuf& javascript) override; + void ToImpliedReturnJS(CFX_WideTextBuf&) override; private: CFX_WideStringC m_wsVariant; - CXFA_FMSimpleExpression* m_pAssignment; - CXFA_FMSimpleExpression* m_pAccessor; + std::unique_ptr<CXFA_FMSimpleExpression> m_pAssignment; + std::unique_ptr<CXFA_FMSimpleExpression> m_pAccessor; int32_t m_iDirection; - CXFA_FMSimpleExpression* m_pStep; - CXFA_FMExpression* m_pList; + std::unique_ptr<CXFA_FMSimpleExpression> m_pStep; + std::unique_ptr<CXFA_FMExpression> m_pList; }; + class CXFA_FMForeachExpression : public CXFA_FMLoopExpression { public: CXFA_FMForeachExpression(FX_DWORD line, const CFX_WideStringC& wsIdentifier, CFX_PtrArray* pAccessors, CXFA_FMExpression* pList); - virtual ~CXFA_FMForeachExpression(); - virtual void ToJavaScript(CFX_WideTextBuf& javascript); - virtual void ToImpliedReturnJS(CFX_WideTextBuf&); + ~CXFA_FMForeachExpression() override; + void ToJavaScript(CFX_WideTextBuf& javascript) override; + void ToImpliedReturnJS(CFX_WideTextBuf&) override; private: CFX_WideStringC m_wsIdentifier; CFX_PtrArray* m_pAccessors; - CXFA_FMExpression* m_pList; + std::unique_ptr<CXFA_FMExpression> m_pList; }; #endif // XFA_SRC_FXFA_SRC_FM2JS_XFA_EXPRESSION_H_ diff --git a/xfa/src/fxfa/src/fm2js/xfa_simpleexpression.cpp b/xfa/src/fxfa/src/fm2js/xfa_simpleexpression.cpp index a8f6ad135d..f849f791ee 100644 --- a/xfa/src/fxfa/src/fm2js/xfa_simpleexpression.cpp +++ b/xfa/src/fxfa/src/fm2js/xfa_simpleexpression.cpp @@ -116,25 +116,34 @@ CFX_WideStringC XFA_FM_EXPTypeToString( CXFA_FMSimpleExpression::CXFA_FMSimpleExpression(FX_DWORD line, XFA_FM_TOKEN op) : m_line(line), m_op(op) {} + void CXFA_FMSimpleExpression::ToJavaScript(CFX_WideTextBuf& javascript) {} + void CXFA_FMSimpleExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) {} + XFA_FM_TOKEN CXFA_FMSimpleExpression::GetOperatorToken() const { return m_op; } + CXFA_FMNullExpression::CXFA_FMNullExpression(FX_DWORD line) : CXFA_FMSimpleExpression(line, TOKnull) {} + void CXFA_FMNullExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC(L"null"); } + CXFA_FMNumberExpression::CXFA_FMNumberExpression(FX_DWORD line, CFX_WideStringC wsNumber) : CXFA_FMSimpleExpression(line, TOKnumber), m_wsNumber(wsNumber) {} + void CXFA_FMNumberExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << m_wsNumber; } + CXFA_FMStringExpression::CXFA_FMStringExpression(FX_DWORD line, CFX_WideStringC wsString) : CXFA_FMSimpleExpression(line, TOKstring), m_wsString(wsString) {} + void CXFA_FMStringExpression::ToJavaScript(CFX_WideTextBuf& javascript) { CFX_WideString tempStr = m_wsString; if (tempStr.GetLength() > 2) { @@ -160,11 +169,13 @@ void CXFA_FMStringExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << tempStr; } } + CXFA_FMIdentifierExpressionn::CXFA_FMIdentifierExpressionn( FX_DWORD line, CFX_WideStringC wsIdentifier) : CXFA_FMSimpleExpression(line, TOKidentifier), m_wsIdentifier(wsIdentifier) {} + void CXFA_FMIdentifierExpressionn::ToJavaScript(CFX_WideTextBuf& javascript) { CFX_WideString tempStr = m_wsIdentifier; if (tempStr.Equal(FX_WSTRC(L"$"))) { @@ -193,25 +204,23 @@ CXFA_FMUnaryExpression::CXFA_FMUnaryExpression(FX_DWORD line, XFA_FM_TOKEN op, CXFA_FMSimpleExpression* pExp) : CXFA_FMSimpleExpression(line, op), m_pExp(pExp) {} -CXFA_FMUnaryExpression::~CXFA_FMUnaryExpression() { - delete m_pExp; -} + void CXFA_FMUnaryExpression::ToJavaScript(CFX_WideTextBuf& javascript) {} + CXFA_FMBinExpression::CXFA_FMBinExpression(FX_DWORD 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() { - delete m_pExp1; - delete m_pExp2; -} + void CXFA_FMBinExpression::ToJavaScript(CFX_WideTextBuf& javascript) {} + CXFA_FMAssignExpression::CXFA_FMAssignExpression(FX_DWORD line, XFA_FM_TOKEN op, CXFA_FMSimpleExpression* pExp1, CXFA_FMSimpleExpression* pExp2) : CXFA_FMBinExpression(line, op, pExp1, pExp2) {} + void CXFA_FMAssignExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC(L"if ("); javascript << gs_lpStrExpFuncName[ISFMOBJECT]; @@ -239,6 +248,7 @@ void CXFA_FMAssignExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC(L");\n}\n"); } } + void CXFA_FMAssignExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC(L"if ("); javascript << gs_lpStrExpFuncName[ISFMOBJECT]; @@ -270,12 +280,14 @@ void CXFA_FMAssignExpression::ToImpliedReturnJS(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC(L");\n}\n"); } } + CXFA_FMLogicalOrExpression::CXFA_FMLogicalOrExpression( FX_DWORD line, XFA_FM_TOKEN op, CXFA_FMSimpleExpression* pExp1, CXFA_FMSimpleExpression* pExp2) : CXFA_FMBinExpression(line, op, pExp1, pExp2) {} + void CXFA_FMLogicalOrExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << gs_lpStrExpFuncName[LOGICALOR]; javascript << FX_WSTRC(L"("); @@ -284,12 +296,14 @@ void CXFA_FMLogicalOrExpression::ToJavaScript(CFX_WideTextBuf& javascript) { m_pExp2->ToJavaScript(javascript); javascript << FX_WSTRC(L")"); } + CXFA_FMLogicalAndExpression::CXFA_FMLogicalAndExpression( FX_DWORD line, XFA_FM_TOKEN op, CXFA_FMSimpleExpression* pExp1, CXFA_FMSimpleExpression* pExp2) : CXFA_FMBinExpression(line, op, pExp1, pExp2) {} + void CXFA_FMLogicalAndExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << gs_lpStrExpFuncName[LOGICALAND]; javascript << FX_WSTRC(L"("); @@ -298,12 +312,14 @@ void CXFA_FMLogicalAndExpression::ToJavaScript(CFX_WideTextBuf& javascript) { m_pExp2->ToJavaScript(javascript); javascript << FX_WSTRC(L")"); } + CXFA_FMEqualityExpression::CXFA_FMEqualityExpression( FX_DWORD line, XFA_FM_TOKEN op, CXFA_FMSimpleExpression* pExp1, CXFA_FMSimpleExpression* pExp2) : CXFA_FMBinExpression(line, op, pExp1, pExp2) {} + void CXFA_FMEqualityExpression::ToJavaScript(CFX_WideTextBuf& javascript) { switch (m_op) { case TOKeq: @@ -324,12 +340,14 @@ void CXFA_FMEqualityExpression::ToJavaScript(CFX_WideTextBuf& javascript) { m_pExp2->ToJavaScript(javascript); javascript << FX_WSTRC(L")"); } + CXFA_FMRelationalExpression::CXFA_FMRelationalExpression( FX_DWORD line, XFA_FM_TOKEN op, CXFA_FMSimpleExpression* pExp1, CXFA_FMSimpleExpression* pExp2) : CXFA_FMBinExpression(line, op, pExp1, pExp2) {} + void CXFA_FMRelationalExpression::ToJavaScript(CFX_WideTextBuf& javascript) { switch (m_op) { case TOKlt: @@ -358,12 +376,14 @@ void CXFA_FMRelationalExpression::ToJavaScript(CFX_WideTextBuf& javascript) { m_pExp2->ToJavaScript(javascript); javascript << FX_WSTRC(L")"); } + CXFA_FMAdditiveExpression::CXFA_FMAdditiveExpression( FX_DWORD line, XFA_FM_TOKEN op, CXFA_FMSimpleExpression* pExp1, CXFA_FMSimpleExpression* pExp2) : CXFA_FMBinExpression(line, op, pExp1, pExp2) {} + void CXFA_FMAdditiveExpression::ToJavaScript(CFX_WideTextBuf& javascript) { switch (m_op) { case TOKplus: @@ -382,12 +402,14 @@ void CXFA_FMAdditiveExpression::ToJavaScript(CFX_WideTextBuf& javascript) { m_pExp2->ToJavaScript(javascript); javascript << FX_WSTRC(L")"); } + CXFA_FMMultiplicativeExpression::CXFA_FMMultiplicativeExpression( FX_DWORD line, XFA_FM_TOKEN op, CXFA_FMSimpleExpression* pExp1, CXFA_FMSimpleExpression* pExp2) : CXFA_FMBinExpression(line, op, pExp1, pExp2) {} + void CXFA_FMMultiplicativeExpression::ToJavaScript( CFX_WideTextBuf& javascript) { switch (m_op) { @@ -407,33 +429,40 @@ void CXFA_FMMultiplicativeExpression::ToJavaScript( m_pExp2->ToJavaScript(javascript); javascript << FX_WSTRC(L")"); } + CXFA_FMPosExpression::CXFA_FMPosExpression(FX_DWORD line, CXFA_FMSimpleExpression* pExp) : CXFA_FMUnaryExpression(line, TOKplus, pExp) {} + void CXFA_FMPosExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << gs_lpStrExpFuncName[POSITIVE]; javascript << FX_WSTRC(L"("); m_pExp->ToJavaScript(javascript); javascript << FX_WSTRC(L")"); } + CXFA_FMNegExpression::CXFA_FMNegExpression(FX_DWORD line, CXFA_FMSimpleExpression* pExp) : CXFA_FMUnaryExpression(line, TOKminus, pExp) {} + void CXFA_FMNegExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << gs_lpStrExpFuncName[NEGATIVE]; javascript << FX_WSTRC(L"("); m_pExp->ToJavaScript(javascript); javascript << FX_WSTRC(L")"); } + CXFA_FMNotExpression::CXFA_FMNotExpression(FX_DWORD line, CXFA_FMSimpleExpression* pExp) : CXFA_FMUnaryExpression(line, TOKksnot, pExp) {} + void CXFA_FMNotExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << gs_lpStrExpFuncName[NOT]; javascript << FX_WSTRC(L"("); m_pExp->ToJavaScript(javascript); javascript << FX_WSTRC(L")"); } + CXFA_FMCallExpression::CXFA_FMCallExpression(FX_DWORD line, CXFA_FMSimpleExpression* pExp, CFX_PtrArray* pArguments, @@ -442,19 +471,14 @@ CXFA_FMCallExpression::CXFA_FMCallExpression(FX_DWORD line, m_bIsSomMethod(bIsSomMethod), m_pArguments(pArguments) { } + CXFA_FMCallExpression::~CXFA_FMCallExpression() { if (m_pArguments) { - int32_t argc = m_pArguments->GetSize(); - int32_t index = 0; - CXFA_FMSimpleExpression* e = 0; - while (index < argc) { - e = (CXFA_FMSimpleExpression*)m_pArguments->GetAt(index); - delete e; - index++; + for (int i = 0; i < m_pArguments->GetSize(); ++i) { + delete reinterpret_cast<CXFA_FMSimpleExpression*>(m_pArguments->GetAt(i)); } m_pArguments->RemoveAll(); delete m_pArguments; - m_pArguments = 0; } } @@ -498,6 +522,7 @@ FX_DWORD CXFA_FMCallExpression::IsMethodWithObjParam( } while (iStart <= iEnd); return parameters; } + void CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) { CFX_WideTextBuf funcName; m_pExp->ToJavaScript(funcName); @@ -505,38 +530,36 @@ void CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << funcName; javascript << FX_WSTRC(L"("); if (m_pArguments) { - int32_t argc = m_pArguments->GetSize(); - int32_t index = 0; FX_DWORD methodPara = IsMethodWithObjParam(funcName.GetWideString()); if (methodPara > 0) { - CXFA_FMSimpleExpression* e = 0; - while (index < argc) { - if ((methodPara & (0x01 << index)) > 0) { + for (int i = 0; i < m_pArguments->GetSize(); ++i) { + if ((methodPara & (0x01 << i)) > 0) { javascript << gs_lpStrExpFuncName[GETFMJSOBJ]; } else { javascript << gs_lpStrExpFuncName[GETFMVALUE]; } javascript << FX_WSTRC(L"("); - e = (CXFA_FMSimpleExpression*)m_pArguments->GetAt(index); + CXFA_FMSimpleExpression* e = + reinterpret_cast<CXFA_FMSimpleExpression*>( + m_pArguments->GetAt(i)); e->ToJavaScript(javascript); javascript << FX_WSTRC(L")"); - if (index + 1 < argc) { + if (i + 1 < m_pArguments->GetSize()) { javascript << FX_WSTRC(L", "); } - index++; } } else { - CXFA_FMSimpleExpression* e = 0; - while (index < argc) { + for (int i = 0; i < m_pArguments->GetSize(); ++i) { javascript << gs_lpStrExpFuncName[GETFMVALUE]; javascript << FX_WSTRC(L"("); - e = (CXFA_FMSimpleExpression*)m_pArguments->GetAt(index); + CXFA_FMSimpleExpression* e = + reinterpret_cast<CXFA_FMSimpleExpression*>( + m_pArguments->GetAt(i)); e->ToJavaScript(javascript); javascript << FX_WSTRC(L")"); - if (index + 1 < argc) { + if (i + 1 < m_pArguments->GetSize()) { javascript << FX_WSTRC(L", "); } - index++; } } } @@ -566,7 +589,7 @@ void CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC(L"\n(\nfunction ()\n{\ntry\n{\n"); if (m_pArguments && m_pArguments->GetSize() > 0) { CXFA_FMSimpleExpression* e = - (CXFA_FMSimpleExpression*)m_pArguments->GetAt(0); + reinterpret_cast<CXFA_FMSimpleExpression*>(m_pArguments->GetAt(0)); javascript << FX_WSTRC(L"return "); e->ToJavaScript(javascript); javascript << FX_WSTRC(L";\n}\n"); @@ -576,16 +599,13 @@ void CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC( L"catch(accessExceptions)\n{\nreturn 0;\n}\n}\n).call(this)\n"); } else if (m_pArguments) { - int32_t argc = m_pArguments->GetSize(); - int32_t index = 0; - CXFA_FMSimpleExpression* e = 0; - while (index < argc) { - e = (CXFA_FMSimpleExpression*)m_pArguments->GetAt(index); + for (int i = 0; i < m_pArguments->GetSize(); ++i) { + CXFA_FMSimpleExpression* e = + reinterpret_cast<CXFA_FMSimpleExpression*>(m_pArguments->GetAt(i)); e->ToJavaScript(javascript); - if (index + 1 < argc) { + if (i + 1 < m_pArguments->GetSize()) { javascript << FX_WSTRC(L", "); } - index++; } } javascript << FX_WSTRC(L")"); @@ -594,6 +614,7 @@ void CXFA_FMCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) { } } } + CXFA_FMDotAccessorExpression::CXFA_FMDotAccessorExpression( FX_DWORD line, CXFA_FMSimpleExpression* pAccessor, @@ -602,6 +623,7 @@ CXFA_FMDotAccessorExpression::CXFA_FMDotAccessorExpression( CXFA_FMSimpleExpression* pIndexExp) : CXFA_FMBinExpression(line, op, pAccessor, pIndexExp), m_wsIdentifier(wsIdentifier) {} + void CXFA_FMDotAccessorExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << gs_lpStrExpFuncName[DOT]; javascript << FX_WSTRC(L"("); @@ -632,6 +654,7 @@ void CXFA_FMDotAccessorExpression::ToJavaScript(CFX_WideTextBuf& javascript) { m_pExp2->ToJavaScript(javascript); javascript << FX_WSTRC(L")"); } + CXFA_FMIndexExpression::CXFA_FMIndexExpression( FX_DWORD line, XFA_FM_AccessorIndex accessorIndex, @@ -640,6 +663,7 @@ CXFA_FMIndexExpression::CXFA_FMIndexExpression( : CXFA_FMUnaryExpression(line, TOKlbracket, pIndexExp), m_accessorIndex(accessorIndex), m_bIsStarIndex(bIsStarIndex) {} + void CXFA_FMIndexExpression::ToJavaScript(CFX_WideTextBuf& javascript) { switch (m_accessorIndex) { case ACCESSOR_NO_INDEX: @@ -666,6 +690,7 @@ void CXFA_FMIndexExpression::ToJavaScript(CFX_WideTextBuf& javascript) { } } } + CXFA_FMDotDotAccessorExpression::CXFA_FMDotDotAccessorExpression( FX_DWORD line, CXFA_FMSimpleExpression* pAccessor, @@ -674,6 +699,7 @@ CXFA_FMDotDotAccessorExpression::CXFA_FMDotDotAccessorExpression( CXFA_FMSimpleExpression* pIndexExp) : CXFA_FMBinExpression(line, op, pAccessor, pIndexExp), m_wsIdentifier(wsIdentifier) {} + void CXFA_FMDotDotAccessorExpression::ToJavaScript( CFX_WideTextBuf& javascript) { javascript << gs_lpStrExpFuncName[DOTDOT]; @@ -691,11 +717,13 @@ void CXFA_FMDotDotAccessorExpression::ToJavaScript( m_pExp2->ToJavaScript(javascript); javascript << FX_WSTRC(L")"); } + CXFA_FMMethodCallExpression::CXFA_FMMethodCallExpression( FX_DWORD line, CXFA_FMSimpleExpression* pAccessorExp1, CXFA_FMSimpleExpression* pCallExp) : CXFA_FMBinExpression(line, TOKdot, pAccessorExp1, pCallExp) {} + void CXFA_FMMethodCallExpression::ToJavaScript(CFX_WideTextBuf& javascript) { javascript << FX_WSTRC(L"(\nfunction ()\n{\n"); javascript << FX_WSTRC(L"var method_return_value = null;\n"); diff --git a/xfa/src/fxfa/src/fm2js/xfa_simpleexpression.h b/xfa/src/fxfa/src/fm2js/xfa_simpleexpression.h index bc84ab784d..df27a630b8 100644 --- a/xfa/src/fxfa/src/fm2js/xfa_simpleexpression.h +++ b/xfa/src/fxfa/src/fm2js/xfa_simpleexpression.h @@ -7,6 +7,8 @@ #ifndef XFA_SRC_FXFA_SRC_FM2JS_XFA_SIMPLEEXPRESSION_H_ #define XFA_SRC_FXFA_SRC_FM2JS_XFA_SIMPLEEXPRESSION_H_ +#include <memory> + #include "core/include/fxcrt/fx_basic.h" #include "xfa/src/fxfa/src/fm2js/xfa_lexer.h" @@ -109,11 +111,10 @@ class CXFA_FMUnaryExpression : public CXFA_FMSimpleExpression { CXFA_FMUnaryExpression(FX_DWORD line, XFA_FM_TOKEN op, CXFA_FMSimpleExpression* pExp); - ~CXFA_FMUnaryExpression() override; void ToJavaScript(CFX_WideTextBuf& javascript) override; protected: - CXFA_FMSimpleExpression* m_pExp; + std::unique_ptr<CXFA_FMSimpleExpression> m_pExp; }; class CXFA_FMBinExpression : public CXFA_FMSimpleExpression { @@ -122,12 +123,11 @@ class CXFA_FMBinExpression : public CXFA_FMSimpleExpression { XFA_FM_TOKEN op, CXFA_FMSimpleExpression* pExp1, CXFA_FMSimpleExpression* pExp2); - ~CXFA_FMBinExpression() override; void ToJavaScript(CFX_WideTextBuf& javascript) override; protected: - CXFA_FMSimpleExpression* m_pExp1; - CXFA_FMSimpleExpression* m_pExp2; + std::unique_ptr<CXFA_FMSimpleExpression> m_pExp1; + std::unique_ptr<CXFA_FMSimpleExpression> m_pExp2; }; class CXFA_FMAssignExpression : public CXFA_FMBinExpression { |