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

Side by Side Diff: fpdfsdk/src/javascript/global.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/PublicMethods.cpp ('k') | fpdfsdk/src/javascript/util.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/IJavaScript.h" 7 #include "../../include/javascript/IJavaScript.h"
8 #include "../../include/javascript/JS_Context.h" 8 #include "../../include/javascript/JS_Context.h"
9 #include "../../include/javascript/JS_Define.h" 9 #include "../../include/javascript/JS_Define.h"
10 #include "../../include/javascript/JS_EventHandler.h" 10 #include "../../include/javascript/JS_EventHandler.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 void global_alternate::Initial(CPDFDoc_Environment* pApp) 131 void global_alternate::Initial(CPDFDoc_Environment* pApp)
132 { 132 {
133 m_pApp = pApp; 133 m_pApp = pApp;
134 134
135 CJS_RuntimeFactory* pFactory = pApp->m_pJSRuntimeFactory; 135 CJS_RuntimeFactory* pFactory = pApp->m_pJSRuntimeFactory;
136 ASSERT(pFactory); 136 ASSERT(pFactory);
137 m_pGlobalData = pFactory->NewGlobalData(pApp); 137 m_pGlobalData = pFactory->NewGlobalData(pApp);
138 UpdateGlobalPersistentVariables(); 138 UpdateGlobalPersistentVariables();
139 } 139 }
140 140
141 FX_BOOL»global_alternate::QueryProperty(FX_LPCWSTR propname) 141 FX_BOOL»global_alternate::QueryProperty(const FX_WCHAR* propname)
142 { 142 {
143 return CFX_WideString(propname) != L"setPersistent"; 143 return CFX_WideString(propname) != L"setPersistent";
144 } 144 }
145 145
146 FX_BOOL»global_alternate::DelProperty(IFXJS_Context* cc, FX_LPCWSTR propname, CF X_WideString& sError) 146 FX_BOOL»global_alternate::DelProperty(IFXJS_Context* cc, const FX_WCHAR* propnam e, CFX_WideString& sError)
147 { 147 {
148 js_global_data* pData = NULL; 148 js_global_data* pData = NULL;
149 CFX_ByteString sPropName = CFX_ByteString::FromUnicode(propname); 149 CFX_ByteString sPropName = CFX_ByteString::FromUnicode(propname);
150 150
151 » if (m_mapGlobal.Lookup(sPropName, (FX_LPVOID&)pData)) 151 » if (m_mapGlobal.Lookup(sPropName, (void*&)pData))
152 { 152 {
153 pData->bDeleted = TRUE; 153 pData->bDeleted = TRUE;
154 return TRUE; 154 return TRUE;
155 } 155 }
156 156
157 return FALSE; 157 return FALSE;
158 } 158 }
159 159
160 FX_BOOL global_alternate::DoProperty(IFXJS_Context* cc, FX_LPCWSTR propname, CJS _PropValue& vp, CFX_WideString& sError) 160 FX_BOOL global_alternate::DoProperty(IFXJS_Context* cc, const FX_WCHAR* propname , CJS_PropValue& vp, CFX_WideString& sError)
161 { 161 {
162 if (vp.IsSetting()) 162 if (vp.IsSetting())
163 { 163 {
164 CFX_ByteString sPropName = CFX_ByteString::FromUnicode(propname) ; 164 CFX_ByteString sPropName = CFX_ByteString::FromUnicode(propname) ;
165 switch (vp.GetType()) 165 switch (vp.GetType())
166 { 166 {
167 case VT_number: 167 case VT_number:
168 { 168 {
169 double dData; 169 double dData;
170 vp >> dData; 170 vp >> dData;
(...skipping 28 matching lines...) Expand all
199 } 199 }
200 default: 200 default:
201 return FALSE; 201 return FALSE;
202 } 202 }
203 } 203 }
204 else 204 else
205 { 205 {
206 js_global_data* pData = NULL; 206 js_global_data* pData = NULL;
207 CFX_ByteString sPropName = CFX_ByteString::FromUnicode(propname) ; 207 CFX_ByteString sPropName = CFX_ByteString::FromUnicode(propname) ;
208 208
209 » » if (m_mapGlobal.Lookup(sPropName, (FX_LPVOID&)pData)) 209 » » if (m_mapGlobal.Lookup(sPropName, (void*&)pData))
210 { 210 {
211 if (pData) 211 if (pData)
212 { 212 {
213 if (!pData->bDeleted) 213 if (!pData->bDeleted)
214 { 214 {
215 switch (pData->nType) 215 switch (pData->nType)
216 { 216 {
217 case JS_GLOBALDATA_TYPE_NUMBER: 217 case JS_GLOBALDATA_TYPE_NUMBER:
218 vp << pData->dData; 218 vp << pData->dData;
219 break; 219 break;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 CJS_Context* pContext = static_cast<CJS_Context*>(cc); 263 CJS_Context* pContext = static_cast<CJS_Context*>(cc);
264 if (params.size() != 2) 264 if (params.size() != 2)
265 { 265 {
266 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); 266 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
267 return FALSE; 267 return FALSE;
268 } 268 }
269 269
270 CFX_ByteString sName = params[0].ToCFXByteString(); 270 CFX_ByteString sName = params[0].ToCFXByteString();
271 271
272 js_global_data* pData = NULL; 272 js_global_data* pData = NULL;
273 » if (m_mapGlobal.Lookup(sName, (FX_LPVOID&)pData)) 273 » if (m_mapGlobal.Lookup(sName, (void*&)pData))
274 { 274 {
275 if (pData && !pData->bDeleted) 275 if (pData && !pData->bDeleted)
276 { 276 {
277 pData->bPersistent = params[1].ToBool(); 277 pData->bPersistent = params[1].ToBool();
278 return TRUE; 278 return TRUE;
279 } 279 }
280 } 280 }
281 281
282 sError = JSGetStringFromID(pContext, IDS_STRING_JSNOGLOBAL); 282 sError = JSGetStringFromID(pContext, IDS_STRING_JSNOGLOBAL);
283 return FALSE; 283 return FALSE;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 334
335 void global_alternate::CommitGlobalPersisitentVariables() 335 void global_alternate::CommitGlobalPersisitentVariables()
336 { 336 {
337 ASSERT(m_pGlobalData != NULL); 337 ASSERT(m_pGlobalData != NULL);
338 338
339 FX_POSITION pos = m_mapGlobal.GetStartPosition(); 339 FX_POSITION pos = m_mapGlobal.GetStartPosition();
340 while (pos) 340 while (pos)
341 { 341 {
342 CFX_ByteString name; 342 CFX_ByteString name;
343 js_global_data* pData = NULL; 343 js_global_data* pData = NULL;
344 » » m_mapGlobal.GetNextAssoc(pos, name, (FX_LPVOID&)pData); 344 » » m_mapGlobal.GetNextAssoc(pos, name, (void*&)pData);
345 345
346 if (pData) 346 if (pData)
347 { 347 {
348 if (pData->bDeleted) 348 if (pData->bDeleted)
349 { 349 {
350 m_pGlobalData->DeleteGlobalVariable(name); 350 m_pGlobalData->DeleteGlobalVariable(name);
351 } 351 }
352 else 352 else
353 { 353 {
354 switch (pData->nType) 354 switch (pData->nType)
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 } 488 }
489 } 489 }
490 490
491 void global_alternate::DestroyGlobalPersisitentVariables() 491 void global_alternate::DestroyGlobalPersisitentVariables()
492 { 492 {
493 FX_POSITION pos = m_mapGlobal.GetStartPosition(); 493 FX_POSITION pos = m_mapGlobal.GetStartPosition();
494 while (pos) 494 while (pos)
495 { 495 {
496 CFX_ByteString name; 496 CFX_ByteString name;
497 js_global_data* pData = NULL; 497 js_global_data* pData = NULL;
498 » » m_mapGlobal.GetNextAssoc(pos, name, (FX_LPVOID&)pData); 498 » » m_mapGlobal.GetNextAssoc(pos, name, (void*&)pData);
499 delete pData; 499 delete pData;
500 } 500 }
501 501
502 m_mapGlobal.RemoveAll(); 502 m_mapGlobal.RemoveAll();
503 } 503 }
504 504
505 505
506 FX_BOOL global_alternate::SetGlobalVariables(FX_LPCSTR propname, int nType, 506 FX_BOOL global_alternate::SetGlobalVariables(const FX_CHAR* propname, int nType,
507 double dData, bool bData, const CFX_ByteString& sData, JSObject pData, bool bDefaultPersistent) 507 double dData, bool bData, const CFX_ByteString& sData, JSObject pData, bool bDefaultPersistent)
508 { 508 {
509 if (propname == NULL) return FALSE; 509 if (propname == NULL) return FALSE;
510 510
511 js_global_data* pTemp = NULL; 511 js_global_data* pTemp = NULL;
512 » m_mapGlobal.Lookup(propname, (FX_LPVOID&)pTemp); 512 » m_mapGlobal.Lookup(propname, (void*&)pTemp);
513 513
514 if (pTemp) 514 if (pTemp)
515 { 515 {
516 if (pTemp->bDeleted || pTemp->nType != nType) 516 if (pTemp->bDeleted || pTemp->nType != nType)
517 { 517 {
518 pTemp->dData = 0; 518 pTemp->dData = 0;
519 pTemp->bData = 0; 519 pTemp->bData = 0;
520 pTemp->sData = ""; 520 pTemp->sData = "";
521 pTemp->nType = nType; 521 pTemp->nType = nType;
522 } 522 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 { 594 {
595 pNewData = new js_global_data; 595 pNewData = new js_global_data;
596 pNewData->nType = JS_GLOBALDATA_TYPE_NULL; 596 pNewData->nType = JS_GLOBALDATA_TYPE_NULL;
597 pNewData->bPersistent = bDefaultPersistent; 597 pNewData->bPersistent = bDefaultPersistent;
598 } 598 }
599 break; 599 break;
600 default: 600 default:
601 return FALSE; 601 return FALSE;
602 } 602 }
603 603
604 » m_mapGlobal.SetAt(propname, (FX_LPVOID)pNewData); 604 » m_mapGlobal.SetAt(propname, (void*)pNewData);
605 605
606 return TRUE; 606 return TRUE;
607 } 607 }
608 608
609 FXJSVALUETYPE GET_VALUE_TYPE(v8::Local<v8::Value> p) 609 FXJSVALUETYPE GET_VALUE_TYPE(v8::Local<v8::Value> p)
610 { 610 {
611 const unsigned int nHash = JS_CalcHash(JS_GetTypeof(p)); 611 const unsigned int nHash = JS_CalcHash(JS_GetTypeof(p));
612 612
613 if (nHash == JSCONST_nUndefHash) 613 if (nHash == JSCONST_nUndefHash)
614 return VT_undefined; 614 return VT_undefined;
615 if (nHash == JSCONST_nNullHash) 615 if (nHash == JSCONST_nNullHash)
616 return VT_null; 616 return VT_null;
617 if (nHash == JSCONST_nStringHash) 617 if (nHash == JSCONST_nStringHash)
618 return VT_string; 618 return VT_string;
619 if (nHash == JSCONST_nNumberHash) 619 if (nHash == JSCONST_nNumberHash)
620 return VT_number; 620 return VT_number;
621 if (nHash == JSCONST_nBoolHash) 621 if (nHash == JSCONST_nBoolHash)
622 return VT_boolean; 622 return VT_boolean;
623 if (nHash == JSCONST_nDateHash) 623 if (nHash == JSCONST_nDateHash)
624 return VT_date; 624 return VT_date;
625 if (nHash == JSCONST_nObjectHash) 625 if (nHash == JSCONST_nObjectHash)
626 return VT_object; 626 return VT_object;
627 if (nHash == JSCONST_nFXobjHash) 627 if (nHash == JSCONST_nFXobjHash)
628 return VT_fxobject; 628 return VT_fxobject;
629 629
630 return VT_unknown; 630 return VT_unknown;
631 } 631 }
632 632
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/PublicMethods.cpp ('k') | fpdfsdk/src/javascript/util.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698