summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page/cpdf_psengine.h
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-11-06 20:01:13 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-06 20:01:13 +0000
commit898690313426bf1604e0bb6def684db84a782494 (patch)
treedcb07d1dfca1475bb4e1c39992fc3f88e70d91ba /core/fpdfapi/page/cpdf_psengine.h
parentd7a3f981fdc6bf9aef306854505638db7b4b51c7 (diff)
downloadpdfium-898690313426bf1604e0bb6def684db84a782494.tar.xz
Add a CPDF_PSEngine test.
Change-Id: Ia267f40dc4ebe9e1d28b6a333eddcff749414ffa Reviewed-on: https://pdfium-review.googlesource.com/17870 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi/page/cpdf_psengine.h')
-rw-r--r--core/fpdfapi/page/cpdf_psengine.h30
1 files changed, 29 insertions, 1 deletions
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 <memory>
#include <vector>
+#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<CPDF_PSProc> 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<CPDF_PSOP>& last_operator() {
+ return m_Operators.back();
+ }
+
private:
static const int kMaxDepth = 128;
+
+ void AddOperator(const ByteStringView& word);
+
std::vector<std::unique_ptr<CPDF_PSOP>> m_Operators;
};