Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(458)

Side by Side Diff: fpdfsdk/javascript/JS_GlobalData.cpp

Issue 2154843002: Clean up singleton implementation (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/javascript/JS_GlobalData.h ('k') | fpdfsdk/javascript/JS_KeyValue.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "fpdfsdk/javascript/JS_GlobalData.h" 7 #include "fpdfsdk/javascript/JS_GlobalData.h"
8 8
9 #include "core/fdrm/crypto/include/fx_crypt.h" 9 #include "core/fdrm/crypto/include/fx_crypt.h"
10 #include "third_party/base/stl_util.h" 10 #include "third_party/base/stl_util.h"
11 11
12 #define JS_MAXGLOBALDATA (1024 * 4 - 8) 12 #define JS_MAXGLOBALDATA (1024 * 4 - 8)
13 13
14 CJS_GlobalVariableArray::CJS_GlobalVariableArray() {}
15
16 CJS_GlobalVariableArray::~CJS_GlobalVariableArray() {
17 Empty();
18 }
19
20 void CJS_GlobalVariableArray::Copy(const CJS_GlobalVariableArray& array) {
21 Empty();
22 for (int i = 0, sz = array.Count(); i < sz; i++) {
23 CJS_KeyValue* pOldObjData = array.GetAt(i);
24 switch (pOldObjData->nType) {
25 case JS_GLOBALDATA_TYPE_NUMBER: {
26 CJS_KeyValue* pNewObjData = new CJS_KeyValue;
27 pNewObjData->sKey = pOldObjData->sKey;
28 pNewObjData->nType = pOldObjData->nType;
29 pNewObjData->dData = pOldObjData->dData;
30 Add(pNewObjData);
31 } break;
32 case JS_GLOBALDATA_TYPE_BOOLEAN: {
33 CJS_KeyValue* pNewObjData = new CJS_KeyValue;
34 pNewObjData->sKey = pOldObjData->sKey;
35 pNewObjData->nType = pOldObjData->nType;
36 pNewObjData->bData = pOldObjData->bData;
37 Add(pNewObjData);
38 } break;
39 case JS_GLOBALDATA_TYPE_STRING: {
40 CJS_KeyValue* pNewObjData = new CJS_KeyValue;
41 pNewObjData->sKey = pOldObjData->sKey;
42 pNewObjData->nType = pOldObjData->nType;
43 pNewObjData->sData = pOldObjData->sData;
44 Add(pNewObjData);
45 } break;
46 case JS_GLOBALDATA_TYPE_OBJECT: {
47 CJS_KeyValue* pNewObjData = new CJS_KeyValue;
48 pNewObjData->sKey = pOldObjData->sKey;
49 pNewObjData->nType = pOldObjData->nType;
50 pNewObjData->objData.Copy(pOldObjData->objData);
51 Add(pNewObjData);
52 } break;
53 case JS_GLOBALDATA_TYPE_NULL: {
54 CJS_KeyValue* pNewObjData = new CJS_KeyValue;
55 pNewObjData->sKey = pOldObjData->sKey;
56 pNewObjData->nType = pOldObjData->nType;
57 Add(pNewObjData);
58 } break;
59 }
60 }
61 }
62
63 void CJS_GlobalVariableArray::Add(CJS_KeyValue* p) {
64 m_Array.Add(p);
65 }
66
67 int CJS_GlobalVariableArray::Count() const {
68 return m_Array.GetSize();
69 }
70
71 CJS_KeyValue* CJS_GlobalVariableArray::GetAt(int index) const {
72 return m_Array.GetAt(index);
73 }
74
75 void CJS_GlobalVariableArray::Empty() {
76 for (int i = 0, sz = m_Array.GetSize(); i < sz; i++)
77 delete m_Array.GetAt(i);
78 m_Array.RemoveAll();
79 }
80
81 #define READER_JS_GLOBALDATA_FILENAME L"Reader_JsGlobal.Data" 14 #define READER_JS_GLOBALDATA_FILENAME L"Reader_JsGlobal.Data"
82 #define PHANTOM_JS_GLOBALDATA_FILENAME L"Phantom_JsGlobal.Data" 15 #define PHANTOM_JS_GLOBALDATA_FILENAME L"Phantom_JsGlobal.Data"
83 #define SDK_JS_GLOBALDATA_FILENAME L"SDK_JsGlobal.Data" 16 #define SDK_JS_GLOBALDATA_FILENAME L"SDK_JsGlobal.Data"
84 17
85 static const uint8_t JS_RC4KEY[] = { 18 namespace {
19
20 const uint8_t JS_RC4KEY[] = {
86 0x19, 0xa8, 0xe8, 0x01, 0xf6, 0xa8, 0xb6, 0x4d, 0x82, 0x04, 0x45, 0x6d, 21 0x19, 0xa8, 0xe8, 0x01, 0xf6, 0xa8, 0xb6, 0x4d, 0x82, 0x04, 0x45, 0x6d,
87 0xb4, 0xcf, 0xd7, 0x77, 0x67, 0xf9, 0x75, 0x9f, 0xf0, 0xe0, 0x1e, 0x51, 22 0xb4, 0xcf, 0xd7, 0x77, 0x67, 0xf9, 0x75, 0x9f, 0xf0, 0xe0, 0x1e, 0x51,
88 0xee, 0x46, 0xfd, 0x0b, 0xc9, 0x93, 0x25, 0x55, 0x4a, 0xee, 0xe0, 0x16, 23 0xee, 0x46, 0xfd, 0x0b, 0xc9, 0x93, 0x25, 0x55, 0x4a, 0xee, 0xe0, 0x16,
89 0xd0, 0xdf, 0x8c, 0xfa, 0x2a, 0xa9, 0x49, 0xfd, 0x97, 0x1c, 0x0e, 0x22, 24 0xd0, 0xdf, 0x8c, 0xfa, 0x2a, 0xa9, 0x49, 0xfd, 0x97, 0x1c, 0x0e, 0x22,
90 0x13, 0x28, 0x7c, 0xaf, 0xc4, 0xfc, 0x9c, 0x12, 0x65, 0x8c, 0x4e, 0x5b, 25 0x13, 0x28, 0x7c, 0xaf, 0xc4, 0xfc, 0x9c, 0x12, 0x65, 0x8c, 0x4e, 0x5b,
91 0x04, 0x75, 0x89, 0xc9, 0xb1, 0xed, 0x50, 0xca, 0x96, 0x6f, 0x1a, 0x7a, 26 0x04, 0x75, 0x89, 0xc9, 0xb1, 0xed, 0x50, 0xca, 0x96, 0x6f, 0x1a, 0x7a,
92 0xfe, 0x58, 0x5d, 0xec, 0x19, 0x4a, 0xf6, 0x35, 0x6a, 0x97, 0x14, 0x00, 27 0xfe, 0x58, 0x5d, 0xec, 0x19, 0x4a, 0xf6, 0x35, 0x6a, 0x97, 0x14, 0x00,
93 0x0e, 0xd0, 0x6b, 0xbb, 0xd5, 0x75, 0x55, 0x8b, 0x6e, 0x6b, 0x19, 0xa0, 28 0x0e, 0xd0, 0x6b, 0xbb, 0xd5, 0x75, 0x55, 0x8b, 0x6e, 0x6b, 0x19, 0xa0,
94 0xf8, 0x77, 0xd5, 0xa3}; 29 0xf8, 0x77, 0xd5, 0xa3};
95 30
96 // Returns true if non-empty, setting sPropName 31 // Returns true if non-empty, setting sPropName
97 static bool TrimPropName(CFX_ByteString* sPropName) { 32 bool TrimPropName(CFX_ByteString* sPropName) {
98 sPropName->TrimLeft(); 33 sPropName->TrimLeft();
99 sPropName->TrimRight(); 34 sPropName->TrimRight();
100 return sPropName->GetLength() != 0; 35 return sPropName->GetLength() != 0;
101 } 36 }
102 37
103 CJS_GlobalData* CJS_GlobalData::g_Instance = nullptr; 38 CJS_GlobalData* g_pInstance = nullptr;
39
40 } // namespace
104 41
105 // static 42 // static
106 CJS_GlobalData* CJS_GlobalData::GetRetainedInstance(CPDFDoc_Environment* pApp) { 43 CJS_GlobalData* CJS_GlobalData::GetRetainedInstance(CPDFDoc_Environment* pApp) {
107 if (!g_Instance) { 44 if (!g_pInstance) {
108 g_Instance = new CJS_GlobalData(); 45 g_pInstance = new CJS_GlobalData();
109 } 46 }
110 ++g_Instance->m_RefCount; 47 ++g_pInstance->m_RefCount;
111 return g_Instance; 48 return g_pInstance;
112 } 49 }
113 50
114 void CJS_GlobalData::Release() { 51 void CJS_GlobalData::Release() {
115 if (!--m_RefCount) { 52 if (!--m_RefCount) {
116 delete g_Instance; 53 delete g_pInstance;
117 g_Instance = nullptr; 54 g_pInstance = nullptr;
118 } 55 }
119 } 56 }
120 57
121 CJS_GlobalData::CJS_GlobalData() 58 CJS_GlobalData::CJS_GlobalData()
122 : m_RefCount(0), m_sFilePath(SDK_JS_GLOBALDATA_FILENAME) { 59 : m_RefCount(0), m_sFilePath(SDK_JS_GLOBALDATA_FILENAME) {
123 LoadGlobalPersistentVariables(); 60 LoadGlobalPersistentVariables();
124 } 61 }
125 62
126 CJS_GlobalData::~CJS_GlobalData() { 63 CJS_GlobalData::~CJS_GlobalData() {
127 SaveGlobalPersisitentVariables(); 64 SaveGlobalPersisitentVariables();
(...skipping 25 matching lines...) Expand all
153 return iter != m_arrayGlobalData.end() ? iter->get() : nullptr; 90 return iter != m_arrayGlobalData.end() ? iter->get() : nullptr;
154 } 91 }
155 92
156 void CJS_GlobalData::SetGlobalVariableNumber(const CFX_ByteString& propname, 93 void CJS_GlobalData::SetGlobalVariableNumber(const CFX_ByteString& propname,
157 double dData) { 94 double dData) {
158 CFX_ByteString sPropName(propname); 95 CFX_ByteString sPropName(propname);
159 if (!TrimPropName(&sPropName)) 96 if (!TrimPropName(&sPropName))
160 return; 97 return;
161 98
162 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) { 99 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) {
163 pData->data.nType = JS_GLOBALDATA_TYPE_NUMBER; 100 pData->data.nType = JS_GlobalDataType::NUMBER;
164 pData->data.dData = dData; 101 pData->data.dData = dData;
165 return; 102 return;
166 } 103 }
167 std::unique_ptr<CJS_GlobalData_Element> pNewData(new CJS_GlobalData_Element); 104 std::unique_ptr<CJS_GlobalData_Element> pNewData(new CJS_GlobalData_Element);
168 pNewData->data.sKey = sPropName; 105 pNewData->data.sKey = sPropName;
169 pNewData->data.nType = JS_GLOBALDATA_TYPE_NUMBER; 106 pNewData->data.nType = JS_GlobalDataType::NUMBER;
170 pNewData->data.dData = dData; 107 pNewData->data.dData = dData;
171 m_arrayGlobalData.push_back(std::move(pNewData)); 108 m_arrayGlobalData.push_back(std::move(pNewData));
172 } 109 }
173 110
174 void CJS_GlobalData::SetGlobalVariableBoolean(const CFX_ByteString& propname, 111 void CJS_GlobalData::SetGlobalVariableBoolean(const CFX_ByteString& propname,
175 bool bData) { 112 bool bData) {
176 CFX_ByteString sPropName(propname); 113 CFX_ByteString sPropName(propname);
177 if (!TrimPropName(&sPropName)) 114 if (!TrimPropName(&sPropName))
178 return; 115 return;
179 116
180 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) { 117 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) {
181 pData->data.nType = JS_GLOBALDATA_TYPE_BOOLEAN; 118 pData->data.nType = JS_GlobalDataType::BOOLEAN;
182 pData->data.bData = bData; 119 pData->data.bData = bData;
183 return; 120 return;
184 } 121 }
185 std::unique_ptr<CJS_GlobalData_Element> pNewData(new CJS_GlobalData_Element); 122 std::unique_ptr<CJS_GlobalData_Element> pNewData(new CJS_GlobalData_Element);
186 pNewData->data.sKey = sPropName; 123 pNewData->data.sKey = sPropName;
187 pNewData->data.nType = JS_GLOBALDATA_TYPE_BOOLEAN; 124 pNewData->data.nType = JS_GlobalDataType::BOOLEAN;
188 pNewData->data.bData = bData; 125 pNewData->data.bData = bData;
189 m_arrayGlobalData.push_back(std::move(pNewData)); 126 m_arrayGlobalData.push_back(std::move(pNewData));
190 } 127 }
191 128
192 void CJS_GlobalData::SetGlobalVariableString(const CFX_ByteString& propname, 129 void CJS_GlobalData::SetGlobalVariableString(const CFX_ByteString& propname,
193 const CFX_ByteString& sData) { 130 const CFX_ByteString& sData) {
194 CFX_ByteString sPropName(propname); 131 CFX_ByteString sPropName(propname);
195 if (!TrimPropName(&sPropName)) 132 if (!TrimPropName(&sPropName))
196 return; 133 return;
197 134
198 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) { 135 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) {
199 pData->data.nType = JS_GLOBALDATA_TYPE_STRING; 136 pData->data.nType = JS_GlobalDataType::STRING;
200 pData->data.sData = sData; 137 pData->data.sData = sData;
201 return; 138 return;
202 } 139 }
203 std::unique_ptr<CJS_GlobalData_Element> pNewData(new CJS_GlobalData_Element); 140 std::unique_ptr<CJS_GlobalData_Element> pNewData(new CJS_GlobalData_Element);
204 pNewData->data.sKey = sPropName; 141 pNewData->data.sKey = sPropName;
205 pNewData->data.nType = JS_GLOBALDATA_TYPE_STRING; 142 pNewData->data.nType = JS_GlobalDataType::STRING;
206 pNewData->data.sData = sData; 143 pNewData->data.sData = sData;
207 m_arrayGlobalData.push_back(std::move(pNewData)); 144 m_arrayGlobalData.push_back(std::move(pNewData));
208 } 145 }
209 146
210 void CJS_GlobalData::SetGlobalVariableObject( 147 void CJS_GlobalData::SetGlobalVariableObject(
211 const CFX_ByteString& propname, 148 const CFX_ByteString& propname,
212 const CJS_GlobalVariableArray& array) { 149 const CJS_GlobalVariableArray& array) {
213 CFX_ByteString sPropName(propname); 150 CFX_ByteString sPropName(propname);
214 if (!TrimPropName(&sPropName)) 151 if (!TrimPropName(&sPropName))
215 return; 152 return;
216 153
217 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) { 154 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) {
218 pData->data.nType = JS_GLOBALDATA_TYPE_OBJECT; 155 pData->data.nType = JS_GlobalDataType::OBJECT;
219 pData->data.objData.Copy(array); 156 pData->data.objData.Copy(array);
220 return; 157 return;
221 } 158 }
222 std::unique_ptr<CJS_GlobalData_Element> pNewData(new CJS_GlobalData_Element); 159 std::unique_ptr<CJS_GlobalData_Element> pNewData(new CJS_GlobalData_Element);
223 pNewData->data.sKey = sPropName; 160 pNewData->data.sKey = sPropName;
224 pNewData->data.nType = JS_GLOBALDATA_TYPE_OBJECT; 161 pNewData->data.nType = JS_GlobalDataType::OBJECT;
225 pNewData->data.objData.Copy(array); 162 pNewData->data.objData.Copy(array);
226 m_arrayGlobalData.push_back(std::move(pNewData)); 163 m_arrayGlobalData.push_back(std::move(pNewData));
227 } 164 }
228 165
229 void CJS_GlobalData::SetGlobalVariableNull(const CFX_ByteString& propname) { 166 void CJS_GlobalData::SetGlobalVariableNull(const CFX_ByteString& propname) {
230 CFX_ByteString sPropName(propname); 167 CFX_ByteString sPropName(propname);
231 if (!TrimPropName(&sPropName)) 168 if (!TrimPropName(&sPropName))
232 return; 169 return;
233 170
234 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) { 171 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) {
235 pData->data.nType = JS_GLOBALDATA_TYPE_NULL; 172 pData->data.nType = JS_GlobalDataType::NULLOBJ;
236 return; 173 return;
237 } 174 }
238 std::unique_ptr<CJS_GlobalData_Element> pNewData(new CJS_GlobalData_Element); 175 std::unique_ptr<CJS_GlobalData_Element> pNewData(new CJS_GlobalData_Element);
239 pNewData->data.sKey = sPropName; 176 pNewData->data.sKey = sPropName;
240 pNewData->data.nType = JS_GLOBALDATA_TYPE_NULL; 177 pNewData->data.nType = JS_GlobalDataType::NULLOBJ;
241 m_arrayGlobalData.push_back(std::move(pNewData)); 178 m_arrayGlobalData.push_back(std::move(pNewData));
242 } 179 }
243 180
244 FX_BOOL CJS_GlobalData::SetGlobalVariablePersistent( 181 FX_BOOL CJS_GlobalData::SetGlobalVariablePersistent(
245 const CFX_ByteString& propname, 182 const CFX_ByteString& propname,
246 FX_BOOL bPersistent) { 183 FX_BOOL bPersistent) {
247 CFX_ByteString sPropName(propname); 184 CFX_ByteString sPropName(propname);
248 if (!TrimPropName(&sPropName)) 185 if (!TrimPropName(&sPropName))
249 return FALSE; 186 return FALSE;
250 187
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 247
311 uint32_t dwNameLen = *((uint32_t*)p); 248 uint32_t dwNameLen = *((uint32_t*)p);
312 p += sizeof(uint32_t); 249 p += sizeof(uint32_t);
313 250
314 if (p + dwNameLen > pBuffer + nLength) 251 if (p + dwNameLen > pBuffer + nLength)
315 break; 252 break;
316 253
317 CFX_ByteString sEntry = CFX_ByteString(p, dwNameLen); 254 CFX_ByteString sEntry = CFX_ByteString(p, dwNameLen);
318 p += sizeof(char) * dwNameLen; 255 p += sizeof(char) * dwNameLen;
319 256
320 uint16_t wDataType = *((uint16_t*)p); 257 JS_GlobalDataType wDataType =
258 static_cast<JS_GlobalDataType>(*((uint16_t*)p));
321 p += sizeof(uint16_t); 259 p += sizeof(uint16_t);
322 260
323 switch (wDataType) { 261 switch (wDataType) {
324 case JS_GLOBALDATA_TYPE_NUMBER: { 262 case JS_GlobalDataType::NUMBER: {
325 double dData = 0; 263 double dData = 0;
326 switch (wVersion) { 264 switch (wVersion) {
327 case 1: { 265 case 1: {
328 uint32_t dwData = *((uint32_t*)p); 266 uint32_t dwData = *((uint32_t*)p);
329 p += sizeof(uint32_t); 267 p += sizeof(uint32_t);
330 dData = dwData; 268 dData = dwData;
331 } break; 269 } break;
332 case 2: { 270 case 2: {
333 dData = *((double*)p); 271 dData = *((double*)p);
334 p += sizeof(double); 272 p += sizeof(double);
335 } break; 273 } break;
336 } 274 }
337 SetGlobalVariableNumber(sEntry, dData); 275 SetGlobalVariableNumber(sEntry, dData);
338 SetGlobalVariablePersistent(sEntry, TRUE); 276 SetGlobalVariablePersistent(sEntry, TRUE);
339 } break; 277 } break;
340 case JS_GLOBALDATA_TYPE_BOOLEAN: { 278 case JS_GlobalDataType::BOOLEAN: {
341 uint16_t wData = *((uint16_t*)p); 279 uint16_t wData = *((uint16_t*)p);
342 p += sizeof(uint16_t); 280 p += sizeof(uint16_t);
343 SetGlobalVariableBoolean(sEntry, (bool)(wData == 1)); 281 SetGlobalVariableBoolean(sEntry, (bool)(wData == 1));
344 SetGlobalVariablePersistent(sEntry, TRUE); 282 SetGlobalVariablePersistent(sEntry, TRUE);
345 } break; 283 } break;
346 case JS_GLOBALDATA_TYPE_STRING: { 284 case JS_GlobalDataType::STRING: {
347 uint32_t dwLength = *((uint32_t*)p); 285 uint32_t dwLength = *((uint32_t*)p);
348 p += sizeof(uint32_t); 286 p += sizeof(uint32_t);
349 287
350 if (p + dwLength > pBuffer + nLength) 288 if (p + dwLength > pBuffer + nLength)
351 break; 289 break;
352 290
353 SetGlobalVariableString(sEntry, CFX_ByteString(p, dwLength)); 291 SetGlobalVariableString(sEntry, CFX_ByteString(p, dwLength));
354 SetGlobalVariablePersistent(sEntry, TRUE); 292 SetGlobalVariablePersistent(sEntry, TRUE);
355 p += sizeof(char) * dwLength; 293 p += sizeof(char) * dwLength;
356 } break; 294 } break;
357 case JS_GLOBALDATA_TYPE_NULL: { 295 case JS_GlobalDataType::NULLOBJ: {
358 SetGlobalVariableNull(sEntry); 296 SetGlobalVariableNull(sEntry);
359 SetGlobalVariablePersistent(sEntry, TRUE); 297 SetGlobalVariablePersistent(sEntry, TRUE);
360 } 298 }
299 case JS_GlobalDataType::OBJECT:
300 break;
361 } 301 }
362 } 302 }
363 } 303 }
364 } 304 }
365 FX_Free(pBuffer); 305 FX_Free(pBuffer);
366 } 306 }
367 } 307 }
368 308
369 void CJS_GlobalData::SaveGlobalPersisitentVariables() { 309 void CJS_GlobalData::SaveGlobalPersisitentVariables() {
370 uint32_t nCount = 0; 310 uint32_t nCount = 0;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 346
407 void CJS_GlobalData::WriteFileBuffer(const FX_WCHAR* sFilePath, 347 void CJS_GlobalData::WriteFileBuffer(const FX_WCHAR* sFilePath,
408 const FX_CHAR* pBuffer, 348 const FX_CHAR* pBuffer,
409 int32_t nLength) { 349 int32_t nLength) {
410 // UnSupport. 350 // UnSupport.
411 } 351 }
412 352
413 void CJS_GlobalData::MakeByteString(const CFX_ByteString& name, 353 void CJS_GlobalData::MakeByteString(const CFX_ByteString& name,
414 CJS_KeyValue* pData, 354 CJS_KeyValue* pData,
415 CFX_BinaryBuf& sData) { 355 CFX_BinaryBuf& sData) {
416 uint16_t wType = (uint16_t)pData->nType; 356 switch (pData->nType) {
417 switch (wType) { 357 case JS_GlobalDataType::NUMBER: {
418 case JS_GLOBALDATA_TYPE_NUMBER: {
419 uint32_t dwNameLen = (uint32_t)name.GetLength(); 358 uint32_t dwNameLen = (uint32_t)name.GetLength();
420 sData.AppendBlock(&dwNameLen, sizeof(uint32_t)); 359 sData.AppendBlock(&dwNameLen, sizeof(uint32_t));
421 sData.AppendString(name); 360 sData.AppendString(name);
422 sData.AppendBlock(&wType, sizeof(uint16_t)); 361 sData.AppendBlock(&pData->nType, sizeof(uint16_t));
423 362
424 double dData = pData->dData; 363 double dData = pData->dData;
425 sData.AppendBlock(&dData, sizeof(double)); 364 sData.AppendBlock(&dData, sizeof(double));
426 } break; 365 } break;
427 case JS_GLOBALDATA_TYPE_BOOLEAN: { 366 case JS_GlobalDataType::BOOLEAN: {
428 uint32_t dwNameLen = (uint32_t)name.GetLength(); 367 uint32_t dwNameLen = (uint32_t)name.GetLength();
429 sData.AppendBlock(&dwNameLen, sizeof(uint32_t)); 368 sData.AppendBlock(&dwNameLen, sizeof(uint32_t));
430 sData.AppendString(name); 369 sData.AppendString(name);
431 sData.AppendBlock(&wType, sizeof(uint16_t)); 370 sData.AppendBlock(&pData->nType, sizeof(uint16_t));
432 371
433 uint16_t wData = (uint16_t)pData->bData; 372 uint16_t wData = (uint16_t)pData->bData;
434 sData.AppendBlock(&wData, sizeof(uint16_t)); 373 sData.AppendBlock(&wData, sizeof(uint16_t));
435 } break; 374 } break;
436 case JS_GLOBALDATA_TYPE_STRING: { 375 case JS_GlobalDataType::STRING: {
437 uint32_t dwNameLen = (uint32_t)name.GetLength(); 376 uint32_t dwNameLen = (uint32_t)name.GetLength();
438 sData.AppendBlock(&dwNameLen, sizeof(uint32_t)); 377 sData.AppendBlock(&dwNameLen, sizeof(uint32_t));
439 sData.AppendString(name); 378 sData.AppendString(name);
440 sData.AppendBlock(&wType, sizeof(uint16_t)); 379 sData.AppendBlock(&pData->nType, sizeof(uint16_t));
441 380
442 uint32_t dwDataLen = (uint32_t)pData->sData.GetLength(); 381 uint32_t dwDataLen = (uint32_t)pData->sData.GetLength();
443 sData.AppendBlock(&dwDataLen, sizeof(uint32_t)); 382 sData.AppendBlock(&dwDataLen, sizeof(uint32_t));
444 sData.AppendString(pData->sData); 383 sData.AppendString(pData->sData);
445 } break; 384 } break;
446 case JS_GLOBALDATA_TYPE_NULL: { 385 case JS_GlobalDataType::NULLOBJ: {
447 uint32_t dwNameLen = (uint32_t)name.GetLength(); 386 uint32_t dwNameLen = (uint32_t)name.GetLength();
448 sData.AppendBlock(&dwNameLen, sizeof(uint32_t)); 387 sData.AppendBlock(&dwNameLen, sizeof(uint32_t));
449 sData.AppendString(name); 388 sData.AppendString(name);
450 sData.AppendBlock(&wType, sizeof(uint32_t)); 389 sData.AppendBlock(&pData->nType, sizeof(uint32_t));
451 } break; 390 } break;
452 default: 391 default:
453 break; 392 break;
454 } 393 }
455 } 394 }
456
457 CJS_KeyValue::CJS_KeyValue() {}
458
459 CJS_KeyValue::~CJS_KeyValue() {}
OLDNEW
« no previous file with comments | « fpdfsdk/javascript/JS_GlobalData.h ('k') | fpdfsdk/javascript/JS_KeyValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698