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 #ifndef FPDFSDK_INCLUDE_JAVASCRIPT_GLOBAL_H_ | 7 #ifndef FPDFSDK_INCLUDE_JAVASCRIPT_GLOBAL_H_ |
8 #define FPDFSDK_INCLUDE_JAVASCRIPT_GLOBAL_H_ | 8 #define FPDFSDK_INCLUDE_JAVASCRIPT_GLOBAL_H_ |
9 | 9 |
10 #include "JS_Define.h" | 10 #include "JS_Define.h" |
11 | 11 |
12 class CJS_GlobalData; | 12 class CJS_GlobalData; |
13 class CJS_GlobalVariableArray; | 13 class CJS_GlobalVariableArray; |
14 class CJS_KeyValue; | 14 class CJS_KeyValue; |
15 | 15 |
16 struct js_global_data | 16 struct js_global_data { |
17 { | 17 js_global_data() { |
18 » js_global_data() | 18 nType = 0; |
19 » { | 19 dData = 0; |
20 » » nType = 0; | 20 bData = FALSE; |
21 » » dData = 0; | 21 sData = ""; |
22 » » bData = FALSE; | 22 bPersistent = FALSE; |
23 » » sData = ""; | 23 bDeleted = FALSE; |
24 » » bPersistent = FALSE; | 24 } |
25 » » bDeleted = FALSE; | |
26 » } | |
27 | 25 |
28 » ~js_global_data() | 26 ~js_global_data() { pData.Reset(); } |
29 » { | 27 int nType; // 0:int 1:bool 2:string 3:obj |
30 » » pData.Reset(); | 28 double dData; |
31 » } | 29 bool bData; |
32 » int» » » » » nType; //0:int 1:bool 2:string 3
:obj | 30 CFX_ByteString sData; |
33 » double» » » » dData; | 31 v8::Global<v8::Object> pData; |
34 » bool» » » » bData; | 32 bool bPersistent; |
35 » CFX_ByteString» » sData; | 33 bool bDeleted; |
36 » v8::Global<v8::Object> pData; | |
37 » bool» » » » bPersistent; | |
38 » bool» » » » bDeleted; | |
39 }; | 34 }; |
40 | 35 |
41 class global_alternate : public CJS_EmbedObj | 36 class global_alternate : public CJS_EmbedObj { |
42 { | 37 public: |
43 public: | 38 global_alternate(CJS_Object* pJSObject); |
44 » global_alternate(CJS_Object* pJSObject); | 39 virtual ~global_alternate(); |
45 » virtual ~global_alternate(); | |
46 | 40 |
47 public: | 41 public: |
48 » FX_BOOL»» » » » » setPersistent(IFXJS_Cont
ext* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); | 42 FX_BOOL setPersistent(IFXJS_Context* cc, |
| 43 const CJS_Parameters& params, |
| 44 CJS_Value& vRet, |
| 45 CFX_WideString& sError); |
49 | 46 |
50 public: | 47 public: |
51 » FX_BOOL»» » » » » QueryProperty(const FX_W
CHAR* propname); | 48 FX_BOOL QueryProperty(const FX_WCHAR* propname); |
52 » FX_BOOL»» » » » » DoProperty(IFXJS_Context
* cc, const FX_WCHAR* propname, CJS_PropValue & vp, CFX_WideString & sError); | 49 FX_BOOL DoProperty(IFXJS_Context* cc, |
53 » FX_BOOL»» » » » » DelProperty(IFXJS_Contex
t* cc, const FX_WCHAR* propname, CFX_WideString & sError); | 50 const FX_WCHAR* propname, |
| 51 CJS_PropValue& vp, |
| 52 CFX_WideString& sError); |
| 53 FX_BOOL DelProperty(IFXJS_Context* cc, |
| 54 const FX_WCHAR* propname, |
| 55 CFX_WideString& sError); |
54 | 56 |
55 » void» » » » » » Initial(CPDFDoc_Environm
ent* pApp); | 57 void Initial(CPDFDoc_Environment* pApp); |
56 | 58 |
57 private: | 59 private: |
58 » void» » » » » » UpdateGlobalPersistentVa
riables(); | 60 void UpdateGlobalPersistentVariables(); |
59 » void» » » » » » CommitGlobalPersisitentV
ariables(); | 61 void CommitGlobalPersisitentVariables(); |
60 » void» » » » » » DestroyGlobalPersisitent
Variables(); | 62 void DestroyGlobalPersisitentVariables(); |
61 » FX_BOOL»» » » » » SetGlobalVariables(const
FX_CHAR* propname, int nType, | 63 FX_BOOL SetGlobalVariables(const FX_CHAR* propname, |
62 » » » » » » » » » double d
Data, bool bData, const CFX_ByteString& sData, JSObject pData, bool bDefaultPers
istent); | 64 int nType, |
| 65 double dData, |
| 66 bool bData, |
| 67 const CFX_ByteString& sData, |
| 68 JSObject pData, |
| 69 bool bDefaultPersistent); |
63 | 70 |
64 » void» » » » » » ObjectToArray(v8::Local<
v8::Object> pObj, CJS_GlobalVariableArray& array); | 71 void ObjectToArray(v8::Local<v8::Object> pObj, |
65 » void» » » » » » PutObjectProperty(v8::Lo
cal<v8::Object> obj, CJS_KeyValue* pData); | 72 CJS_GlobalVariableArray& array); |
| 73 void PutObjectProperty(v8::Local<v8::Object> obj, CJS_KeyValue* pData); |
66 | 74 |
67 private: | 75 private: |
68 » CFX_MapByteStringToPtr» » m_mapGlobal; | 76 CFX_MapByteStringToPtr m_mapGlobal; |
69 » CFX_WideString» » » » m_sFilePath; | 77 CFX_WideString m_sFilePath; |
70 » CJS_GlobalData*»» » » m_pGlobalData; | 78 CJS_GlobalData* m_pGlobalData; |
71 » CPDFDoc_Environment*» » » » m_pApp; | 79 CPDFDoc_Environment* m_pApp; |
72 }; | 80 }; |
73 | 81 |
| 82 class CJS_Global : public CJS_Object { |
| 83 public: |
| 84 CJS_Global(JSFXObject pObject) : CJS_Object(pObject){}; |
| 85 virtual ~CJS_Global(void){}; |
74 | 86 |
75 class CJS_Global : public CJS_Object | 87 virtual FX_BOOL InitInstance(IFXJS_Context* cc); |
76 { | |
77 public: | |
78 » CJS_Global(JSFXObject pObject) : CJS_Object(pObject) {}; | |
79 » virtual ~CJS_Global(void){}; | |
80 | 88 |
81 » virtual FX_BOOL»InitInstance(IFXJS_Context* cc); | 89 DECLARE_SPECIAL_JS_CLASS(CJS_Global); |
82 | 90 |
83 » DECLARE_SPECIAL_JS_CLASS(CJS_Global); | 91 JS_SPECIAL_STATIC_METHOD(setPersistent, global_alternate, global); |
84 | |
85 » JS_SPECIAL_STATIC_METHOD(setPersistent, global_alternate, global); | |
86 | |
87 }; | 92 }; |
88 | 93 |
89 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_GLOBAL_H_ | 94 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_GLOBAL_H_ |
OLD | NEW |