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

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

Issue 1171733003: Remove typdefs for pointer types in fx_system.h (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual fixes. Created 5 years, 6 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/src/javascript/JS_EventHandler.cpp ('k') | fpdfsdk/src/javascript/JS_Object.cpp » ('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 "../../include/javascript/JavaScript.h" 7 #include "../../include/javascript/JavaScript.h"
8 #include "../../include/javascript/IJavaScript.h" 8 #include "../../include/javascript/IJavaScript.h"
9 #include "../../include/javascript/JS_GlobalData.h" 9 #include "../../include/javascript/JS_GlobalData.h"
10 10
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 CJS_GlobalData::~CJS_GlobalData() 131 CJS_GlobalData::~CJS_GlobalData()
132 { 132 {
133 SaveGlobalPersisitentVariables(); 133 SaveGlobalPersisitentVariables();
134 134
135 for (int i=0,sz=m_arrayGlobalData.GetSize(); i<sz; i++) 135 for (int i=0,sz=m_arrayGlobalData.GetSize(); i<sz; i++)
136 delete m_arrayGlobalData.GetAt(i); 136 delete m_arrayGlobalData.GetAt(i);
137 137
138 m_arrayGlobalData.RemoveAll(); 138 m_arrayGlobalData.RemoveAll();
139 } 139 }
140 140
141 int» CJS_GlobalData::FindGlobalVariable(FX_LPCSTR propname) 141 int» CJS_GlobalData::FindGlobalVariable(const FX_CHAR* propname)
142 { 142 {
143 ASSERT(propname != NULL); 143 ASSERT(propname != NULL);
144 144
145 int nRet = -1; 145 int nRet = -1;
146 146
147 for (int i=0,sz=m_arrayGlobalData.GetSize(); i<sz; i++) 147 for (int i=0,sz=m_arrayGlobalData.GetSize(); i<sz; i++)
148 { 148 {
149 CJS_GlobalData_Element* pTemp = m_arrayGlobalData.GetAt(i); 149 CJS_GlobalData_Element* pTemp = m_arrayGlobalData.GetAt(i);
150 if (pTemp->data.sKey[0] == *propname && pTemp->data.sKey == prop name) 150 if (pTemp->data.sKey[0] == *propname && pTemp->data.sKey == prop name)
151 { 151 {
152 nRet = i; 152 nRet = i;
153 break; 153 break;
154 } 154 }
155 } 155 }
156 156
157 return nRet; 157 return nRet;
158 } 158 }
159 159
160 CJS_GlobalData_Element* CJS_GlobalData::GetGlobalVariable(FX_LPCSTR propname) 160 CJS_GlobalData_Element* CJS_GlobalData::GetGlobalVariable(const FX_CHAR* propnam e)
161 { 161 {
162 ASSERT(propname != NULL); 162 ASSERT(propname != NULL);
163 163
164 int nFind = FindGlobalVariable(propname); 164 int nFind = FindGlobalVariable(propname);
165 165
166 if (nFind >= 0) 166 if (nFind >= 0)
167 return m_arrayGlobalData.GetAt(nFind); 167 return m_arrayGlobalData.GetAt(nFind);
168 else 168 else
169 return NULL; 169 return NULL;
170 } 170 }
171 171
172 void CJS_GlobalData::SetGlobalVariableNumber(FX_LPCSTR propname, double dData) 172 void CJS_GlobalData::SetGlobalVariableNumber(const FX_CHAR* propname, double dDa ta)
173 { 173 {
174 ASSERT(propname != NULL); 174 ASSERT(propname != NULL);
175 CFX_ByteString sPropName = propname; 175 CFX_ByteString sPropName = propname;
176 176
177 sPropName.TrimLeft(); 177 sPropName.TrimLeft();
178 sPropName.TrimRight(); 178 sPropName.TrimRight();
179 179
180 if (sPropName.GetLength() == 0) return; 180 if (sPropName.GetLength() == 0) return;
181 181
182 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) 182 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName))
183 { 183 {
184 pData->data.nType = JS_GLOBALDATA_TYPE_NUMBER; 184 pData->data.nType = JS_GLOBALDATA_TYPE_NUMBER;
185 pData->data.dData = dData; 185 pData->data.dData = dData;
186 } 186 }
187 else 187 else
188 { 188 {
189 CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element; 189 CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element;
190 pNewData->data.sKey = sPropName; 190 pNewData->data.sKey = sPropName;
191 pNewData->data.nType = JS_GLOBALDATA_TYPE_NUMBER; 191 pNewData->data.nType = JS_GLOBALDATA_TYPE_NUMBER;
192 pNewData->data.dData = dData; 192 pNewData->data.dData = dData;
193 193
194 m_arrayGlobalData.Add(pNewData); 194 m_arrayGlobalData.Add(pNewData);
195 } 195 }
196 } 196 }
197 197
198 void CJS_GlobalData::SetGlobalVariableBoolean(FX_LPCSTR propname, bool bData) 198 void CJS_GlobalData::SetGlobalVariableBoolean(const FX_CHAR* propname, bool bDat a)
199 { 199 {
200 ASSERT(propname != NULL); 200 ASSERT(propname != NULL);
201 CFX_ByteString sPropName = propname; 201 CFX_ByteString sPropName = propname;
202 202
203 sPropName.TrimLeft(); 203 sPropName.TrimLeft();
204 sPropName.TrimRight(); 204 sPropName.TrimRight();
205 205
206 if (sPropName.GetLength() == 0) return; 206 if (sPropName.GetLength() == 0) return;
207 207
208 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) 208 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName))
209 { 209 {
210 pData->data.nType = JS_GLOBALDATA_TYPE_BOOLEAN; 210 pData->data.nType = JS_GLOBALDATA_TYPE_BOOLEAN;
211 pData->data.bData = bData; 211 pData->data.bData = bData;
212 } 212 }
213 else 213 else
214 { 214 {
215 CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element; 215 CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element;
216 pNewData->data.sKey = sPropName; 216 pNewData->data.sKey = sPropName;
217 pNewData->data.nType = JS_GLOBALDATA_TYPE_BOOLEAN; 217 pNewData->data.nType = JS_GLOBALDATA_TYPE_BOOLEAN;
218 pNewData->data.bData = bData; 218 pNewData->data.bData = bData;
219 219
220 m_arrayGlobalData.Add(pNewData); 220 m_arrayGlobalData.Add(pNewData);
221 } 221 }
222 } 222 }
223 223
224 void CJS_GlobalData::SetGlobalVariableString(FX_LPCSTR propname, const CFX_ByteS tring& sData) 224 void CJS_GlobalData::SetGlobalVariableString(const FX_CHAR* propname, const CFX_ ByteString& sData)
225 { 225 {
226 ASSERT(propname != NULL); 226 ASSERT(propname != NULL);
227 CFX_ByteString sPropName = propname; 227 CFX_ByteString sPropName = propname;
228 228
229 sPropName.TrimLeft(); 229 sPropName.TrimLeft();
230 sPropName.TrimRight(); 230 sPropName.TrimRight();
231 231
232 if (sPropName.GetLength() == 0) return; 232 if (sPropName.GetLength() == 0) return;
233 233
234 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) 234 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName))
235 { 235 {
236 pData->data.nType = JS_GLOBALDATA_TYPE_STRING; 236 pData->data.nType = JS_GLOBALDATA_TYPE_STRING;
237 pData->data.sData = sData; 237 pData->data.sData = sData;
238 } 238 }
239 else 239 else
240 { 240 {
241 CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element; 241 CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element;
242 pNewData->data.sKey = sPropName; 242 pNewData->data.sKey = sPropName;
243 pNewData->data.nType = JS_GLOBALDATA_TYPE_STRING; 243 pNewData->data.nType = JS_GLOBALDATA_TYPE_STRING;
244 pNewData->data.sData = sData; 244 pNewData->data.sData = sData;
245 245
246 m_arrayGlobalData.Add(pNewData); 246 m_arrayGlobalData.Add(pNewData);
247 } 247 }
248 } 248 }
249 249
250 void CJS_GlobalData::SetGlobalVariableObject(FX_LPCSTR propname, const CJS_Globa lVariableArray& array) 250 void CJS_GlobalData::SetGlobalVariableObject(const FX_CHAR* propname, const CJS_ GlobalVariableArray& array)
251 { 251 {
252 ASSERT(propname != NULL); 252 ASSERT(propname != NULL);
253 CFX_ByteString sPropName = propname; 253 CFX_ByteString sPropName = propname;
254 254
255 sPropName.TrimLeft(); 255 sPropName.TrimLeft();
256 sPropName.TrimRight(); 256 sPropName.TrimRight();
257 257
258 if (sPropName.GetLength() == 0) return; 258 if (sPropName.GetLength() == 0) return;
259 259
260 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) 260 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName))
261 { 261 {
262 pData->data.nType = JS_GLOBALDATA_TYPE_OBJECT; 262 pData->data.nType = JS_GLOBALDATA_TYPE_OBJECT;
263 pData->data.objData.Copy(array); 263 pData->data.objData.Copy(array);
264 } 264 }
265 else 265 else
266 { 266 {
267 CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element; 267 CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element;
268 pNewData->data.sKey = sPropName; 268 pNewData->data.sKey = sPropName;
269 pNewData->data.nType = JS_GLOBALDATA_TYPE_OBJECT; 269 pNewData->data.nType = JS_GLOBALDATA_TYPE_OBJECT;
270 pNewData->data.objData.Copy(array); 270 pNewData->data.objData.Copy(array);
271 271
272 m_arrayGlobalData.Add(pNewData); 272 m_arrayGlobalData.Add(pNewData);
273 } 273 }
274 } 274 }
275 275
276 void CJS_GlobalData::SetGlobalVariableNull(FX_LPCSTR propname) 276 void CJS_GlobalData::SetGlobalVariableNull(const FX_CHAR* propname)
277 { 277 {
278 ASSERT(propname != NULL); 278 ASSERT(propname != NULL);
279 CFX_ByteString sPropName = propname; 279 CFX_ByteString sPropName = propname;
280 280
281 sPropName.TrimLeft(); 281 sPropName.TrimLeft();
282 sPropName.TrimRight(); 282 sPropName.TrimRight();
283 283
284 if (sPropName.GetLength() == 0) return; 284 if (sPropName.GetLength() == 0) return;
285 285
286 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) 286 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName))
287 { 287 {
288 pData->data.nType = JS_GLOBALDATA_TYPE_NULL; 288 pData->data.nType = JS_GLOBALDATA_TYPE_NULL;
289 } 289 }
290 else 290 else
291 { 291 {
292 CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element; 292 CJS_GlobalData_Element* pNewData = new CJS_GlobalData_Element;
293 pNewData->data.sKey = sPropName; 293 pNewData->data.sKey = sPropName;
294 pNewData->data.nType = JS_GLOBALDATA_TYPE_NULL; 294 pNewData->data.nType = JS_GLOBALDATA_TYPE_NULL;
295 295
296 m_arrayGlobalData.Add(pNewData); 296 m_arrayGlobalData.Add(pNewData);
297 } 297 }
298 } 298 }
299 299
300 FX_BOOL CJS_GlobalData::SetGlobalVariablePersistent(FX_LPCSTR propname, FX_BOOL bPersistent) 300 FX_BOOL CJS_GlobalData::SetGlobalVariablePersistent(const FX_CHAR* propname, FX_ BOOL bPersistent)
301 { 301 {
302 ASSERT(propname != NULL); 302 ASSERT(propname != NULL);
303 CFX_ByteString sPropName = propname; 303 CFX_ByteString sPropName = propname;
304 304
305 sPropName.TrimLeft(); 305 sPropName.TrimLeft();
306 sPropName.TrimRight(); 306 sPropName.TrimRight();
307 307
308 if (sPropName.GetLength() == 0) return FALSE; 308 if (sPropName.GetLength() == 0) return FALSE;
309 309
310 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) 310 if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName))
311 { 311 {
312 pData->bPersistent = bPersistent; 312 pData->bPersistent = bPersistent;
313 return TRUE; 313 return TRUE;
314 } 314 }
315 315
316 return FALSE; 316 return FALSE;
317 } 317 }
318 318
319 FX_BOOL CJS_GlobalData::DeleteGlobalVariable(FX_LPCSTR propname) 319 FX_BOOL CJS_GlobalData::DeleteGlobalVariable(const FX_CHAR* propname)
320 { 320 {
321 ASSERT(propname != NULL); 321 ASSERT(propname != NULL);
322 CFX_ByteString sPropName = propname; 322 CFX_ByteString sPropName = propname;
323 323
324 sPropName.TrimLeft(); 324 sPropName.TrimLeft();
325 sPropName.TrimRight(); 325 sPropName.TrimRight();
326 326
327 if (sPropName.GetLength() == 0) return FALSE; 327 if (sPropName.GetLength() == 0) return FALSE;
328 328
329 int nFind = FindGlobalVariable(sPropName); 329 int nFind = FindGlobalVariable(sPropName);
(...skipping 13 matching lines...) Expand all
343 return m_arrayGlobalData.GetSize(); 343 return m_arrayGlobalData.GetSize();
344 } 344 }
345 345
346 CJS_GlobalData_Element* CJS_GlobalData::GetAt(int index) const 346 CJS_GlobalData_Element* CJS_GlobalData::GetAt(int index) const
347 { 347 {
348 return m_arrayGlobalData.GetAt(index); 348 return m_arrayGlobalData.GetAt(index);
349 } 349 }
350 350
351 void CJS_GlobalData::LoadGlobalPersistentVariables() 351 void CJS_GlobalData::LoadGlobalPersistentVariables()
352 { 352 {
353 » FX_LPBYTE pBuffer = NULL; 353 » uint8_t* pBuffer = NULL;
354 int32_t nLength = 0; 354 int32_t nLength = 0;
355 355
356 LoadFileBuffer(m_sFilePath.c_str(), pBuffer, nLength); 356 LoadFileBuffer(m_sFilePath.c_str(), pBuffer, nLength);
357 CRYPT_ArcFourCryptBlock(pBuffer, nLength, JS_RC4KEY, sizeof(JS_RC4KEY)); 357 CRYPT_ArcFourCryptBlock(pBuffer, nLength, JS_RC4KEY, sizeof(JS_RC4KEY));
358 358
359 if (pBuffer) 359 if (pBuffer)
360 { 360 {
361 » » FX_LPBYTE p = pBuffer; 361 » » uint8_t* p = pBuffer;
362 FX_WORD wType = *((FX_WORD*)p); 362 FX_WORD wType = *((FX_WORD*)p);
363 p += sizeof(FX_WORD); 363 p += sizeof(FX_WORD);
364 364
365 //FX_WORD wTemp = (FX_WORD)(('X' << 8) | 'F'); 365 //FX_WORD wTemp = (FX_WORD)(('X' << 8) | 'F');
366 366
367 if (wType == (FX_WORD)(('X' << 8) | 'F')) 367 if (wType == (FX_WORD)(('X' << 8) | 'F'))
368 { 368 {
369 FX_WORD wVersion = *((FX_WORD*)p); 369 FX_WORD wVersion = *((FX_WORD*)p);
370 p += sizeof(FX_WORD); 370 p += sizeof(FX_WORD);
371 371
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 sFile.AppendBlock(&wType, sizeof(FX_WORD)); 501 sFile.AppendBlock(&wType, sizeof(FX_WORD));
502 FX_WORD wVersion = 2; 502 FX_WORD wVersion = 2;
503 sFile.AppendBlock(&wVersion, sizeof(FX_WORD)); 503 sFile.AppendBlock(&wVersion, sizeof(FX_WORD));
504 sFile.AppendBlock(&nCount, sizeof(FX_DWORD)); 504 sFile.AppendBlock(&nCount, sizeof(FX_DWORD));
505 FX_DWORD dwSize = sData.GetSize(); 505 FX_DWORD dwSize = sData.GetSize();
506 sFile.AppendBlock(&dwSize, sizeof(FX_DWORD)); 506 sFile.AppendBlock(&dwSize, sizeof(FX_DWORD));
507 507
508 sFile.AppendBlock(sData.GetBuffer(), sData.GetSize()); 508 sFile.AppendBlock(sData.GetBuffer(), sData.GetSize());
509 509
510 CRYPT_ArcFourCryptBlock(sFile.GetBuffer(), sFile.GetSize(), JS_RC4KEY, s izeof(JS_RC4KEY)); 510 CRYPT_ArcFourCryptBlock(sFile.GetBuffer(), sFile.GetSize(), JS_RC4KEY, s izeof(JS_RC4KEY));
511 » WriteFileBuffer(m_sFilePath.c_str(), (FX_LPCSTR)sFile.GetBuffer(), sFile .GetSize()); 511 » WriteFileBuffer(m_sFilePath.c_str(), (const FX_CHAR*)sFile.GetBuffer(), sFile.GetSize());
512 } 512 }
513 513
514 void CJS_GlobalData::LoadFileBuffer(FX_LPCWSTR sFilePath, FX_LPBYTE& pBuffer, in t32_t& nLength) 514 void CJS_GlobalData::LoadFileBuffer(const FX_WCHAR* sFilePath, uint8_t*& pBuffer , int32_t& nLength)
515 { 515 {
516 //UnSupport. 516 //UnSupport.
517 } 517 }
518 518
519 void CJS_GlobalData::WriteFileBuffer(FX_LPCWSTR sFilePath, FX_LPCSTR pBuffer, in t32_t nLength) 519 void CJS_GlobalData::WriteFileBuffer(const FX_WCHAR* sFilePath, const FX_CHAR* p Buffer, int32_t nLength)
520 { 520 {
521 //UnSupport. 521 //UnSupport.
522 } 522 }
523 523
524 void CJS_GlobalData::MakeByteString(const CFX_ByteString& name, CJS_KeyValue* pD ata, CFX_BinaryBuf& sData) 524 void CJS_GlobalData::MakeByteString(const CFX_ByteString& name, CJS_KeyValue* pD ata, CFX_BinaryBuf& sData)
525 { 525 {
526 ASSERT(pData != NULL); 526 ASSERT(pData != NULL);
527 527
528 FX_WORD wType = (FX_WORD)pData->nType; 528 FX_WORD wType = (FX_WORD)pData->nType;
529 529
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 sData.AppendString(name); 571 sData.AppendString(name);
572 572
573 sData.AppendBlock(&wType, sizeof(FX_DWORD)); 573 sData.AppendBlock(&wType, sizeof(FX_DWORD));
574 } 574 }
575 break; 575 break;
576 default: 576 default:
577 break; 577 break;
578 } 578 }
579 } 579 }
580 580
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/JS_EventHandler.cpp ('k') | fpdfsdk/src/javascript/JS_Object.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698