OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef CORE_FPDFAPI_FPDF_PAGE_CPDF_PSENGINE_H_ | 7 #ifndef CORE_FPDFAPI_FPDF_PAGE_CPDF_PSENGINE_H_ |
8 #define CORE_FPDFAPI_FPDF_PAGE_CPDF_PSENGINE_H_ | 8 #define CORE_FPDFAPI_FPDF_PAGE_CPDF_PSENGINE_H_ |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 PSOP_CONST | 63 PSOP_CONST |
64 }; | 64 }; |
65 | 65 |
66 constexpr uint32_t PSENGINE_STACKSIZE = 100; | 66 constexpr uint32_t PSENGINE_STACKSIZE = 100; |
67 | 67 |
68 class CPDF_PSProc { | 68 class CPDF_PSProc { |
69 public: | 69 public: |
70 CPDF_PSProc(); | 70 CPDF_PSProc(); |
71 ~CPDF_PSProc(); | 71 ~CPDF_PSProc(); |
72 | 72 |
73 FX_BOOL Parse(CPDF_SimpleParser* parser); | 73 FX_BOOL Parse(CPDF_SimpleParser* parser, int depth); |
74 FX_BOOL Execute(CPDF_PSEngine* pEngine); | 74 FX_BOOL Execute(CPDF_PSEngine* pEngine); |
75 | 75 |
76 private: | 76 private: |
| 77 static const int kMaxDepth = 128; |
77 std::vector<std::unique_ptr<CPDF_PSOP>> m_Operators; | 78 std::vector<std::unique_ptr<CPDF_PSOP>> m_Operators; |
78 }; | 79 }; |
79 | 80 |
80 class CPDF_PSEngine { | 81 class CPDF_PSEngine { |
81 public: | 82 public: |
82 CPDF_PSEngine(); | 83 CPDF_PSEngine(); |
83 ~CPDF_PSEngine(); | 84 ~CPDF_PSEngine(); |
84 | 85 |
85 FX_BOOL Parse(const FX_CHAR* str, int size); | 86 FX_BOOL Parse(const FX_CHAR* str, int size); |
86 FX_BOOL Execute(); | 87 FX_BOOL Execute(); |
87 FX_BOOL DoOperator(PDF_PSOP op); | 88 FX_BOOL DoOperator(PDF_PSOP op); |
88 void Reset() { m_StackCount = 0; } | 89 void Reset() { m_StackCount = 0; } |
89 void Push(FX_FLOAT value); | 90 void Push(FX_FLOAT value); |
90 void Push(int value) { Push((FX_FLOAT)value); } | 91 void Push(int value) { Push((FX_FLOAT)value); } |
91 FX_FLOAT Pop(); | 92 FX_FLOAT Pop(); |
92 uint32_t GetStackSize() const { return m_StackCount; } | 93 uint32_t GetStackSize() const { return m_StackCount; } |
93 | 94 |
94 private: | 95 private: |
95 FX_FLOAT m_Stack[PSENGINE_STACKSIZE]; | 96 FX_FLOAT m_Stack[PSENGINE_STACKSIZE]; |
96 uint32_t m_StackCount; | 97 uint32_t m_StackCount; |
97 CPDF_PSProc m_MainProc; | 98 CPDF_PSProc m_MainProc; |
98 }; | 99 }; |
99 | 100 |
100 #endif // CORE_FPDFAPI_FPDF_PAGE_CPDF_PSENGINE_H_ | 101 #endif // CORE_FPDFAPI_FPDF_PAGE_CPDF_PSENGINE_H_ |
OLD | NEW |