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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 static void Dispose(v8::Isolate* isolate, | 74 static void Dispose(v8::Isolate* isolate, |
75 v8::Global<v8::Object> value, | 75 v8::Global<v8::Object> value, |
76 void* key); | 76 void* key); |
77 static void DisposeCallbackData(WeakCallbackDataType* callbackData) {} | 77 static void DisposeCallbackData(WeakCallbackDataType* callbackData) {} |
78 }; | 78 }; |
79 | 79 |
80 class V8TemplateMap { | 80 class V8TemplateMap { |
81 public: | 81 public: |
82 typedef v8::GlobalValueMap<void*, v8::Object, V8TemplateMapTraits> MapType; | 82 typedef v8::GlobalValueMap<void*, v8::Object, V8TemplateMapTraits> MapType; |
83 | 83 |
84 void set(void* key, v8::Local<v8::Object> handle) { | 84 explicit V8TemplateMap(v8::Isolate* isolate); |
85 ASSERT(!m_map.Contains(key)); | 85 ~V8TemplateMap(); |
86 m_map.Set(key, handle); | 86 |
87 } | 87 void set(void* key, v8::Local<v8::Object> handle); |
88 explicit V8TemplateMap(v8::Isolate* isolate) : m_map(isolate) {} | 88 |
89 friend class V8TemplateMapTraits; | 89 friend class V8TemplateMapTraits; |
90 | 90 |
91 private: | 91 private: |
92 MapType m_map; | 92 MapType m_map; |
93 }; | 93 }; |
94 | 94 |
95 class FXJS_PerIsolateData { | 95 class FXJS_PerIsolateData { |
96 public: | 96 public: |
| 97 ~FXJS_PerIsolateData(); |
| 98 |
97 static void SetUp(v8::Isolate* pIsolate); | 99 static void SetUp(v8::Isolate* pIsolate); |
98 static FXJS_PerIsolateData* Get(v8::Isolate* pIsolate); | 100 static FXJS_PerIsolateData* Get(v8::Isolate* pIsolate); |
| 101 |
99 void CreateDynamicObjsMap(v8::Isolate* pIsolate) { | 102 void CreateDynamicObjsMap(v8::Isolate* pIsolate) { |
100 if (!m_pDynamicObjsMap) | 103 if (!m_pDynamicObjsMap) |
101 m_pDynamicObjsMap = new V8TemplateMap(pIsolate); | 104 m_pDynamicObjsMap = new V8TemplateMap(pIsolate); |
102 } | 105 } |
103 void ReleaseDynamicObjsMap() { | 106 void ReleaseDynamicObjsMap() { |
104 delete m_pDynamicObjsMap; | 107 delete m_pDynamicObjsMap; |
105 m_pDynamicObjsMap = nullptr; | 108 m_pDynamicObjsMap = nullptr; |
106 } | 109 } |
107 | 110 |
108 std::vector<CFXJS_ObjDefinition*> m_ObjectDefnArray; | 111 std::vector<CFXJS_ObjDefinition*> m_ObjectDefnArray; |
109 #ifdef PDF_ENABLE_XFA | 112 #ifdef PDF_ENABLE_XFA |
110 CFXJSE_RuntimeData* m_pFXJSERuntimeData; | 113 CFXJSE_RuntimeData* m_pFXJSERuntimeData; |
111 #endif // PDF_ENABLE_XFA | 114 #endif // PDF_ENABLE_XFA |
112 V8TemplateMap* m_pDynamicObjsMap; | 115 V8TemplateMap* m_pDynamicObjsMap; |
113 | 116 |
114 protected: | 117 protected: |
115 #ifndef PDF_ENABLE_XFA | 118 FXJS_PerIsolateData(); |
116 FXJS_PerIsolateData() : m_pDynamicObjsMap(nullptr) {} | |
117 #else // PDF_ENABLE_XFA | |
118 FXJS_PerIsolateData() | |
119 : m_pFXJSERuntimeData(nullptr), m_pDynamicObjsMap(nullptr) {} | |
120 #endif // PDF_ENABLE_XFA | |
121 }; | 119 }; |
122 | 120 |
123 extern const wchar_t kFXJSValueNameString[]; | 121 extern const wchar_t kFXJSValueNameString[]; |
124 extern const wchar_t kFXJSValueNameNumber[]; | 122 extern const wchar_t kFXJSValueNameNumber[]; |
125 extern const wchar_t kFXJSValueNameBoolean[]; | 123 extern const wchar_t kFXJSValueNameBoolean[]; |
126 extern const wchar_t kFXJSValueNameDate[]; | 124 extern const wchar_t kFXJSValueNameDate[]; |
127 extern const wchar_t kFXJSValueNameObject[]; | 125 extern const wchar_t kFXJSValueNameObject[]; |
128 extern const wchar_t kFXJSValueNameFxobj[]; | 126 extern const wchar_t kFXJSValueNameFxobj[]; |
129 extern const wchar_t kFXJSValueNameNull[]; | 127 extern const wchar_t kFXJSValueNameNull[]; |
130 extern const wchar_t kFXJSValueNameUndefined[]; | 128 extern const wchar_t kFXJSValueNameUndefined[]; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 double FXJS_ToNumber(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue); | 281 double FXJS_ToNumber(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue); |
284 v8::Local<v8::Object> FXJS_ToObject(v8::Isolate* pIsolate, | 282 v8::Local<v8::Object> FXJS_ToObject(v8::Isolate* pIsolate, |
285 v8::Local<v8::Value> pValue); | 283 v8::Local<v8::Value> pValue); |
286 CFX_WideString FXJS_ToString(v8::Isolate* pIsolate, | 284 CFX_WideString FXJS_ToString(v8::Isolate* pIsolate, |
287 v8::Local<v8::Value> pValue); | 285 v8::Local<v8::Value> pValue); |
288 v8::Local<v8::Array> FXJS_ToArray(v8::Isolate* pIsolate, | 286 v8::Local<v8::Array> FXJS_ToArray(v8::Isolate* pIsolate, |
289 v8::Local<v8::Value> pValue); | 287 v8::Local<v8::Value> pValue); |
290 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom); | 288 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom); |
291 | 289 |
292 #endif // FPDFSDK_JSAPI_INCLUDE_FXJS_V8_H_ | 290 #endif // FPDFSDK_JSAPI_INCLUDE_FXJS_V8_H_ |
OLD | NEW |