diff options
author | dan sinclair <dsinclair@chromium.org> | 2018-02-19 18:18:38 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-02-19 18:18:38 +0000 |
commit | 00961a731b4811f84b5610d0b752f2f2b610f8ff (patch) | |
tree | 3eeba992b11a7ecbfb89fc7009acba4da2d42f14 | |
parent | d276a52cd5061e0d4ee4aa79b8e89bbeb0a89da3 (diff) | |
download | pdfium-00961a731b4811f84b5610d0b752f2f2b610f8ff.tar.xz |
Remove base class ToJavaScript methods in FormCalc
This CL removes the Loop base class as it adds no functionality. Other
base classes have had their ToJavaScript methods set as pure virtual and
their constructors made protected.
Change-Id: I5c77b8734d23c576dd52db7f72396ecdf2f7bd22
Reviewed-on: https://pdfium-review.googlesource.com/27270
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r-- | xfa/fxfa/fm2js/cxfa_fmexpression.cpp | 18 | ||||
-rw-r--r-- | xfa/fxfa/fm2js/cxfa_fmexpression.h | 22 | ||||
-rw-r--r-- | xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp | 20 | ||||
-rw-r--r-- | xfa/fxfa/fm2js/cxfa_fmsimpleexpression.h | 20 | ||||
-rw-r--r-- | xfa/fxfa/fm2js/cxfa_fmsimpleexpression_unittest.cpp | 6 |
5 files changed, 25 insertions, 61 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fmexpression.cpp b/xfa/fxfa/fm2js/cxfa_fmexpression.cpp index 97652bcd37..ae6cdb44d0 100644 --- a/xfa/fxfa/fm2js/cxfa_fmexpression.cpp +++ b/xfa/fxfa/fm2js/cxfa_fmexpression.cpp @@ -27,11 +27,6 @@ CXFA_FMExpression::CXFA_FMExpression(uint32_t line) CXFA_FMExpression::CXFA_FMExpression(uint32_t line, XFA_FM_EXPTYPE type) : m_type(type), m_line(line) {} -bool CXFA_FMExpression::ToJavaScript(CFX_WideTextBuf& js, ReturnType type) { - CXFA_FMToJavaScriptDepth depthManager; - return !CXFA_IsTooBig(js) && depthManager.IsWithinMaxDepth(); -} - CXFA_FMFunctionDefinition::CXFA_FMFunctionDefinition( uint32_t line, bool isGlobal, @@ -291,18 +286,11 @@ bool CXFA_FMIfExpression::ToJavaScript(CFX_WideTextBuf& js, ReturnType type) { return !CXFA_IsTooBig(js); } -CXFA_FMLoopExpression::~CXFA_FMLoopExpression() {} - -bool CXFA_FMLoopExpression::ToJavaScript(CFX_WideTextBuf& js, ReturnType type) { - CXFA_FMToJavaScriptDepth depthManager; - return !CXFA_IsTooBig(js) && depthManager.IsWithinMaxDepth(); -} - CXFA_FMWhileExpression::CXFA_FMWhileExpression( uint32_t line, std::unique_ptr<CXFA_FMSimpleExpression> pCondition, std::unique_ptr<CXFA_FMExpression> pExpression) - : CXFA_FMLoopExpression(line), + : CXFA_FMExpression(line), m_pCondition(std::move(pCondition)), m_pExpression(std::move(pExpression)) {} @@ -369,7 +357,7 @@ CXFA_FMForExpression::CXFA_FMForExpression( int32_t iDirection, std::unique_ptr<CXFA_FMSimpleExpression> pStep, std::unique_ptr<CXFA_FMExpression> pList) - : CXFA_FMLoopExpression(line), + : CXFA_FMExpression(line), m_wsVariant(wsVariant), m_pAssignment(std::move(pAssignment)), m_pAccessor(std::move(pAccessor)), @@ -434,7 +422,7 @@ CXFA_FMForeachExpression::CXFA_FMForeachExpression( const WideStringView& wsIdentifier, std::vector<std::unique_ptr<CXFA_FMSimpleExpression>>&& pAccessors, std::unique_ptr<CXFA_FMExpression> pList) - : CXFA_FMLoopExpression(line), + : CXFA_FMExpression(line), m_wsIdentifier(wsIdentifier), m_pAccessors(std::move(pAccessors)), m_pList(std::move(pList)) {} diff --git a/xfa/fxfa/fm2js/cxfa_fmexpression.h b/xfa/fxfa/fm2js/cxfa_fmexpression.h index 104b8976a5..5140ed39ab 100644 --- a/xfa/fxfa/fm2js/cxfa_fmexpression.h +++ b/xfa/fxfa/fm2js/cxfa_fmexpression.h @@ -27,14 +27,16 @@ class CFX_WideTextBuf; class CXFA_FMExpression { public: - explicit CXFA_FMExpression(uint32_t line); - CXFA_FMExpression(uint32_t line, XFA_FM_EXPTYPE type); virtual ~CXFA_FMExpression() {} + virtual bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) = 0; - virtual bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type); uint32_t GetLine() { return m_line; } XFA_FM_EXPTYPE GetExpType() const { return m_type; } + protected: + explicit CXFA_FMExpression(uint32_t line); + CXFA_FMExpression(uint32_t line, XFA_FM_EXPTYPE type); + private: XFA_FM_EXPTYPE m_type; uint32_t m_line; @@ -126,15 +128,7 @@ class CXFA_FMIfExpression : public CXFA_FMExpression { std::unique_ptr<CXFA_FMExpression> m_pElseExpression; }; -class CXFA_FMLoopExpression : public CXFA_FMExpression { - public: - explicit CXFA_FMLoopExpression(uint32_t line) : CXFA_FMExpression(line) {} - ~CXFA_FMLoopExpression() override; - - bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override; -}; - -class CXFA_FMWhileExpression : public CXFA_FMLoopExpression { +class CXFA_FMWhileExpression : public CXFA_FMExpression { public: CXFA_FMWhileExpression(uint32_t line, std::unique_ptr<CXFA_FMSimpleExpression> pCodition, @@ -164,7 +158,7 @@ class CXFA_FMContinueExpression : public CXFA_FMExpression { bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override; }; -class CXFA_FMForExpression : public CXFA_FMLoopExpression { +class CXFA_FMForExpression : public CXFA_FMExpression { public: CXFA_FMForExpression(uint32_t line, const WideStringView& wsVariant, @@ -186,7 +180,7 @@ class CXFA_FMForExpression : public CXFA_FMLoopExpression { std::unique_ptr<CXFA_FMExpression> m_pList; }; -class CXFA_FMForeachExpression : public CXFA_FMLoopExpression { +class CXFA_FMForeachExpression : public CXFA_FMExpression { public: // Takes ownership of |pAccessors|. CXFA_FMForeachExpression( diff --git a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp index 8354072b4d..ec61511284 100644 --- a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp +++ b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp @@ -74,11 +74,6 @@ const XFA_FMSOMMethod gs_FMSomMethods[] = { CXFA_FMSimpleExpression::CXFA_FMSimpleExpression(uint32_t line, XFA_FM_TOKEN op) : m_line(line), m_op(op) {} -bool CXFA_FMSimpleExpression::ToJavaScript(CFX_WideTextBuf& js, - ReturnType type) { - CXFA_FMToJavaScriptDepth depthManager; - return !CXFA_IsTooBig(js) && depthManager.IsWithinMaxDepth(); -} XFA_FM_TOKEN CXFA_FMSimpleExpression::GetOperatorToken() const { return m_op; } @@ -195,13 +190,7 @@ CXFA_FMUnaryExpression::CXFA_FMUnaryExpression( std::unique_ptr<CXFA_FMSimpleExpression> pExp) : CXFA_FMSimpleExpression(line, op), m_pExp(std::move(pExp)) {} -CXFA_FMUnaryExpression::~CXFA_FMUnaryExpression() {} - -bool CXFA_FMUnaryExpression::ToJavaScript(CFX_WideTextBuf& js, - ReturnType type) { - CXFA_FMToJavaScriptDepth depthManager; - return !CXFA_IsTooBig(js) && depthManager.IsWithinMaxDepth(); -} +CXFA_FMUnaryExpression::~CXFA_FMUnaryExpression() = default; CXFA_FMBinExpression::CXFA_FMBinExpression( uint32_t line, @@ -212,12 +201,7 @@ CXFA_FMBinExpression::CXFA_FMBinExpression( m_pExp1(std::move(pExp1)), m_pExp2(std::move(pExp2)) {} -CXFA_FMBinExpression::~CXFA_FMBinExpression() {} - -bool CXFA_FMBinExpression::ToJavaScript(CFX_WideTextBuf& js, ReturnType type) { - CXFA_FMToJavaScriptDepth depthManager; - return !CXFA_IsTooBig(js) && depthManager.IsWithinMaxDepth(); -} +CXFA_FMBinExpression::~CXFA_FMBinExpression() = default; CXFA_FMAssignExpression::CXFA_FMAssignExpression( uint32_t line, diff --git a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.h b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.h index 57f4d2ed11..bc41c74d70 100644 --- a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.h +++ b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.h @@ -25,14 +25,14 @@ class CFX_WideTextBuf; class CXFA_FMSimpleExpression { public: - CXFA_FMSimpleExpression(uint32_t line, XFA_FM_TOKEN op); virtual ~CXFA_FMSimpleExpression() {} - - virtual bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type); + virtual bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) = 0; XFA_FM_TOKEN GetOperatorToken() const; protected: + CXFA_FMSimpleExpression(uint32_t line, XFA_FM_TOKEN op); + uint32_t m_line; const XFA_FM_TOKEN m_op; }; @@ -80,28 +80,26 @@ class CXFA_FMIdentifierExpression : public CXFA_FMSimpleExpression { class CXFA_FMUnaryExpression : public CXFA_FMSimpleExpression { public: + ~CXFA_FMUnaryExpression() override; + + protected: CXFA_FMUnaryExpression(uint32_t line, XFA_FM_TOKEN op, std::unique_ptr<CXFA_FMSimpleExpression> pExp); - ~CXFA_FMUnaryExpression() override; - - bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override; - protected: std::unique_ptr<CXFA_FMSimpleExpression> m_pExp; }; class CXFA_FMBinExpression : public CXFA_FMSimpleExpression { public: + ~CXFA_FMBinExpression() override; + + protected: CXFA_FMBinExpression(uint32_t line, XFA_FM_TOKEN op, std::unique_ptr<CXFA_FMSimpleExpression> pExp1, std::unique_ptr<CXFA_FMSimpleExpression> pExp2); - ~CXFA_FMBinExpression() override; - - bool ToJavaScript(CFX_WideTextBuf& javascript, ReturnType type) override; - protected: std::unique_ptr<CXFA_FMSimpleExpression> m_pExp1; std::unique_ptr<CXFA_FMSimpleExpression> m_pExp2; }; diff --git a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression_unittest.cpp b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression_unittest.cpp index e97df41ad7..168de84db4 100644 --- a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression_unittest.cpp +++ b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression_unittest.cpp @@ -21,7 +21,7 @@ TEST(FMCallExpressionTest, more_than_32_arguments) { std::vector<std::unique_ptr<CXFA_FMSimpleExpression>> args; for (size_t i = 0; i < 50; i++) - args.push_back(pdfium::MakeUnique<CXFA_FMSimpleExpression>(0, TOKnan)); + args.push_back(pdfium::MakeUnique<CXFA_FMNullExpression>(0)); CXFA_FMToJavaScriptDepth::Reset(); CXFA_FMCallExpression callExp(0, std::move(exp), std::move(args), true); @@ -37,9 +37,9 @@ TEST(FMCallExpressionTest, more_than_32_arguments) { result += L"pfm_rt.get_"; // Object positions for sign() method. if (i == 0 || i == 5 || i == 6) - result += L"jsobj()"; + result += L"jsobj(null)"; else - result += L"val()"; + result += L"val(null)"; } result += L")"; |