OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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 // FXJS_V8 is a layer that makes it easier to define native objects in V8, but | 7 // FXJS_V8 is a layer that makes it easier to define native objects in V8, but |
8 // has no knowledge of PDF-specific native objects. It could in theory be used | 8 // has no knowledge of PDF-specific native objects. It could in theory be used |
9 // to implement other sets of native objects. | 9 // to implement other sets of native objects. |
10 | 10 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 MapType m_map; | 93 MapType m_map; |
94 }; | 94 }; |
95 | 95 |
96 class FXJS_PerIsolateData { | 96 class FXJS_PerIsolateData { |
97 public: | 97 public: |
98 ~FXJS_PerIsolateData(); | 98 ~FXJS_PerIsolateData(); |
99 | 99 |
100 static void SetUp(v8::Isolate* pIsolate); | 100 static void SetUp(v8::Isolate* pIsolate); |
101 static FXJS_PerIsolateData* Get(v8::Isolate* pIsolate); | 101 static FXJS_PerIsolateData* Get(v8::Isolate* pIsolate); |
102 | 102 |
103 void CreateDynamicObjsMap(v8::Isolate* pIsolate) { | 103 std::vector<std::unique_ptr<CFXJS_ObjDefinition>> m_ObjectDefnArray; |
104 if (!m_pDynamicObjsMap) | |
105 m_pDynamicObjsMap = new V8TemplateMap(pIsolate); | |
106 } | |
107 void ReleaseDynamicObjsMap() { | |
108 delete m_pDynamicObjsMap; | |
109 m_pDynamicObjsMap = nullptr; | |
110 } | |
111 | |
112 std::vector<CFXJS_ObjDefinition*> m_ObjectDefnArray; | |
113 #ifdef PDF_ENABLE_XFA | 104 #ifdef PDF_ENABLE_XFA |
114 std::unique_ptr<CFXJSE_RuntimeData> m_pFXJSERuntimeData; | 105 std::unique_ptr<CFXJSE_RuntimeData> m_pFXJSERuntimeData; |
115 #endif // PDF_ENABLE_XFA | 106 #endif // PDF_ENABLE_XFA |
116 V8TemplateMap* m_pDynamicObjsMap; | 107 std::unique_ptr<V8TemplateMap> m_pDynamicObjsMap; |
117 | 108 |
118 protected: | 109 protected: |
119 FXJS_PerIsolateData(); | 110 explicit FXJS_PerIsolateData(v8::Isolate* pIsolate); |
120 }; | 111 }; |
121 | 112 |
122 class FXJS_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { | 113 class FXJS_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { |
123 void* Allocate(size_t length) override; | 114 void* Allocate(size_t length) override; |
124 void* AllocateUninitialized(size_t length) override; | 115 void* AllocateUninitialized(size_t length) override; |
125 void Free(void* data, size_t length) override; | 116 void Free(void* data, size_t length) override; |
126 }; | 117 }; |
127 | 118 |
128 void FXJS_Initialize(unsigned int embedderDataSlot, v8::Isolate* pIsolate); | 119 void FXJS_Initialize(unsigned int embedderDataSlot, v8::Isolate* pIsolate); |
129 void FXJS_Release(); | 120 void FXJS_Release(); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 void SetIsolate(v8::Isolate* pIsolate) { m_isolate = pIsolate; } | 253 void SetIsolate(v8::Isolate* pIsolate) { m_isolate = pIsolate; } |
263 | 254 |
264 private: | 255 private: |
265 v8::Isolate* m_isolate; | 256 v8::Isolate* m_isolate; |
266 v8::Global<v8::Context> m_V8PersistentContext; | 257 v8::Global<v8::Context> m_V8PersistentContext; |
267 std::vector<v8::Global<v8::Object>*> m_StaticObjects; | 258 std::vector<v8::Global<v8::Object>*> m_StaticObjects; |
268 std::map<CFX_WideString, v8::Global<v8::Array>> m_ConstArrays; | 259 std::map<CFX_WideString, v8::Global<v8::Array>> m_ConstArrays; |
269 }; | 260 }; |
270 | 261 |
271 #endif // FXJS_INCLUDE_FXJS_V8_H_ | 262 #endif // FXJS_INCLUDE_FXJS_V8_H_ |
OLD | NEW |