From 898690313426bf1604e0bb6def684db84a782494 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 6 Nov 2017 20:01:13 +0000 Subject: Add a CPDF_PSEngine test. Change-Id: Ia267f40dc4ebe9e1d28b6a333eddcff749414ffa Reviewed-on: https://pdfium-review.googlesource.com/17870 Reviewed-by: dsinclair Commit-Queue: Lei Zhang --- core/fpdfapi/page/cpdf_psengine.h | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'core/fpdfapi/page/cpdf_psengine.h') diff --git a/core/fpdfapi/page/cpdf_psengine.h b/core/fpdfapi/page/cpdf_psengine.h index 0d5eadd78e..63d91d0757 100644 --- a/core/fpdfapi/page/cpdf_psengine.h +++ b/core/fpdfapi/page/cpdf_psengine.h @@ -10,10 +10,11 @@ #include #include +#include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" class CPDF_PSEngine; -class CPDF_PSOP; +class CPDF_PSProc; class CPDF_SimpleParser; enum PDF_PSOP : uint8_t { @@ -63,6 +64,23 @@ enum PDF_PSOP : uint8_t { PSOP_CONST }; +class CPDF_PSOP { + public: + CPDF_PSOP(); + explicit CPDF_PSOP(PDF_PSOP op); + explicit CPDF_PSOP(float value); + ~CPDF_PSOP(); + + float GetFloatValue() const; + CPDF_PSProc* GetProc() const; + PDF_PSOP GetOp() const { return m_op; } + + private: + const PDF_PSOP m_op; + const float m_value; + std::unique_ptr m_proc; +}; + class CPDF_PSProc { public: CPDF_PSProc(); @@ -71,8 +89,18 @@ class CPDF_PSProc { bool Parse(CPDF_SimpleParser* parser, int depth); bool Execute(CPDF_PSEngine* pEngine); + // These methods are exposed for testing. + void AddOperatorForTesting(const ByteStringView& word); + size_t num_operators() const { return m_Operators.size(); } + const std::unique_ptr& last_operator() { + return m_Operators.back(); + } + private: static const int kMaxDepth = 128; + + void AddOperator(const ByteStringView& word); + std::vector> m_Operators; }; -- cgit v1.2.3