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/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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 m_pGlobalData->SetGlobalVariablePersiste
nt(name, pData->bPersistent); | 380 m_pGlobalData->SetGlobalVariablePersiste
nt(name, pData->bPersistent); |
381 break; | 381 break; |
382 } | 382 } |
383 } | 383 } |
384 } | 384 } |
385 } | 385 } |
386 } | 386 } |
387 | 387 |
388 void global_alternate::ObjectToArray(v8::Handle<v8::Object> pObj, CJS_GlobalVari
ableArray& array) | 388 void global_alternate::ObjectToArray(v8::Handle<v8::Object> pObj, CJS_GlobalVari
ableArray& array) |
389 { | 389 { |
390 v8::Handle<v8::Array> pKeyList = JS_GetObjectElementNames(pObj); | |
391 int nObjElements = pKeyList->Length(); | |
392 | |
393 v8::Local<v8::Context> context = pObj->CreationContext(); | 390 v8::Local<v8::Context> context = pObj->CreationContext(); |
394 v8::Isolate* isolate = context->GetIsolate(); | 391 v8::Isolate* isolate = context->GetIsolate(); |
| 392 v8::Handle<v8::Array> pKeyList = JS_GetObjectElementNames(isolate, pObj)
; |
| 393 int nObjElements = pKeyList->Length(); |
395 | 394 |
396 for (int i=0; i<nObjElements; i++) | 395 for (int i=0; i<nObjElements; i++) |
397 { | 396 { |
398 | 397 |
399 » » CFX_WideString ws = JS_ToString(JS_GetArrayElemnet(pKeyList, i))
; | 398 » » CFX_WideString ws = JS_ToString(isolate, JS_GetArrayElement(isol
ate, pKeyList, i)); |
400 CFX_ByteString sKey = ws.UTF8Encode(); | 399 CFX_ByteString sKey = ws.UTF8Encode(); |
401 | 400 |
402 v8::Handle<v8::Value> v = JS_GetObjectElement(isolate, pObj, ws.
c_str()); | 401 v8::Handle<v8::Value> v = JS_GetObjectElement(isolate, pObj, ws.
c_str()); |
403 FXJSVALUETYPE vt = GET_VALUE_TYPE(v); | 402 FXJSVALUETYPE vt = GET_VALUE_TYPE(v); |
404 switch (vt) | 403 switch (vt) |
405 { | 404 { |
406 case VT_number: | 405 case VT_number: |
407 { | 406 { |
408 CJS_KeyValue* pObjElement = new CJS_KeyValue; | 407 CJS_KeyValue* pObjElement = new CJS_KeyValue; |
409 pObjElement->nType = JS_GLOBALDATA_TYPE_NUMBER; | 408 pObjElement->nType = JS_GLOBALDATA_TYPE_NUMBER; |
410 pObjElement->sKey = sKey; | 409 pObjElement->sKey = sKey; |
411 » » » » pObjElement->dData = JS_ToNumber(v); | 410 » » » » pObjElement->dData = JS_ToNumber(isolate, v); |
412 array.Add(pObjElement); | 411 array.Add(pObjElement); |
413 } | 412 } |
414 break; | 413 break; |
415 case VT_boolean: | 414 case VT_boolean: |
416 { | 415 { |
417 CJS_KeyValue* pObjElement = new CJS_KeyValue; | 416 CJS_KeyValue* pObjElement = new CJS_KeyValue; |
418 pObjElement->nType = JS_GLOBALDATA_TYPE_BOOLEAN; | 417 pObjElement->nType = JS_GLOBALDATA_TYPE_BOOLEAN; |
419 pObjElement->sKey = sKey; | 418 pObjElement->sKey = sKey; |
420 » » » » pObjElement->dData = JS_ToBoolean(v); | 419 » » » » pObjElement->dData = JS_ToBoolean(isolate, v); |
421 array.Add(pObjElement); | 420 array.Add(pObjElement); |
422 } | 421 } |
423 break; | 422 break; |
424 case VT_string: | 423 case VT_string: |
425 { | 424 { |
426 CFX_ByteString sValue = CJS_Value(isolate, v, VT
_string).ToCFXByteString(); | 425 CFX_ByteString sValue = CJS_Value(isolate, v, VT
_string).ToCFXByteString(); |
427 CJS_KeyValue* pObjElement = new CJS_KeyValue; | 426 CJS_KeyValue* pObjElement = new CJS_KeyValue; |
428 pObjElement->nType = JS_GLOBALDATA_TYPE_STRING; | 427 pObjElement->nType = JS_GLOBALDATA_TYPE_STRING; |
429 pObjElement->sKey = sKey; | 428 pObjElement->sKey = sKey; |
430 pObjElement->sData = sValue; | 429 pObjElement->sData = sValue; |
431 array.Add(pObjElement); | 430 array.Add(pObjElement); |
432 } | 431 } |
433 break; | 432 break; |
434 case VT_object: | 433 case VT_object: |
435 { | 434 { |
436 CJS_KeyValue* pObjElement = new CJS_KeyValue; | 435 CJS_KeyValue* pObjElement = new CJS_KeyValue; |
437 pObjElement->nType = JS_GLOBALDATA_TYPE_OBJECT; | 436 pObjElement->nType = JS_GLOBALDATA_TYPE_OBJECT; |
438 pObjElement->sKey = sKey; | 437 pObjElement->sKey = sKey; |
439 » » » » ObjectToArray(JS_ToObject(v), pObjElement->objDa
ta); | 438 » » » » ObjectToArray(JS_ToObject(isolate, v), pObjEleme
nt->objData); |
440 array.Add(pObjElement); | 439 array.Add(pObjElement); |
441 } | 440 } |
442 break; | 441 break; |
443 case VT_null: | 442 case VT_null: |
444 { | 443 { |
445 CJS_KeyValue* pObjElement = new CJS_KeyValue; | 444 CJS_KeyValue* pObjElement = new CJS_KeyValue; |
446 pObjElement->nType = JS_GLOBALDATA_TYPE_NULL; | 445 pObjElement->nType = JS_GLOBALDATA_TYPE_NULL; |
447 pObjElement->sKey = sKey; | 446 pObjElement->sKey = sKey; |
448 array.Add(pObjElement); | 447 array.Add(pObjElement); |
449 } | 448 } |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 if (nHash == JSCONST_nDateHash) | 623 if (nHash == JSCONST_nDateHash) |
625 return VT_date; | 624 return VT_date; |
626 if (nHash == JSCONST_nObjectHash) | 625 if (nHash == JSCONST_nObjectHash) |
627 return VT_object; | 626 return VT_object; |
628 if (nHash == JSCONST_nFXobjHash) | 627 if (nHash == JSCONST_nFXobjHash) |
629 return VT_fxobject; | 628 return VT_fxobject; |
630 | 629 |
631 return VT_unknown; | 630 return VT_unknown; |
632 } | 631 } |
633 | 632 |
OLD | NEW |