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 #include "../../include/javascript/JavaScript.h" | |
8 #include "../../include/javascript/IJavaScript.h" | 7 #include "../../include/javascript/IJavaScript.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" |
| 11 #include "../../include/javascript/JS_GlobalData.h" |
10 #include "../../include/javascript/JS_Object.h" | 12 #include "../../include/javascript/JS_Object.h" |
11 #include "../../include/javascript/JS_Value.h" | 13 #include "../../include/javascript/JS_Value.h" |
12 #include "../../include/javascript/JS_GlobalData.h" | 14 #include "../../include/javascript/JavaScript.h" |
13 #include "../../include/javascript/global.h" | 15 #include "../../include/javascript/global.h" |
14 #include "../../include/javascript/JS_EventHandler.h" | 16 #include "../../include/javascript/resource.h" |
15 #include "../../include/javascript/JS_Context.h" | |
16 | 17 |
17 /* ---------------------------- global ---------------------------- */ | 18 /* ---------------------------- global ---------------------------- */ |
18 | 19 |
19 // Helper class for compile-time calculation of hash values in order to | 20 // Helper class for compile-time calculation of hash values in order to |
20 // avoid having global object initializers. | 21 // avoid having global object initializers. |
21 template <unsigned ACC, wchar_t... Ns> | 22 template <unsigned ACC, wchar_t... Ns> |
22 struct CHash; | 23 struct CHash; |
23 | 24 |
24 // Only needed to hash single-character strings. | 25 // Only needed to hash single-character strings. |
25 template <wchar_t N> | 26 template <wchar_t N> |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 vp.SetNull(); | 264 vp.SetNull(); |
264 return TRUE; | 265 return TRUE; |
265 } | 266 } |
266 } | 267 } |
267 | 268 |
268 return FALSE; | 269 return FALSE; |
269 } | 270 } |
270 | 271 |
271 FX_BOOL global_alternate::setPersistent(IFXJS_Context* cc, const CJS_Parameters&
params, CJS_Value& vRet, JS_ErrorString& sError) | 272 FX_BOOL global_alternate::setPersistent(IFXJS_Context* cc, const CJS_Parameters&
params, CJS_Value& vRet, JS_ErrorString& sError) |
272 { | 273 { |
| 274 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
273 if (params.size() != 2) | 275 if (params.size() != 2) |
274 { | 276 { |
275 » » //sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);» | 277 » » sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
276 return FALSE; | 278 return FALSE; |
277 } | 279 } |
278 | 280 |
279 CFX_ByteString sName = params[0]; | 281 CFX_ByteString sName = params[0]; |
280 | 282 |
281 js_global_data* pData = NULL; | 283 js_global_data* pData = NULL; |
282 if (m_mapGlobal.Lookup(sName, (FX_LPVOID&)pData)) | 284 if (m_mapGlobal.Lookup(sName, (FX_LPVOID&)pData)) |
283 { | 285 { |
284 if (pData && !pData->bDeleted) | 286 if (pData && !pData->bDeleted) |
285 { | 287 { |
286 pData->bPersistent = (bool)params[1]; | 288 pData->bPersistent = (bool)params[1]; |
287 return TRUE; | 289 return TRUE; |
288 } | 290 } |
289 } | 291 } |
290 | 292 |
291 » //sError = JSGetStringFromID(IDS_JSPARAM_INCORRECT);» | 293 » sError = JSGetStringFromID(pContext, IDS_STRING_JSNOGLOBAL); |
292 return FALSE; | 294 return FALSE; |
293 } | 295 } |
294 | 296 |
295 void global_alternate::UpdateGlobalPersistentVariables() | 297 void global_alternate::UpdateGlobalPersistentVariables() |
296 { | 298 { |
297 ASSERT(m_pGlobalData != NULL); | 299 ASSERT(m_pGlobalData != NULL); |
298 | 300 |
299 for (int i=0,sz=m_pGlobalData->GetSize(); i<sz; i++) | 301 for (int i=0,sz=m_pGlobalData->GetSize(); i<sz; i++) |
300 { | 302 { |
301 CJS_GlobalData_Element* pData = m_pGlobalData->GetAt(i); | 303 CJS_GlobalData_Element* pData = m_pGlobalData->GetAt(i); |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 if (nHash == JSCONST_nDateHash) | 635 if (nHash == JSCONST_nDateHash) |
634 return VT_date; | 636 return VT_date; |
635 if (nHash == JSCONST_nObjectHash) | 637 if (nHash == JSCONST_nObjectHash) |
636 return VT_object; | 638 return VT_object; |
637 if (nHash == JSCONST_nFXobjHash) | 639 if (nHash == JSCONST_nFXobjHash) |
638 return VT_fxobject; | 640 return VT_fxobject; |
639 | 641 |
640 return VT_unknown; | 642 return VT_unknown; |
641 } | 643 } |
642 | 644 |
OLD | NEW |