| 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 "xfa/fxfa/fm2js/xfa_fm2jscontext.h" | 7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" |
| 8 | 8 |
| 9 #include <time.h> | 9 #include <time.h> |
| 10 | 10 |
| 11 #include "core/fxcrt/include/fx_ext.h" | 11 #include "core/fxcrt/include/fx_ext.h" |
| 12 #include "xfa/fgas/localization/fgas_locale.h" | 12 #include "xfa/fgas/localization/fgas_locale.h" |
| 13 #include "xfa/fxfa/app/xfa_ffnotify.h" | 13 #include "xfa/fxfa/app/xfa_ffnotify.h" |
| 14 #include "xfa/fxfa/fm2js/xfa_program.h" | 14 #include "xfa/fxfa/fm2js/xfa_program.h" |
| 15 #include "xfa/fxfa/parser/xfa_document.h" | 15 #include "xfa/fxfa/parser/xfa_document.h" |
| 16 #include "xfa/fxfa/parser/xfa_localevalue.h" | 16 #include "xfa/fxfa/parser/xfa_localevalue.h" |
| 17 #include "xfa/fxfa/parser/xfa_parser.h" | 17 #include "xfa/fxfa/parser/xfa_parser.h" |
| 18 #include "xfa/fxfa/parser/xfa_parser_imp.h" | 18 #include "xfa/fxfa/parser/xfa_parser_imp.h" |
| 19 #include "xfa/fxfa/parser/xfa_script_imp.h" | 19 #include "xfa/fxfa/parser/xfa_script_imp.h" |
| 20 #include "xfa/fxjse/cfxjse_arguments.h" | 20 #include "xfa/fxjse/cfxjse_arguments.h" |
| 21 #include "xfa/fxjse/class.h" |
| 21 #include "xfa/fxjse/value.h" | 22 #include "xfa/fxjse/value.h" |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 const double kFinancialPrecision = 0.00000001; | 26 const double kFinancialPrecision = 0.00000001; |
| 26 | 27 |
| 27 struct XFA_FMHtmlReserveCode { | 28 struct XFA_FMHtmlReserveCode { |
| 28 uint32_t m_uCode; | 29 uint32_t m_uCode; |
| 29 const FX_WCHAR* m_htmlReserve; | 30 const FX_WCHAR* m_htmlReserve; |
| 30 }; | 31 }; |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 if (argc < 1) { | 537 if (argc < 1) { |
| 537 args.GetReturnValue()->SetNull(); | 538 args.GetReturnValue()->SetNull(); |
| 538 return; | 539 return; |
| 539 } | 540 } |
| 540 | 541 |
| 541 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); | 542 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); |
| 542 uint32_t uCount = 0; | 543 uint32_t uCount = 0; |
| 543 FX_DOUBLE dSum = 0.0; | 544 FX_DOUBLE dSum = 0.0; |
| 544 for (int32_t i = 0; i < argc; i++) { | 545 for (int32_t i = 0; i < argc; i++) { |
| 545 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); | 546 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); |
| 546 if (FXJSE_Value_IsNull(argValue.get())) | 547 if (argValue->IsNull()) |
| 547 continue; | 548 continue; |
| 548 | 549 |
| 549 if (!FXJSE_Value_IsArray(argValue.get())) { | 550 if (!argValue->IsArray()) { |
| 550 dSum += ValueToDouble(pThis, argValue.get()); | 551 dSum += ValueToDouble(pThis, argValue.get()); |
| 551 uCount++; | 552 uCount++; |
| 552 continue; | 553 continue; |
| 553 } | 554 } |
| 554 | 555 |
| 555 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 556 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 556 argValue->GetObjectProperty("length", lengthValue.get()); | 557 argValue->GetObjectProperty("length", lengthValue.get()); |
| 557 int32_t iLength = lengthValue->ToInteger(); | 558 int32_t iLength = lengthValue->ToInteger(); |
| 558 | 559 |
| 559 if (iLength > 2) { | 560 if (iLength > 2) { |
| 560 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 561 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 561 argValue->GetObjectPropertyByIdx(1, propertyValue.get()); | 562 argValue->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 562 | 563 |
| 563 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 564 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 564 if (FXJSE_Value_IsNull(propertyValue.get())) { | 565 if (propertyValue->IsNull()) { |
| 565 for (int32_t j = 2; j < iLength; j++) { | 566 for (int32_t j = 2; j < iLength; j++) { |
| 566 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); | 567 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); |
| 567 std::unique_ptr<CFXJSE_Value> defaultPropValue( | 568 std::unique_ptr<CFXJSE_Value> defaultPropValue( |
| 568 new CFXJSE_Value(pIsolate)); | 569 new CFXJSE_Value(pIsolate)); |
| 569 GetObjectDefaultValue(jsObjectValue.get(), defaultPropValue.get()); | 570 GetObjectDefaultValue(jsObjectValue.get(), defaultPropValue.get()); |
| 570 if (FXJSE_Value_IsNull(defaultPropValue.get())) | 571 if (defaultPropValue->IsNull()) |
| 571 continue; | 572 continue; |
| 572 | 573 |
| 573 dSum += ValueToDouble(pThis, defaultPropValue.get()); | 574 dSum += ValueToDouble(pThis, defaultPropValue.get()); |
| 574 uCount++; | 575 uCount++; |
| 575 } | 576 } |
| 576 } else { | 577 } else { |
| 577 CFX_ByteString propertyStr; | 578 CFX_ByteString propertyStr; |
| 578 propertyValue->ToString(propertyStr); | 579 propertyValue->ToString(propertyStr); |
| 579 for (int32_t j = 2; j < iLength; j++) { | 580 for (int32_t j = 2; j < iLength; j++) { |
| 580 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); | 581 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); |
| 581 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 582 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 582 new CFXJSE_Value(pIsolate)); | 583 new CFXJSE_Value(pIsolate)); |
| 583 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), | 584 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), |
| 584 newPropertyValue.get()); | 585 newPropertyValue.get()); |
| 585 if (FXJSE_Value_IsNull(newPropertyValue.get())) | 586 if (newPropertyValue->IsNull()) |
| 586 continue; | 587 continue; |
| 587 | 588 |
| 588 dSum += ValueToDouble(pThis, newPropertyValue.get()); | 589 dSum += ValueToDouble(pThis, newPropertyValue.get()); |
| 589 uCount++; | 590 uCount++; |
| 590 } | 591 } |
| 591 } | 592 } |
| 592 } | 593 } |
| 593 } | 594 } |
| 594 if (uCount == 0) { | 595 if (uCount == 0) { |
| 595 args.GetReturnValue()->SetNull(); | 596 args.GetReturnValue()->SetNull(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 621 | 622 |
| 622 // static | 623 // static |
| 623 void CXFA_FM2JSContext::Count(CFXJSE_Value* pThis, | 624 void CXFA_FM2JSContext::Count(CFXJSE_Value* pThis, |
| 624 const CFX_ByteStringC& szFuncName, | 625 const CFX_ByteStringC& szFuncName, |
| 625 CFXJSE_Arguments& args) { | 626 CFXJSE_Arguments& args) { |
| 626 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); | 627 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); |
| 627 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 628 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 628 int32_t iCount = 0; | 629 int32_t iCount = 0; |
| 629 for (int32_t i = 0; i < args.GetLength(); i++) { | 630 for (int32_t i = 0; i < args.GetLength(); i++) { |
| 630 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); | 631 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); |
| 631 if (FXJSE_Value_IsNull(argValue.get())) | 632 if (argValue->IsNull()) |
| 632 continue; | 633 continue; |
| 633 | 634 |
| 634 if (FXJSE_Value_IsArray(argValue.get())) { | 635 if (argValue->IsArray()) { |
| 635 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 636 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 636 argValue->GetObjectProperty("length", lengthValue.get()); | 637 argValue->GetObjectProperty("length", lengthValue.get()); |
| 637 | 638 |
| 638 int32_t iLength = lengthValue->ToInteger(); | 639 int32_t iLength = lengthValue->ToInteger(); |
| 639 if (iLength <= 2) { | 640 if (iLength <= 2) { |
| 640 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); | 641 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); |
| 641 return; | 642 return; |
| 642 } | 643 } |
| 643 | 644 |
| 644 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 645 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 645 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 646 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 646 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 647 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 647 new CFXJSE_Value(pIsolate)); | 648 new CFXJSE_Value(pIsolate)); |
| 648 argValue->GetObjectPropertyByIdx(1, propertyValue.get()); | 649 argValue->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 649 argValue->GetObjectPropertyByIdx(2, jsObjectValue.get()); | 650 argValue->GetObjectPropertyByIdx(2, jsObjectValue.get()); |
| 650 if (FXJSE_Value_IsNull(propertyValue.get())) { | 651 if (propertyValue->IsNull()) { |
| 651 for (int32_t j = 2; j < iLength; j++) { | 652 for (int32_t j = 2; j < iLength; j++) { |
| 652 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); | 653 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); |
| 653 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 654 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
| 654 if (!FXJSE_Value_IsNull(newPropertyValue.get())) | 655 if (!newPropertyValue->IsNull()) |
| 655 iCount++; | 656 iCount++; |
| 656 } | 657 } |
| 657 } else { | 658 } else { |
| 658 CFX_ByteString propertyStr; | 659 CFX_ByteString propertyStr; |
| 659 propertyValue->ToString(propertyStr); | 660 propertyValue->ToString(propertyStr); |
| 660 for (int32_t j = 2; j < iLength; j++) { | 661 for (int32_t j = 2; j < iLength; j++) { |
| 661 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); | 662 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); |
| 662 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), | 663 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), |
| 663 newPropertyValue.get()); | 664 newPropertyValue.get()); |
| 664 iCount += (FXJSE_Value_IsNull(newPropertyValue.get()) ? 0 : 1); | 665 iCount += newPropertyValue->IsNull() ? 0 : 1; |
| 665 } | 666 } |
| 666 } | 667 } |
| 667 } else if (FXJSE_Value_IsObject(argValue.get())) { | 668 } else if (argValue->IsObject()) { |
| 668 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 669 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 669 new CFXJSE_Value(pIsolate)); | 670 new CFXJSE_Value(pIsolate)); |
| 670 GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); | 671 GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); |
| 671 if (!FXJSE_Value_IsNull(newPropertyValue.get())) | 672 if (!newPropertyValue->IsNull()) |
| 672 iCount++; | 673 iCount++; |
| 673 } else { | 674 } else { |
| 674 iCount++; | 675 iCount++; |
| 675 } | 676 } |
| 676 } | 677 } |
| 677 args.GetReturnValue()->SetInteger(iCount); | 678 args.GetReturnValue()->SetInteger(iCount); |
| 678 } | 679 } |
| 679 | 680 |
| 680 // static | 681 // static |
| 681 void CXFA_FM2JSContext::Floor(CFXJSE_Value* pThis, | 682 void CXFA_FM2JSContext::Floor(CFXJSE_Value* pThis, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 700 // static | 701 // static |
| 701 void CXFA_FM2JSContext::Max(CFXJSE_Value* pThis, | 702 void CXFA_FM2JSContext::Max(CFXJSE_Value* pThis, |
| 702 const CFX_ByteStringC& szFuncName, | 703 const CFX_ByteStringC& szFuncName, |
| 703 CFXJSE_Arguments& args) { | 704 CFXJSE_Arguments& args) { |
| 704 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); | 705 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); |
| 705 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 706 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 706 uint32_t uCount = 0; | 707 uint32_t uCount = 0; |
| 707 FX_DOUBLE dMaxValue = 0.0; | 708 FX_DOUBLE dMaxValue = 0.0; |
| 708 for (int32_t i = 0; i < args.GetLength(); i++) { | 709 for (int32_t i = 0; i < args.GetLength(); i++) { |
| 709 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); | 710 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); |
| 710 if (FXJSE_Value_IsNull(argValue.get())) | 711 if (argValue->IsNull()) |
| 711 continue; | 712 continue; |
| 712 | 713 |
| 713 if (FXJSE_Value_IsArray(argValue.get())) { | 714 if (argValue->IsArray()) { |
| 714 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 715 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 715 argValue->GetObjectProperty("length", lengthValue.get()); | 716 argValue->GetObjectProperty("length", lengthValue.get()); |
| 716 int32_t iLength = lengthValue->ToInteger(); | 717 int32_t iLength = lengthValue->ToInteger(); |
| 717 if (iLength <= 2) { | 718 if (iLength <= 2) { |
| 718 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); | 719 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); |
| 719 return; | 720 return; |
| 720 } | 721 } |
| 721 | 722 |
| 722 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 723 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 723 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 724 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 724 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 725 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 725 new CFXJSE_Value(pIsolate)); | 726 new CFXJSE_Value(pIsolate)); |
| 726 argValue->GetObjectPropertyByIdx(1, propertyValue.get()); | 727 argValue->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 727 argValue->GetObjectPropertyByIdx(2, jsObjectValue.get()); | 728 argValue->GetObjectPropertyByIdx(2, jsObjectValue.get()); |
| 728 if (FXJSE_Value_IsNull(propertyValue.get())) { | 729 if (propertyValue->IsNull()) { |
| 729 for (int32_t j = 2; j < iLength; j++) { | 730 for (int32_t j = 2; j < iLength; j++) { |
| 730 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); | 731 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); |
| 731 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 732 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
| 732 if (FXJSE_Value_IsNull(newPropertyValue.get())) | 733 if (newPropertyValue->IsNull()) |
| 733 continue; | 734 continue; |
| 734 | 735 |
| 735 uCount++; | 736 uCount++; |
| 736 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); | 737 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); |
| 737 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); | 738 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); |
| 738 } | 739 } |
| 739 } else { | 740 } else { |
| 740 CFX_ByteString propertyStr; | 741 CFX_ByteString propertyStr; |
| 741 propertyValue->ToString(propertyStr); | 742 propertyValue->ToString(propertyStr); |
| 742 for (int32_t j = 2; j < iLength; j++) { | 743 for (int32_t j = 2; j < iLength; j++) { |
| 743 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); | 744 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); |
| 744 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), | 745 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), |
| 745 newPropertyValue.get()); | 746 newPropertyValue.get()); |
| 746 if (FXJSE_Value_IsNull(newPropertyValue.get())) | 747 if (newPropertyValue->IsNull()) |
| 747 continue; | 748 continue; |
| 748 | 749 |
| 749 uCount++; | 750 uCount++; |
| 750 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); | 751 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); |
| 751 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); | 752 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); |
| 752 } | 753 } |
| 753 } | 754 } |
| 754 } else if (FXJSE_Value_IsObject(argValue.get())) { | 755 } else if (argValue->IsObject()) { |
| 755 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 756 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 756 new CFXJSE_Value(pIsolate)); | 757 new CFXJSE_Value(pIsolate)); |
| 757 GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); | 758 GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); |
| 758 if (FXJSE_Value_IsNull(newPropertyValue.get())) | 759 if (newPropertyValue->IsNull()) |
| 759 continue; | 760 continue; |
| 760 | 761 |
| 761 uCount++; | 762 uCount++; |
| 762 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); | 763 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); |
| 763 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); | 764 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); |
| 764 } else { | 765 } else { |
| 765 uCount++; | 766 uCount++; |
| 766 FX_DOUBLE dValue = ValueToDouble(pThis, argValue.get()); | 767 FX_DOUBLE dValue = ValueToDouble(pThis, argValue.get()); |
| 767 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); | 768 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); |
| 768 } | 769 } |
| 769 } | 770 } |
| 770 if (uCount == 0) { | 771 if (uCount == 0) { |
| 771 args.GetReturnValue()->SetNull(); | 772 args.GetReturnValue()->SetNull(); |
| 772 return; | 773 return; |
| 773 } | 774 } |
| 774 | 775 |
| 775 args.GetReturnValue()->SetDouble(dMaxValue); | 776 args.GetReturnValue()->SetDouble(dMaxValue); |
| 776 } | 777 } |
| 777 | 778 |
| 778 // static | 779 // static |
| 779 void CXFA_FM2JSContext::Min(CFXJSE_Value* pThis, | 780 void CXFA_FM2JSContext::Min(CFXJSE_Value* pThis, |
| 780 const CFX_ByteStringC& szFuncName, | 781 const CFX_ByteStringC& szFuncName, |
| 781 CFXJSE_Arguments& args) { | 782 CFXJSE_Arguments& args) { |
| 782 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); | 783 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); |
| 783 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 784 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 784 uint32_t uCount = 0; | 785 uint32_t uCount = 0; |
| 785 FX_DOUBLE dMinValue = 0.0; | 786 FX_DOUBLE dMinValue = 0.0; |
| 786 for (int32_t i = 0; i < args.GetLength(); i++) { | 787 for (int32_t i = 0; i < args.GetLength(); i++) { |
| 787 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); | 788 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); |
| 788 if (FXJSE_Value_IsNull(argValue.get())) | 789 if (argValue->IsNull()) |
| 789 continue; | 790 continue; |
| 790 | 791 |
| 791 if (FXJSE_Value_IsArray(argValue.get())) { | 792 if (argValue->IsArray()) { |
| 792 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 793 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 793 argValue->GetObjectProperty("length", lengthValue.get()); | 794 argValue->GetObjectProperty("length", lengthValue.get()); |
| 794 int32_t iLength = lengthValue->ToInteger(); | 795 int32_t iLength = lengthValue->ToInteger(); |
| 795 if (iLength <= 2) { | 796 if (iLength <= 2) { |
| 796 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); | 797 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); |
| 797 return; | 798 return; |
| 798 } | 799 } |
| 799 | 800 |
| 800 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 801 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 801 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 802 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 802 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 803 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 803 new CFXJSE_Value(pIsolate)); | 804 new CFXJSE_Value(pIsolate)); |
| 804 argValue->GetObjectPropertyByIdx(1, propertyValue.get()); | 805 argValue->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 805 argValue->GetObjectPropertyByIdx(2, jsObjectValue.get()); | 806 argValue->GetObjectPropertyByIdx(2, jsObjectValue.get()); |
| 806 if (FXJSE_Value_IsNull(propertyValue.get())) { | 807 if (propertyValue->IsNull()) { |
| 807 for (int32_t j = 2; j < iLength; j++) { | 808 for (int32_t j = 2; j < iLength; j++) { |
| 808 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); | 809 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); |
| 809 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 810 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
| 810 if (FXJSE_Value_IsNull(newPropertyValue.get())) | 811 if (newPropertyValue->IsNull()) |
| 811 continue; | 812 continue; |
| 812 | 813 |
| 813 uCount++; | 814 uCount++; |
| 814 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); | 815 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); |
| 815 dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue); | 816 dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue); |
| 816 } | 817 } |
| 817 } else { | 818 } else { |
| 818 CFX_ByteString propertyStr; | 819 CFX_ByteString propertyStr; |
| 819 propertyValue->ToString(propertyStr); | 820 propertyValue->ToString(propertyStr); |
| 820 for (int32_t j = 2; j < iLength; j++) { | 821 for (int32_t j = 2; j < iLength; j++) { |
| 821 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); | 822 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); |
| 822 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), | 823 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), |
| 823 newPropertyValue.get()); | 824 newPropertyValue.get()); |
| 824 if (FXJSE_Value_IsNull(newPropertyValue.get())) | 825 if (newPropertyValue->IsNull()) |
| 825 continue; | 826 continue; |
| 826 | 827 |
| 827 uCount++; | 828 uCount++; |
| 828 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); | 829 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); |
| 829 dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue); | 830 dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue); |
| 830 } | 831 } |
| 831 } | 832 } |
| 832 } else if (FXJSE_Value_IsObject(argValue.get())) { | 833 } else if (argValue->IsObject()) { |
| 833 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 834 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 834 new CFXJSE_Value(pIsolate)); | 835 new CFXJSE_Value(pIsolate)); |
| 835 GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); | 836 GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); |
| 836 if (FXJSE_Value_IsNull(newPropertyValue.get())) | 837 if (newPropertyValue->IsNull()) |
| 837 continue; | 838 continue; |
| 838 | 839 |
| 839 uCount++; | 840 uCount++; |
| 840 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); | 841 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); |
| 841 dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue); | 842 dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue); |
| 842 } else { | 843 } else { |
| 843 uCount++; | 844 uCount++; |
| 844 FX_DOUBLE dValue = ValueToDouble(pThis, argValue.get()); | 845 FX_DOUBLE dValue = ValueToDouble(pThis, argValue.get()); |
| 845 dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue); | 846 dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue); |
| 846 } | 847 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 858 const CFX_ByteStringC& szFuncName, | 859 const CFX_ByteStringC& szFuncName, |
| 859 CFXJSE_Arguments& args) { | 860 CFXJSE_Arguments& args) { |
| 860 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); | 861 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); |
| 861 if (args.GetLength() != 2) { | 862 if (args.GetLength() != 2) { |
| 862 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Mod"); | 863 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Mod"); |
| 863 return; | 864 return; |
| 864 } | 865 } |
| 865 | 866 |
| 866 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 867 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 867 std::unique_ptr<CFXJSE_Value> argTwo = args.GetValue(1); | 868 std::unique_ptr<CFXJSE_Value> argTwo = args.GetValue(1); |
| 868 if (FXJSE_Value_IsNull(argOne.get()) || FXJSE_Value_IsNull(argTwo.get())) { | 869 if (argOne->IsNull() || argTwo->IsNull()) { |
| 869 args.GetReturnValue()->SetNull(); | 870 args.GetReturnValue()->SetNull(); |
| 870 return; | 871 return; |
| 871 } | 872 } |
| 872 | 873 |
| 873 bool argOneResult; | 874 bool argOneResult; |
| 874 FX_DOUBLE dDividend = ExtractDouble(pThis, argOne.get(), &argOneResult); | 875 FX_DOUBLE dDividend = ExtractDouble(pThis, argOne.get(), &argOneResult); |
| 875 bool argTwoResult; | 876 bool argTwoResult; |
| 876 FX_DOUBLE dDivisor = ExtractDouble(pThis, argTwo.get(), &argTwoResult); | 877 FX_DOUBLE dDivisor = ExtractDouble(pThis, argTwo.get(), &argTwoResult); |
| 877 if (!argOneResult || !argTwoResult) { | 878 if (!argOneResult || !argTwoResult) { |
| 878 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); | 879 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 893 const CFX_ByteStringC& szFuncName, | 894 const CFX_ByteStringC& szFuncName, |
| 894 CFXJSE_Arguments& args) { | 895 CFXJSE_Arguments& args) { |
| 895 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); | 896 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); |
| 896 int32_t argc = args.GetLength(); | 897 int32_t argc = args.GetLength(); |
| 897 if (argc < 1 || argc > 2) { | 898 if (argc < 1 || argc > 2) { |
| 898 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Round"); | 899 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Round"); |
| 899 return; | 900 return; |
| 900 } | 901 } |
| 901 | 902 |
| 902 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 903 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 903 if (FXJSE_Value_IsNull(argOne.get())) { | 904 if (argOne->IsNull()) { |
| 904 args.GetReturnValue()->SetNull(); | 905 args.GetReturnValue()->SetNull(); |
| 905 return; | 906 return; |
| 906 } | 907 } |
| 907 | 908 |
| 908 bool dValueRet; | 909 bool dValueRet; |
| 909 FX_DOUBLE dValue = ExtractDouble(pThis, argOne.get(), &dValueRet); | 910 FX_DOUBLE dValue = ExtractDouble(pThis, argOne.get(), &dValueRet); |
| 910 if (!dValueRet) { | 911 if (!dValueRet) { |
| 911 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); | 912 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); |
| 912 return; | 913 return; |
| 913 } | 914 } |
| 914 | 915 |
| 915 uint8_t uPrecision = 0; | 916 uint8_t uPrecision = 0; |
| 916 if (argc > 1) { | 917 if (argc > 1) { |
| 917 std::unique_ptr<CFXJSE_Value> argTwo = args.GetValue(1); | 918 std::unique_ptr<CFXJSE_Value> argTwo = args.GetValue(1); |
| 918 if (FXJSE_Value_IsNull(argTwo.get())) { | 919 if (argTwo->IsNull()) { |
| 919 args.GetReturnValue()->SetNull(); | 920 args.GetReturnValue()->SetNull(); |
| 920 return; | 921 return; |
| 921 } | 922 } |
| 922 | 923 |
| 923 bool dPrecisionRet; | 924 bool dPrecisionRet; |
| 924 FX_DOUBLE dPrecision = ExtractDouble(pThis, argTwo.get(), &dPrecisionRet); | 925 FX_DOUBLE dPrecision = ExtractDouble(pThis, argTwo.get(), &dPrecisionRet); |
| 925 if (!dPrecisionRet) { | 926 if (!dPrecisionRet) { |
| 926 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); | 927 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); |
| 927 return; | 928 return; |
| 928 } | 929 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 945 args.GetReturnValue()->SetNull(); | 946 args.GetReturnValue()->SetNull(); |
| 946 return; | 947 return; |
| 947 } | 948 } |
| 948 | 949 |
| 949 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); | 950 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); |
| 950 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 951 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 951 uint32_t uCount = 0; | 952 uint32_t uCount = 0; |
| 952 FX_DOUBLE dSum = 0.0; | 953 FX_DOUBLE dSum = 0.0; |
| 953 for (int32_t i = 0; i < argc; i++) { | 954 for (int32_t i = 0; i < argc; i++) { |
| 954 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); | 955 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); |
| 955 if (FXJSE_Value_IsNull(argValue.get())) | 956 if (argValue->IsNull()) |
| 956 continue; | 957 continue; |
| 957 | 958 |
| 958 if (FXJSE_Value_IsArray(argValue.get())) { | 959 if (argValue->IsArray()) { |
| 959 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 960 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 960 argValue->GetObjectProperty("length", lengthValue.get()); | 961 argValue->GetObjectProperty("length", lengthValue.get()); |
| 961 int32_t iLength = lengthValue->ToInteger(); | 962 int32_t iLength = lengthValue->ToInteger(); |
| 962 if (iLength <= 2) { | 963 if (iLength <= 2) { |
| 963 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); | 964 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); |
| 964 return; | 965 return; |
| 965 } | 966 } |
| 966 | 967 |
| 967 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 968 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 968 argValue->GetObjectPropertyByIdx(1, propertyValue.get()); | 969 argValue->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 969 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 970 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 970 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 971 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 971 new CFXJSE_Value(pIsolate)); | 972 new CFXJSE_Value(pIsolate)); |
| 972 if (FXJSE_Value_IsNull(propertyValue.get())) { | 973 if (propertyValue->IsNull()) { |
| 973 for (int32_t j = 2; j < iLength; j++) { | 974 for (int32_t j = 2; j < iLength; j++) { |
| 974 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); | 975 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); |
| 975 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 976 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
| 976 if (FXJSE_Value_IsNull(newPropertyValue.get())) | 977 if (newPropertyValue->IsNull()) |
| 977 continue; | 978 continue; |
| 978 | 979 |
| 979 dSum += ValueToDouble(pThis, jsObjectValue.get()); | 980 dSum += ValueToDouble(pThis, jsObjectValue.get()); |
| 980 uCount++; | 981 uCount++; |
| 981 } | 982 } |
| 982 } else { | 983 } else { |
| 983 CFX_ByteString propertyStr; | 984 CFX_ByteString propertyStr; |
| 984 propertyValue->ToString(propertyStr); | 985 propertyValue->ToString(propertyStr); |
| 985 for (int32_t j = 2; j < iLength; j++) { | 986 for (int32_t j = 2; j < iLength; j++) { |
| 986 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); | 987 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); |
| 987 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), | 988 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), |
| 988 newPropertyValue.get()); | 989 newPropertyValue.get()); |
| 989 if (FXJSE_Value_IsNull(newPropertyValue.get())) | 990 if (newPropertyValue->IsNull()) |
| 990 continue; | 991 continue; |
| 991 | 992 |
| 992 dSum += ValueToDouble(pThis, newPropertyValue.get()); | 993 dSum += ValueToDouble(pThis, newPropertyValue.get()); |
| 993 uCount++; | 994 uCount++; |
| 994 } | 995 } |
| 995 } | 996 } |
| 996 } else if (FXJSE_Value_IsObject(argValue.get())) { | 997 } else if (argValue->IsObject()) { |
| 997 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 998 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 998 new CFXJSE_Value(pIsolate)); | 999 new CFXJSE_Value(pIsolate)); |
| 999 GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); | 1000 GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); |
| 1000 if (FXJSE_Value_IsNull(newPropertyValue.get())) | 1001 if (newPropertyValue->IsNull()) |
| 1001 continue; | 1002 continue; |
| 1002 | 1003 |
| 1003 dSum += ValueToDouble(pThis, argValue.get()); | 1004 dSum += ValueToDouble(pThis, argValue.get()); |
| 1004 uCount++; | 1005 uCount++; |
| 1005 } else { | 1006 } else { |
| 1006 dSum += ValueToDouble(pThis, argValue.get()); | 1007 dSum += ValueToDouble(pThis, argValue.get()); |
| 1007 uCount++; | 1008 uCount++; |
| 1008 } | 1009 } |
| 1009 } | 1010 } |
| 1010 if (uCount == 0) { | 1011 if (uCount == 0) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1098 int32_t argc = args.GetLength(); | 1099 int32_t argc = args.GetLength(); |
| 1099 if (argc > 2) { | 1100 if (argc > 2) { |
| 1100 ToJSContext(pThis, nullptr) | 1101 ToJSContext(pThis, nullptr) |
| 1101 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Date2Num"); | 1102 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Date2Num"); |
| 1102 return; | 1103 return; |
| 1103 } | 1104 } |
| 1104 | 1105 |
| 1105 int32_t iStyle = 0; | 1106 int32_t iStyle = 0; |
| 1106 if (argc > 0) { | 1107 if (argc > 0) { |
| 1107 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0); | 1108 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0); |
| 1108 if (FXJSE_Value_IsNull(argStyle.get())) { | 1109 if (argStyle->IsNull()) { |
| 1109 args.GetReturnValue()->SetNull(); | 1110 args.GetReturnValue()->SetNull(); |
| 1110 return; | 1111 return; |
| 1111 } | 1112 } |
| 1112 | 1113 |
| 1113 iStyle = (int32_t)ValueToFloat(pThis, argStyle.get()); | 1114 iStyle = (int32_t)ValueToFloat(pThis, argStyle.get()); |
| 1114 if (iStyle < 0 || iStyle > 4) | 1115 if (iStyle < 0 || iStyle > 4) |
| 1115 iStyle = 0; | 1116 iStyle = 0; |
| 1116 } | 1117 } |
| 1117 | 1118 |
| 1118 CFX_ByteString szLocal; | 1119 CFX_ByteString szLocal; |
| 1119 if (argc > 1) { | 1120 if (argc > 1) { |
| 1120 std::unique_ptr<CFXJSE_Value> argLocal = GetSimpleValue(pThis, args, 1); | 1121 std::unique_ptr<CFXJSE_Value> argLocal = GetSimpleValue(pThis, args, 1); |
| 1121 if (FXJSE_Value_IsNull(argLocal.get())) { | 1122 if (argLocal->IsNull()) { |
| 1122 args.GetReturnValue()->SetNull(); | 1123 args.GetReturnValue()->SetNull(); |
| 1123 return; | 1124 return; |
| 1124 } | 1125 } |
| 1125 ValueToUTF8String(argLocal.get(), szLocal); | 1126 ValueToUTF8String(argLocal.get(), szLocal); |
| 1126 } | 1127 } |
| 1127 | 1128 |
| 1128 CFX_ByteString formatStr; | 1129 CFX_ByteString formatStr; |
| 1129 GetStandardDateFormat(pThis, iStyle, szLocal.AsStringC(), formatStr); | 1130 GetStandardDateFormat(pThis, iStyle, szLocal.AsStringC(), formatStr); |
| 1130 args.GetReturnValue()->SetString(formatStr.AsStringC()); | 1131 args.GetReturnValue()->SetString(formatStr.AsStringC()); |
| 1131 } | 1132 } |
| 1132 | 1133 |
| 1133 // static | 1134 // static |
| 1134 void CXFA_FM2JSContext::IsoDate2Num(CFXJSE_Value* pThis, | 1135 void CXFA_FM2JSContext::IsoDate2Num(CFXJSE_Value* pThis, |
| 1135 const CFX_ByteStringC& szFuncName, | 1136 const CFX_ByteStringC& szFuncName, |
| 1136 CFXJSE_Arguments& args) { | 1137 CFXJSE_Arguments& args) { |
| 1137 if (args.GetLength() != 1) { | 1138 if (args.GetLength() != 1) { |
| 1138 ToJSContext(pThis, nullptr) | 1139 ToJSContext(pThis, nullptr) |
| 1139 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"IsoDate2Num"); | 1140 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"IsoDate2Num"); |
| 1140 return; | 1141 return; |
| 1141 } | 1142 } |
| 1142 | 1143 |
| 1143 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 1144 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 1144 if (FXJSE_Value_IsNull(argOne.get())) { | 1145 if (argOne->IsNull()) { |
| 1145 args.GetReturnValue()->SetNull(); | 1146 args.GetReturnValue()->SetNull(); |
| 1146 return; | 1147 return; |
| 1147 } | 1148 } |
| 1148 | 1149 |
| 1149 CFX_ByteString szArgString; | 1150 CFX_ByteString szArgString; |
| 1150 ValueToUTF8String(argOne.get(), szArgString); | 1151 ValueToUTF8String(argOne.get(), szArgString); |
| 1151 args.GetReturnValue()->SetInteger(DateString2Num(szArgString.AsStringC())); | 1152 args.GetReturnValue()->SetInteger(DateString2Num(szArgString.AsStringC())); |
| 1152 } | 1153 } |
| 1153 | 1154 |
| 1154 // static | 1155 // static |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 int32_t argc = args.GetLength(); | 1218 int32_t argc = args.GetLength(); |
| 1218 if (argc > 2) { | 1219 if (argc > 2) { |
| 1219 ToJSContext(pThis, nullptr) | 1220 ToJSContext(pThis, nullptr) |
| 1220 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"LocalDateFmt"); | 1221 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"LocalDateFmt"); |
| 1221 return; | 1222 return; |
| 1222 } | 1223 } |
| 1223 | 1224 |
| 1224 int32_t iStyle = 0; | 1225 int32_t iStyle = 0; |
| 1225 if (argc > 0) { | 1226 if (argc > 0) { |
| 1226 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0); | 1227 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0); |
| 1227 if (FXJSE_Value_IsNull(argStyle.get())) { | 1228 if (argStyle->IsNull()) { |
| 1228 args.GetReturnValue()->SetNull(); | 1229 args.GetReturnValue()->SetNull(); |
| 1229 return; | 1230 return; |
| 1230 } | 1231 } |
| 1231 iStyle = (int32_t)ValueToFloat(pThis, argStyle.get()); | 1232 iStyle = (int32_t)ValueToFloat(pThis, argStyle.get()); |
| 1232 if (iStyle > 4 || iStyle < 0) | 1233 if (iStyle > 4 || iStyle < 0) |
| 1233 iStyle = 0; | 1234 iStyle = 0; |
| 1234 } | 1235 } |
| 1235 | 1236 |
| 1236 CFX_ByteString szLocal; | 1237 CFX_ByteString szLocal; |
| 1237 if (argc > 1) { | 1238 if (argc > 1) { |
| 1238 std::unique_ptr<CFXJSE_Value> argLocal = GetSimpleValue(pThis, args, 1); | 1239 std::unique_ptr<CFXJSE_Value> argLocal = GetSimpleValue(pThis, args, 1); |
| 1239 if (FXJSE_Value_IsNull(argLocal.get())) { | 1240 if (argLocal->IsNull()) { |
| 1240 args.GetReturnValue()->SetNull(); | 1241 args.GetReturnValue()->SetNull(); |
| 1241 return; | 1242 return; |
| 1242 } | 1243 } |
| 1243 ValueToUTF8String(argLocal.get(), szLocal); | 1244 ValueToUTF8String(argLocal.get(), szLocal); |
| 1244 } | 1245 } |
| 1245 | 1246 |
| 1246 CFX_ByteString formatStr; | 1247 CFX_ByteString formatStr; |
| 1247 GetLocalDateFormat(pThis, iStyle, szLocal.AsStringC(), formatStr, FALSE); | 1248 GetLocalDateFormat(pThis, iStyle, szLocal.AsStringC(), formatStr, FALSE); |
| 1248 args.GetReturnValue()->SetString(formatStr.AsStringC()); | 1249 args.GetReturnValue()->SetString(formatStr.AsStringC()); |
| 1249 } | 1250 } |
| 1250 | 1251 |
| 1251 // static | 1252 // static |
| 1252 void CXFA_FM2JSContext::LocalTimeFmt(CFXJSE_Value* pThis, | 1253 void CXFA_FM2JSContext::LocalTimeFmt(CFXJSE_Value* pThis, |
| 1253 const CFX_ByteStringC& szFuncName, | 1254 const CFX_ByteStringC& szFuncName, |
| 1254 CFXJSE_Arguments& args) { | 1255 CFXJSE_Arguments& args) { |
| 1255 int32_t argc = args.GetLength(); | 1256 int32_t argc = args.GetLength(); |
| 1256 if (argc > 2) { | 1257 if (argc > 2) { |
| 1257 ToJSContext(pThis, nullptr) | 1258 ToJSContext(pThis, nullptr) |
| 1258 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"LocalTimeFmt"); | 1259 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"LocalTimeFmt"); |
| 1259 return; | 1260 return; |
| 1260 } | 1261 } |
| 1261 | 1262 |
| 1262 int32_t iStyle = 0; | 1263 int32_t iStyle = 0; |
| 1263 if (argc > 0) { | 1264 if (argc > 0) { |
| 1264 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0); | 1265 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0); |
| 1265 if (FXJSE_Value_IsNull(argStyle.get())) { | 1266 if (argStyle->IsNull()) { |
| 1266 args.GetReturnValue()->SetNull(); | 1267 args.GetReturnValue()->SetNull(); |
| 1267 return; | 1268 return; |
| 1268 } | 1269 } |
| 1269 iStyle = (int32_t)ValueToFloat(pThis, argStyle.get()); | 1270 iStyle = (int32_t)ValueToFloat(pThis, argStyle.get()); |
| 1270 if (iStyle > 4 || iStyle < 0) | 1271 if (iStyle > 4 || iStyle < 0) |
| 1271 iStyle = 0; | 1272 iStyle = 0; |
| 1272 } | 1273 } |
| 1273 | 1274 |
| 1274 CFX_ByteString szLocal; | 1275 CFX_ByteString szLocal; |
| 1275 if (argc > 1) { | 1276 if (argc > 1) { |
| 1276 std::unique_ptr<CFXJSE_Value> argLocal = GetSimpleValue(pThis, args, 1); | 1277 std::unique_ptr<CFXJSE_Value> argLocal = GetSimpleValue(pThis, args, 1); |
| 1277 if (FXJSE_Value_IsNull(argLocal.get())) { | 1278 if (argLocal->IsNull()) { |
| 1278 args.GetReturnValue()->SetNull(); | 1279 args.GetReturnValue()->SetNull(); |
| 1279 return; | 1280 return; |
| 1280 } | 1281 } |
| 1281 ValueToUTF8String(argLocal.get(), szLocal); | 1282 ValueToUTF8String(argLocal.get(), szLocal); |
| 1282 } | 1283 } |
| 1283 | 1284 |
| 1284 CFX_ByteString formatStr; | 1285 CFX_ByteString formatStr; |
| 1285 GetLocalTimeFormat(pThis, iStyle, szLocal.AsStringC(), formatStr, FALSE); | 1286 GetLocalTimeFormat(pThis, iStyle, szLocal.AsStringC(), formatStr, FALSE); |
| 1286 args.GetReturnValue()->SetString(formatStr.AsStringC()); | 1287 args.GetReturnValue()->SetString(formatStr.AsStringC()); |
| 1287 } | 1288 } |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1433 const CFX_ByteStringC& szFuncName, | 1434 const CFX_ByteStringC& szFuncName, |
| 1434 CFXJSE_Arguments& args) { | 1435 CFXJSE_Arguments& args) { |
| 1435 int32_t argc = args.GetLength(); | 1436 int32_t argc = args.GetLength(); |
| 1436 if (argc < 1 || argc > 3) { | 1437 if (argc < 1 || argc > 3) { |
| 1437 ToJSContext(pThis, nullptr) | 1438 ToJSContext(pThis, nullptr) |
| 1438 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2GMTime"); | 1439 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2GMTime"); |
| 1439 return; | 1440 return; |
| 1440 } | 1441 } |
| 1441 | 1442 |
| 1442 std::unique_ptr<CFXJSE_Value> timeValue = GetSimpleValue(pThis, args, 0); | 1443 std::unique_ptr<CFXJSE_Value> timeValue = GetSimpleValue(pThis, args, 0); |
| 1443 if (FXJSE_Value_IsNull(timeValue.get())) { | 1444 if (timeValue->IsNull()) { |
| 1444 args.GetReturnValue()->SetNull(); | 1445 args.GetReturnValue()->SetNull(); |
| 1445 return; | 1446 return; |
| 1446 } | 1447 } |
| 1447 int32_t iTime = (int32_t)ValueToFloat(pThis, timeValue.get()); | 1448 int32_t iTime = (int32_t)ValueToFloat(pThis, timeValue.get()); |
| 1448 if (FXSYS_abs(iTime) < 1.0) { | 1449 if (FXSYS_abs(iTime) < 1.0) { |
| 1449 args.GetReturnValue()->SetNull(); | 1450 args.GetReturnValue()->SetNull(); |
| 1450 return; | 1451 return; |
| 1451 } | 1452 } |
| 1452 | 1453 |
| 1453 CFX_ByteString formatString; | 1454 CFX_ByteString formatString; |
| 1454 if (argc > 1) { | 1455 if (argc > 1) { |
| 1455 std::unique_ptr<CFXJSE_Value> formatValue = GetSimpleValue(pThis, args, 1); | 1456 std::unique_ptr<CFXJSE_Value> formatValue = GetSimpleValue(pThis, args, 1); |
| 1456 if (FXJSE_Value_IsNull(formatValue.get())) { | 1457 if (formatValue->IsNull()) { |
| 1457 args.GetReturnValue()->SetNull(); | 1458 args.GetReturnValue()->SetNull(); |
| 1458 return; | 1459 return; |
| 1459 } | 1460 } |
| 1460 ValueToUTF8String(formatValue.get(), formatString); | 1461 ValueToUTF8String(formatValue.get(), formatString); |
| 1461 } | 1462 } |
| 1462 | 1463 |
| 1463 CFX_ByteString localString; | 1464 CFX_ByteString localString; |
| 1464 if (argc > 2) { | 1465 if (argc > 2) { |
| 1465 std::unique_ptr<CFXJSE_Value> localValue = GetSimpleValue(pThis, args, 2); | 1466 std::unique_ptr<CFXJSE_Value> localValue = GetSimpleValue(pThis, args, 2); |
| 1466 if (FXJSE_Value_IsNull(localValue.get())) { | 1467 if (localValue->IsNull()) { |
| 1467 args.GetReturnValue()->SetNull(); | 1468 args.GetReturnValue()->SetNull(); |
| 1468 return; | 1469 return; |
| 1469 } | 1470 } |
| 1470 ValueToUTF8String(localValue.get(), localString); | 1471 ValueToUTF8String(localValue.get(), localString); |
| 1471 } | 1472 } |
| 1472 | 1473 |
| 1473 CFX_ByteString szGMTTimeString; | 1474 CFX_ByteString szGMTTimeString; |
| 1474 Num2AllTime(pThis, iTime, formatString.AsStringC(), localString.AsStringC(), | 1475 Num2AllTime(pThis, iTime, formatString.AsStringC(), localString.AsStringC(), |
| 1475 TRUE, szGMTTimeString); | 1476 TRUE, szGMTTimeString); |
| 1476 args.GetReturnValue()->SetString(szGMTTimeString.AsStringC()); | 1477 args.GetReturnValue()->SetString(szGMTTimeString.AsStringC()); |
| 1477 } | 1478 } |
| 1478 | 1479 |
| 1479 // static | 1480 // static |
| 1480 void CXFA_FM2JSContext::Num2Time(CFXJSE_Value* pThis, | 1481 void CXFA_FM2JSContext::Num2Time(CFXJSE_Value* pThis, |
| 1481 const CFX_ByteStringC& szFuncName, | 1482 const CFX_ByteStringC& szFuncName, |
| 1482 CFXJSE_Arguments& args) { | 1483 CFXJSE_Arguments& args) { |
| 1483 int32_t argc = args.GetLength(); | 1484 int32_t argc = args.GetLength(); |
| 1484 if (argc < 1 || argc > 3) { | 1485 if (argc < 1 || argc > 3) { |
| 1485 ToJSContext(pThis, nullptr) | 1486 ToJSContext(pThis, nullptr) |
| 1486 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2Time"); | 1487 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2Time"); |
| 1487 return; | 1488 return; |
| 1488 } | 1489 } |
| 1489 | 1490 |
| 1490 std::unique_ptr<CFXJSE_Value> timeValue = GetSimpleValue(pThis, args, 0); | 1491 std::unique_ptr<CFXJSE_Value> timeValue = GetSimpleValue(pThis, args, 0); |
| 1491 if (FXJSE_Value_IsNull(timeValue.get())) { | 1492 if (timeValue->IsNull()) { |
| 1492 args.GetReturnValue()->SetNull(); | 1493 args.GetReturnValue()->SetNull(); |
| 1493 return; | 1494 return; |
| 1494 } | 1495 } |
| 1495 FX_FLOAT fTime = ValueToFloat(pThis, timeValue.get()); | 1496 FX_FLOAT fTime = ValueToFloat(pThis, timeValue.get()); |
| 1496 if (FXSYS_fabs(fTime) < 1.0) { | 1497 if (FXSYS_fabs(fTime) < 1.0) { |
| 1497 args.GetReturnValue()->SetNull(); | 1498 args.GetReturnValue()->SetNull(); |
| 1498 return; | 1499 return; |
| 1499 } | 1500 } |
| 1500 | 1501 |
| 1501 CFX_ByteString formatString; | 1502 CFX_ByteString formatString; |
| 1502 if (argc > 1) { | 1503 if (argc > 1) { |
| 1503 std::unique_ptr<CFXJSE_Value> formatValue = GetSimpleValue(pThis, args, 1); | 1504 std::unique_ptr<CFXJSE_Value> formatValue = GetSimpleValue(pThis, args, 1); |
| 1504 if (FXJSE_Value_IsNull(formatValue.get())) { | 1505 if (formatValue->IsNull()) { |
| 1505 args.GetReturnValue()->SetNull(); | 1506 args.GetReturnValue()->SetNull(); |
| 1506 return; | 1507 return; |
| 1507 } | 1508 } |
| 1508 ValueToUTF8String(formatValue.get(), formatString); | 1509 ValueToUTF8String(formatValue.get(), formatString); |
| 1509 } | 1510 } |
| 1510 | 1511 |
| 1511 CFX_ByteString localString; | 1512 CFX_ByteString localString; |
| 1512 if (argc > 2) { | 1513 if (argc > 2) { |
| 1513 std::unique_ptr<CFXJSE_Value> localValue = GetSimpleValue(pThis, args, 2); | 1514 std::unique_ptr<CFXJSE_Value> localValue = GetSimpleValue(pThis, args, 2); |
| 1514 if (FXJSE_Value_IsNull(localValue.get())) { | 1515 if (localValue->IsNull()) { |
| 1515 args.GetReturnValue()->SetNull(); | 1516 args.GetReturnValue()->SetNull(); |
| 1516 return; | 1517 return; |
| 1517 } | 1518 } |
| 1518 ValueToUTF8String(localValue.get(), localString); | 1519 ValueToUTF8String(localValue.get(), localString); |
| 1519 } | 1520 } |
| 1520 | 1521 |
| 1521 CFX_ByteString szLocalTimeString; | 1522 CFX_ByteString szLocalTimeString; |
| 1522 Num2AllTime(pThis, (int32_t)fTime, formatString.AsStringC(), | 1523 Num2AllTime(pThis, (int32_t)fTime, formatString.AsStringC(), |
| 1523 localString.AsStringC(), FALSE, szLocalTimeString); | 1524 localString.AsStringC(), FALSE, szLocalTimeString); |
| 1524 args.GetReturnValue()->SetString(szLocalTimeString.AsStringC()); | 1525 args.GetReturnValue()->SetString(szLocalTimeString.AsStringC()); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1641 int32_t argc = args.GetLength(); | 1642 int32_t argc = args.GetLength(); |
| 1642 if (argc > 2) { | 1643 if (argc > 2) { |
| 1643 ToJSContext(pThis, nullptr) | 1644 ToJSContext(pThis, nullptr) |
| 1644 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"TimeFmt"); | 1645 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"TimeFmt"); |
| 1645 return; | 1646 return; |
| 1646 } | 1647 } |
| 1647 | 1648 |
| 1648 int32_t iStyle = 0; | 1649 int32_t iStyle = 0; |
| 1649 if (argc > 0) { | 1650 if (argc > 0) { |
| 1650 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0); | 1651 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0); |
| 1651 if (FXJSE_Value_IsNull(argStyle.get())) { | 1652 if (argStyle->IsNull()) { |
| 1652 args.GetReturnValue()->SetNull(); | 1653 args.GetReturnValue()->SetNull(); |
| 1653 return; | 1654 return; |
| 1654 } | 1655 } |
| 1655 iStyle = (int32_t)ValueToFloat(pThis, argStyle.get()); | 1656 iStyle = (int32_t)ValueToFloat(pThis, argStyle.get()); |
| 1656 if (iStyle > 4 || iStyle < 0) | 1657 if (iStyle > 4 || iStyle < 0) |
| 1657 iStyle = 0; | 1658 iStyle = 0; |
| 1658 } | 1659 } |
| 1659 | 1660 |
| 1660 CFX_ByteString szLocal; | 1661 CFX_ByteString szLocal; |
| 1661 if (argc > 1) { | 1662 if (argc > 1) { |
| 1662 std::unique_ptr<CFXJSE_Value> argLocal = GetSimpleValue(pThis, args, 1); | 1663 std::unique_ptr<CFXJSE_Value> argLocal = GetSimpleValue(pThis, args, 1); |
| 1663 if (FXJSE_Value_IsNull(argLocal.get())) { | 1664 if (argLocal->IsNull()) { |
| 1664 args.GetReturnValue()->SetNull(); | 1665 args.GetReturnValue()->SetNull(); |
| 1665 return; | 1666 return; |
| 1666 } | 1667 } |
| 1667 ValueToUTF8String(argLocal.get(), szLocal); | 1668 ValueToUTF8String(argLocal.get(), szLocal); |
| 1668 } | 1669 } |
| 1669 | 1670 |
| 1670 CFX_ByteString formatStr; | 1671 CFX_ByteString formatStr; |
| 1671 GetStandardTimeFormat(pThis, iStyle, szLocal.AsStringC(), formatStr); | 1672 GetStandardTimeFormat(pThis, iStyle, szLocal.AsStringC(), formatStr); |
| 1672 args.GetReturnValue()->SetString(formatStr.AsStringC()); | 1673 args.GetReturnValue()->SetString(formatStr.AsStringC()); |
| 1673 } | 1674 } |
| (...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2811 return; | 2812 return; |
| 2812 } | 2813 } |
| 2813 | 2814 |
| 2814 FX_BOOL bFound = FALSE; | 2815 FX_BOOL bFound = FALSE; |
| 2815 FX_BOOL bStopCounterFlags = FALSE; | 2816 FX_BOOL bStopCounterFlags = FALSE; |
| 2816 int32_t iArgIndex = 1; | 2817 int32_t iArgIndex = 1; |
| 2817 int32_t iValueIndex = 0; | 2818 int32_t iValueIndex = 0; |
| 2818 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 2819 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 2819 while (!bFound && !bStopCounterFlags && (iArgIndex < argc)) { | 2820 while (!bFound && !bStopCounterFlags && (iArgIndex < argc)) { |
| 2820 std::unique_ptr<CFXJSE_Value> argIndexValue = args.GetValue(iArgIndex); | 2821 std::unique_ptr<CFXJSE_Value> argIndexValue = args.GetValue(iArgIndex); |
| 2821 if (FXJSE_Value_IsArray(argIndexValue.get())) { | 2822 if (argIndexValue->IsArray()) { |
| 2822 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 2823 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 2823 argIndexValue->GetObjectProperty("length", lengthValue.get()); | 2824 argIndexValue->GetObjectProperty("length", lengthValue.get()); |
| 2824 int32_t iLength = lengthValue->ToInteger(); | 2825 int32_t iLength = lengthValue->ToInteger(); |
| 2825 if (iLength > 3) | 2826 if (iLength > 3) |
| 2826 bStopCounterFlags = TRUE; | 2827 bStopCounterFlags = TRUE; |
| 2827 | 2828 |
| 2828 iValueIndex += (iLength - 2); | 2829 iValueIndex += (iLength - 2); |
| 2829 if (iValueIndex >= iIndex) { | 2830 if (iValueIndex >= iIndex) { |
| 2830 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 2831 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 2831 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 2832 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 2832 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 2833 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 2833 new CFXJSE_Value(pIsolate)); | 2834 new CFXJSE_Value(pIsolate)); |
| 2834 argIndexValue->GetObjectPropertyByIdx(1, propertyValue.get()); | 2835 argIndexValue->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 2835 argIndexValue->GetObjectPropertyByIdx( | 2836 argIndexValue->GetObjectPropertyByIdx( |
| 2836 (iLength - 1) - (iValueIndex - iIndex), jsObjectValue.get()); | 2837 (iLength - 1) - (iValueIndex - iIndex), jsObjectValue.get()); |
| 2837 if (FXJSE_Value_IsNull(propertyValue.get())) { | 2838 if (propertyValue->IsNull()) { |
| 2838 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 2839 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
| 2839 } else { | 2840 } else { |
| 2840 CFX_ByteString propStr; | 2841 CFX_ByteString propStr; |
| 2841 propertyValue->ToString(propStr); | 2842 propertyValue->ToString(propStr); |
| 2842 jsObjectValue->GetObjectProperty(propStr.AsStringC(), | 2843 jsObjectValue->GetObjectProperty(propStr.AsStringC(), |
| 2843 newPropertyValue.get()); | 2844 newPropertyValue.get()); |
| 2844 } | 2845 } |
| 2845 CFX_ByteString bsChoosed; | 2846 CFX_ByteString bsChoosed; |
| 2846 ValueToUTF8String(newPropertyValue.get(), bsChoosed); | 2847 ValueToUTF8String(newPropertyValue.get(), bsChoosed); |
| 2847 args.GetReturnValue()->SetString(bsChoosed.AsStringC()); | 2848 args.GetReturnValue()->SetString(bsChoosed.AsStringC()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2864 | 2865 |
| 2865 // static | 2866 // static |
| 2866 void CXFA_FM2JSContext::Exists(CFXJSE_Value* pThis, | 2867 void CXFA_FM2JSContext::Exists(CFXJSE_Value* pThis, |
| 2867 const CFX_ByteStringC& szFuncName, | 2868 const CFX_ByteStringC& szFuncName, |
| 2868 CFXJSE_Arguments& args) { | 2869 CFXJSE_Arguments& args) { |
| 2869 if (args.GetLength() != 1) { | 2870 if (args.GetLength() != 1) { |
| 2870 ToJSContext(pThis, nullptr) | 2871 ToJSContext(pThis, nullptr) |
| 2871 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Exists"); | 2872 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Exists"); |
| 2872 return; | 2873 return; |
| 2873 } | 2874 } |
| 2874 | 2875 args.GetReturnValue()->SetInteger(args.GetValue(0)->IsObject()); |
| 2875 args.GetReturnValue()->SetInteger( | |
| 2876 FXJSE_Value_IsObject(args.GetValue(0).get())); | |
| 2877 } | 2876 } |
| 2878 | 2877 |
| 2879 // static | 2878 // static |
| 2880 void CXFA_FM2JSContext::HasValue(CFXJSE_Value* pThis, | 2879 void CXFA_FM2JSContext::HasValue(CFXJSE_Value* pThis, |
| 2881 const CFX_ByteStringC& szFuncName, | 2880 const CFX_ByteStringC& szFuncName, |
| 2882 CFXJSE_Arguments& args) { | 2881 CFXJSE_Arguments& args) { |
| 2883 if (args.GetLength() != 1) { | 2882 if (args.GetLength() != 1) { |
| 2884 ToJSContext(pThis, nullptr) | 2883 ToJSContext(pThis, nullptr) |
| 2885 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"HasValue"); | 2884 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"HasValue"); |
| 2886 return; | 2885 return; |
| 2887 } | 2886 } |
| 2888 | 2887 |
| 2889 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 2888 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 2890 if (!FXJSE_Value_IsUTF8String(argOne.get())) { | 2889 if (!argOne->IsString()) { |
| 2891 args.GetReturnValue()->SetInteger(FXJSE_Value_IsNumber(argOne.get()) || | 2890 args.GetReturnValue()->SetInteger(argOne->IsNumber() || |
| 2892 FXJSE_Value_IsBoolean(argOne.get())); | 2891 argOne->IsBoolean()); |
| 2893 return; | 2892 return; |
| 2894 } | 2893 } |
| 2895 | 2894 |
| 2896 CFX_ByteString valueStr; | 2895 CFX_ByteString valueStr; |
| 2897 argOne->ToString(valueStr); | 2896 argOne->ToString(valueStr); |
| 2898 valueStr.TrimLeft(); | 2897 valueStr.TrimLeft(); |
| 2899 args.GetReturnValue()->SetInteger(!valueStr.IsEmpty()); | 2898 args.GetReturnValue()->SetInteger(!valueStr.IsEmpty()); |
| 2900 } | 2899 } |
| 2901 | 2900 |
| 2902 // static | 2901 // static |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2931 void CXFA_FM2JSContext::Within(CFXJSE_Value* pThis, | 2930 void CXFA_FM2JSContext::Within(CFXJSE_Value* pThis, |
| 2932 const CFX_ByteStringC& szFuncName, | 2931 const CFX_ByteStringC& szFuncName, |
| 2933 CFXJSE_Arguments& args) { | 2932 CFXJSE_Arguments& args) { |
| 2934 if (args.GetLength() != 3) { | 2933 if (args.GetLength() != 3) { |
| 2935 ToJSContext(pThis, nullptr) | 2934 ToJSContext(pThis, nullptr) |
| 2936 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Within"); | 2935 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Within"); |
| 2937 return; | 2936 return; |
| 2938 } | 2937 } |
| 2939 | 2938 |
| 2940 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 2939 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 2941 if (FXJSE_Value_IsNull(argOne.get())) { | 2940 if (argOne->IsNull()) { |
| 2942 args.GetReturnValue()->SetUndefined(); | 2941 args.GetReturnValue()->SetUndefined(); |
| 2943 return; | 2942 return; |
| 2944 } | 2943 } |
| 2945 | 2944 |
| 2946 std::unique_ptr<CFXJSE_Value> argLow = GetSimpleValue(pThis, args, 1); | 2945 std::unique_ptr<CFXJSE_Value> argLow = GetSimpleValue(pThis, args, 1); |
| 2947 std::unique_ptr<CFXJSE_Value> argHigh = GetSimpleValue(pThis, args, 2); | 2946 std::unique_ptr<CFXJSE_Value> argHigh = GetSimpleValue(pThis, args, 2); |
| 2948 if (FXJSE_Value_IsNumber(argOne.get())) { | 2947 if (argOne->IsNumber()) { |
| 2949 FX_FLOAT oneNumber = ValueToFloat(pThis, argOne.get()); | 2948 FX_FLOAT oneNumber = ValueToFloat(pThis, argOne.get()); |
| 2950 FX_FLOAT lowNumber = ValueToFloat(pThis, argLow.get()); | 2949 FX_FLOAT lowNumber = ValueToFloat(pThis, argLow.get()); |
| 2951 FX_FLOAT heightNumber = ValueToFloat(pThis, argHigh.get()); | 2950 FX_FLOAT heightNumber = ValueToFloat(pThis, argHigh.get()); |
| 2952 args.GetReturnValue()->SetInteger((oneNumber >= lowNumber) && | 2951 args.GetReturnValue()->SetInteger((oneNumber >= lowNumber) && |
| 2953 (oneNumber <= heightNumber)); | 2952 (oneNumber <= heightNumber)); |
| 2954 return; | 2953 return; |
| 2955 } | 2954 } |
| 2956 | 2955 |
| 2957 CFX_ByteString oneString; | 2956 CFX_ByteString oneString; |
| 2958 CFX_ByteString lowString; | 2957 CFX_ByteString lowString; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2997 if (utf8ScriptString.IsEmpty()) { | 2996 if (utf8ScriptString.IsEmpty()) { |
| 2998 args.GetReturnValue()->SetNull(); | 2997 args.GetReturnValue()->SetNull(); |
| 2999 return; | 2998 return; |
| 3000 } | 2999 } |
| 3001 | 3000 |
| 3002 CFX_WideTextBuf wsJavaScriptBuf; | 3001 CFX_WideTextBuf wsJavaScriptBuf; |
| 3003 CFX_WideString wsError; | 3002 CFX_WideString wsError; |
| 3004 CXFA_FM2JSContext::Translate( | 3003 CXFA_FM2JSContext::Translate( |
| 3005 CFX_WideString::FromUTF8(utf8ScriptString.AsStringC()).AsStringC(), | 3004 CFX_WideString::FromUTF8(utf8ScriptString.AsStringC()).AsStringC(), |
| 3006 wsJavaScriptBuf, wsError); | 3005 wsJavaScriptBuf, wsError); |
| 3007 CFXJSE_Context* pNewContext = | 3006 std::unique_ptr<CFXJSE_Context> pNewContext( |
| 3008 FXJSE_Context_Create(pIsolate, nullptr, nullptr); | 3007 CFXJSE_Context::Create(pIsolate, nullptr, nullptr)); |
| 3009 | 3008 |
| 3010 std::unique_ptr<CFXJSE_Value> returnValue(new CFXJSE_Value(pIsolate)); | 3009 std::unique_ptr<CFXJSE_Value> returnValue(new CFXJSE_Value(pIsolate)); |
| 3011 CFX_WideString javaScript(wsJavaScriptBuf.AsStringC()); | 3010 CFX_WideString javaScript(wsJavaScriptBuf.AsStringC()); |
| 3012 FXJSE_ExecuteScript( | 3011 pNewContext->ExecuteScript( |
| 3013 pNewContext, | |
| 3014 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(), | 3012 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(), |
| 3015 returnValue.get()); | 3013 returnValue.get()); |
| 3016 | 3014 |
| 3017 args.GetReturnValue()->Assign(returnValue.get()); | 3015 args.GetReturnValue()->Assign(returnValue.get()); |
| 3018 FXJSE_Context_Release(pNewContext); | |
| 3019 } | 3016 } |
| 3020 | 3017 |
| 3021 // static | 3018 // static |
| 3022 void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis, | 3019 void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis, |
| 3023 const CFX_ByteStringC& szFuncName, | 3020 const CFX_ByteStringC& szFuncName, |
| 3024 CFXJSE_Arguments& args) { | 3021 CFXJSE_Arguments& args) { |
| 3025 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); | 3022 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); |
| 3026 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 3023 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 3027 if (args.GetLength() != 1) { | 3024 if (args.GetLength() != 1) { |
| 3028 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Ref"); | 3025 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Ref"); |
| 3029 return; | 3026 return; |
| 3030 } | 3027 } |
| 3031 | 3028 |
| 3032 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 3029 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 3033 if (!FXJSE_Value_IsArray(argOne.get()) && | 3030 if (!argOne->IsArray() && !argOne->IsObject() && !argOne->IsBoolean() && |
| 3034 !FXJSE_Value_IsObject(argOne.get()) && | 3031 !argOne->IsString() && !argOne->IsNull() && !argOne->IsNumber()) { |
| 3035 !FXJSE_Value_IsBoolean(argOne.get()) && | |
| 3036 !FXJSE_Value_IsUTF8String(argOne.get()) && | |
| 3037 !FXJSE_Value_IsNull(argOne.get()) && | |
| 3038 !FXJSE_Value_IsNumber(argOne.get())) { | |
| 3039 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); | 3032 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); |
| 3040 return; | 3033 return; |
| 3041 } | 3034 } |
| 3042 | 3035 |
| 3043 if (FXJSE_Value_IsBoolean(argOne.get()) || | 3036 if (argOne->IsBoolean() || argOne->IsString() || argOne->IsNumber()) { |
| 3044 FXJSE_Value_IsUTF8String(argOne.get()) || | |
| 3045 FXJSE_Value_IsNumber(argOne.get())) { | |
| 3046 args.GetReturnValue()->Assign(argOne.get()); | 3037 args.GetReturnValue()->Assign(argOne.get()); |
| 3047 return; | 3038 return; |
| 3048 } | 3039 } |
| 3049 | 3040 |
| 3050 CFXJSE_Value* rgValues[3]; | 3041 CFXJSE_Value* rgValues[3]; |
| 3051 for (int32_t i = 0; i < 3; i++) | 3042 for (int32_t i = 0; i < 3; i++) |
| 3052 rgValues[i] = new CFXJSE_Value(pIsolate); | 3043 rgValues[i] = new CFXJSE_Value(pIsolate); |
| 3053 | 3044 |
| 3054 int intVal = 3; | 3045 int intVal = 3; |
| 3055 if (FXJSE_Value_IsNull(argOne.get())) { | 3046 if (argOne->IsNull()) { |
| 3047 // TODO(dsinclair): Why is this 4 when the others are all 3? |
| 3056 intVal = 4; | 3048 intVal = 4; |
| 3057 rgValues[2]->SetNull(); | 3049 rgValues[2]->SetNull(); |
| 3058 } else if (FXJSE_Value_IsArray(argOne.get())) { | 3050 } else if (argOne->IsArray()) { |
| 3059 #ifndef NDEBUG | 3051 #ifndef NDEBUG |
| 3060 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 3052 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 3061 argOne->GetObjectProperty("length", lengthValue.get()); | 3053 argOne->GetObjectProperty("length", lengthValue.get()); |
| 3062 ASSERT(lengthValue->ToInteger() >= 3); | 3054 ASSERT(lengthValue->ToInteger() >= 3); |
| 3063 #endif | 3055 #endif |
| 3064 | 3056 |
| 3065 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 3057 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 3066 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 3058 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 3067 argOne->GetObjectPropertyByIdx(1, propertyValue.get()); | 3059 argOne->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 3068 argOne->GetObjectPropertyByIdx(2, jsObjectValue.get()); | 3060 argOne->GetObjectPropertyByIdx(2, jsObjectValue.get()); |
| 3069 if (!FXJSE_Value_IsNull(propertyValue.get()) || | 3061 if (!propertyValue->IsNull() || jsObjectValue->IsNull()) { |
| 3070 FXJSE_Value_IsNull(jsObjectValue.get())) { | |
| 3071 for (int32_t i = 0; i < 3; i++) | 3062 for (int32_t i = 0; i < 3; i++) |
| 3072 delete rgValues[i]; | 3063 delete rgValues[i]; |
| 3073 | 3064 |
| 3074 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); | 3065 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); |
| 3075 return; | 3066 return; |
| 3076 } | 3067 } |
| 3077 | 3068 |
| 3078 rgValues[2]->Assign(jsObjectValue.get()); | 3069 rgValues[2]->Assign(jsObjectValue.get()); |
| 3079 } else if (FXJSE_Value_IsObject(argOne.get())) { | 3070 } else if (argOne->IsObject()) { |
| 3080 rgValues[2]->Assign(argOne.get()); | 3071 rgValues[2]->Assign(argOne.get()); |
| 3081 } | 3072 } |
| 3082 | 3073 |
| 3083 rgValues[0]->SetInteger(intVal); | 3074 rgValues[0]->SetInteger(intVal); |
| 3084 rgValues[1]->SetNull(); | 3075 rgValues[1]->SetNull(); |
| 3085 args.GetReturnValue()->SetArray(3, rgValues); | 3076 args.GetReturnValue()->SetArray(3, rgValues); |
| 3086 | 3077 |
| 3087 for (int32_t i = 0; i < 3; i++) | 3078 for (int32_t i = 0; i < 3; i++) |
| 3088 delete rgValues[i]; | 3079 delete rgValues[i]; |
| 3089 } | 3080 } |
| 3090 | 3081 |
| 3091 // static | 3082 // static |
| 3092 void CXFA_FM2JSContext::UnitType(CFXJSE_Value* pThis, | 3083 void CXFA_FM2JSContext::UnitType(CFXJSE_Value* pThis, |
| 3093 const CFX_ByteStringC& szFuncName, | 3084 const CFX_ByteStringC& szFuncName, |
| 3094 CFXJSE_Arguments& args) { | 3085 CFXJSE_Arguments& args) { |
| 3095 if (args.GetLength() != 1) { | 3086 if (args.GetLength() != 1) { |
| 3096 ToJSContext(pThis, nullptr) | 3087 ToJSContext(pThis, nullptr) |
| 3097 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"UnitType"); | 3088 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"UnitType"); |
| 3098 return; | 3089 return; |
| 3099 } | 3090 } |
| 3100 | 3091 |
| 3101 std::unique_ptr<CFXJSE_Value> unitspanValue = GetSimpleValue(pThis, args, 0); | 3092 std::unique_ptr<CFXJSE_Value> unitspanValue = GetSimpleValue(pThis, args, 0); |
| 3102 if (FXJSE_Value_IsNull(unitspanValue.get())) { | 3093 if (unitspanValue->IsNull()) { |
| 3103 args.GetReturnValue()->SetNull(); | 3094 args.GetReturnValue()->SetNull(); |
| 3104 return; | 3095 return; |
| 3105 } | 3096 } |
| 3106 | 3097 |
| 3107 CFX_ByteString unitspanString; | 3098 CFX_ByteString unitspanString; |
| 3108 ValueToUTF8String(unitspanValue.get(), unitspanString); | 3099 ValueToUTF8String(unitspanValue.get(), unitspanString); |
| 3109 if (unitspanString.IsEmpty()) { | 3100 if (unitspanString.IsEmpty()) { |
| 3110 args.GetReturnValue()->SetString("in"); | 3101 args.GetReturnValue()->SetString("in"); |
| 3111 return; | 3102 return; |
| 3112 } | 3103 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3206 const CFX_ByteStringC& szFuncName, | 3197 const CFX_ByteStringC& szFuncName, |
| 3207 CFXJSE_Arguments& args) { | 3198 CFXJSE_Arguments& args) { |
| 3208 int32_t argc = args.GetLength(); | 3199 int32_t argc = args.GetLength(); |
| 3209 if (argc < 1 || argc > 2) { | 3200 if (argc < 1 || argc > 2) { |
| 3210 ToJSContext(pThis, nullptr) | 3201 ToJSContext(pThis, nullptr) |
| 3211 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"UnitValue"); | 3202 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"UnitValue"); |
| 3212 return; | 3203 return; |
| 3213 } | 3204 } |
| 3214 | 3205 |
| 3215 std::unique_ptr<CFXJSE_Value> unitspanValue = GetSimpleValue(pThis, args, 0); | 3206 std::unique_ptr<CFXJSE_Value> unitspanValue = GetSimpleValue(pThis, args, 0); |
| 3216 if (FXJSE_Value_IsNull(unitspanValue.get())) { | 3207 if (unitspanValue->IsNull()) { |
| 3217 args.GetReturnValue()->SetNull(); | 3208 args.GetReturnValue()->SetNull(); |
| 3218 return; | 3209 return; |
| 3219 } | 3210 } |
| 3220 | 3211 |
| 3221 CFX_ByteString unitspanString; | 3212 CFX_ByteString unitspanString; |
| 3222 ValueToUTF8String(unitspanValue.get(), unitspanString); | 3213 ValueToUTF8String(unitspanValue.get(), unitspanString); |
| 3223 const FX_CHAR* pData = unitspanString.c_str(); | 3214 const FX_CHAR* pData = unitspanString.c_str(); |
| 3224 if (!pData) { | 3215 if (!pData) { |
| 3225 args.GetReturnValue()->SetInteger(0); | 3216 args.GetReturnValue()->SetInteger(0); |
| 3226 return; | 3217 return; |
| (...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4449 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Rtrim"); | 4440 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Rtrim"); |
| 4450 } | 4441 } |
| 4451 } | 4442 } |
| 4452 | 4443 |
| 4453 // static | 4444 // static |
| 4454 void CXFA_FM2JSContext::Space(CFXJSE_Value* pThis, | 4445 void CXFA_FM2JSContext::Space(CFXJSE_Value* pThis, |
| 4455 const CFX_ByteStringC& szFuncName, | 4446 const CFX_ByteStringC& szFuncName, |
| 4456 CFXJSE_Arguments& args) { | 4447 CFXJSE_Arguments& args) { |
| 4457 if (args.GetLength() == 1) { | 4448 if (args.GetLength() == 1) { |
| 4458 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4449 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 4459 if (FXJSE_Value_IsNull(argOne.get())) { | 4450 if (argOne->IsNull()) { |
| 4460 args.GetReturnValue()->SetNull(); | 4451 args.GetReturnValue()->SetNull(); |
| 4461 } else { | 4452 } else { |
| 4462 int32_t count = 0; | 4453 int32_t count = 0; |
| 4463 count = ValueToInteger(pThis, argOne.get()); | 4454 count = ValueToInteger(pThis, argOne.get()); |
| 4464 count = (count < 0) ? 0 : count; | 4455 count = (count < 0) ? 0 : count; |
| 4465 CFX_ByteTextBuf spaceString; | 4456 CFX_ByteTextBuf spaceString; |
| 4466 int32_t index = 0; | 4457 int32_t index = 0; |
| 4467 while (index < count) { | 4458 while (index < count) { |
| 4468 spaceString.AppendByte(' '); | 4459 spaceString.AppendByte(' '); |
| 4469 index++; | 4460 index++; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4481 void CXFA_FM2JSContext::Str(CFXJSE_Value* pThis, | 4472 void CXFA_FM2JSContext::Str(CFXJSE_Value* pThis, |
| 4482 const CFX_ByteStringC& szFuncName, | 4473 const CFX_ByteStringC& szFuncName, |
| 4483 CFXJSE_Arguments& args) { | 4474 CFXJSE_Arguments& args) { |
| 4484 int32_t argc = args.GetLength(); | 4475 int32_t argc = args.GetLength(); |
| 4485 if ((argc > 0) && (argc < 4)) { | 4476 if ((argc > 0) && (argc < 4)) { |
| 4486 FX_BOOL bFlags = FALSE; | 4477 FX_BOOL bFlags = FALSE; |
| 4487 FX_FLOAT fNumber = 0.0f; | 4478 FX_FLOAT fNumber = 0.0f; |
| 4488 int32_t iWidth = 10; | 4479 int32_t iWidth = 10; |
| 4489 int32_t iPrecision = 0; | 4480 int32_t iPrecision = 0; |
| 4490 std::unique_ptr<CFXJSE_Value> numberValue = GetSimpleValue(pThis, args, 0); | 4481 std::unique_ptr<CFXJSE_Value> numberValue = GetSimpleValue(pThis, args, 0); |
| 4491 if (FXJSE_Value_IsNull(numberValue.get())) { | 4482 if (numberValue->IsNull()) { |
| 4492 bFlags = TRUE; | 4483 bFlags = TRUE; |
| 4493 } else { | 4484 } else { |
| 4494 fNumber = ValueToFloat(pThis, numberValue.get()); | 4485 fNumber = ValueToFloat(pThis, numberValue.get()); |
| 4495 } | 4486 } |
| 4496 if (argc > 1) { | 4487 if (argc > 1) { |
| 4497 std::unique_ptr<CFXJSE_Value> widthValue = GetSimpleValue(pThis, args, 1); | 4488 std::unique_ptr<CFXJSE_Value> widthValue = GetSimpleValue(pThis, args, 1); |
| 4498 iWidth = (int32_t)ValueToFloat(pThis, widthValue.get()); | 4489 iWidth = (int32_t)ValueToFloat(pThis, widthValue.get()); |
| 4499 } | 4490 } |
| 4500 if (argc > 2) { | 4491 if (argc > 2) { |
| 4501 std::unique_ptr<CFXJSE_Value> precisionValue = | 4492 std::unique_ptr<CFXJSE_Value> precisionValue = |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4602 int32_t argc = args.GetLength(); | 4593 int32_t argc = args.GetLength(); |
| 4603 if ((argc == 3) || (argc == 4)) { | 4594 if ((argc == 3) || (argc == 4)) { |
| 4604 CFX_ByteString sourceString; | 4595 CFX_ByteString sourceString; |
| 4605 CFX_ByteString insertString; | 4596 CFX_ByteString insertString; |
| 4606 int32_t iLength = 0; | 4597 int32_t iLength = 0; |
| 4607 int32_t iStart = 0; | 4598 int32_t iStart = 0; |
| 4608 int32_t iDelete = 0; | 4599 int32_t iDelete = 0; |
| 4609 std::unique_ptr<CFXJSE_Value> sourceValue = GetSimpleValue(pThis, args, 0); | 4600 std::unique_ptr<CFXJSE_Value> sourceValue = GetSimpleValue(pThis, args, 0); |
| 4610 std::unique_ptr<CFXJSE_Value> startValue = GetSimpleValue(pThis, args, 1); | 4601 std::unique_ptr<CFXJSE_Value> startValue = GetSimpleValue(pThis, args, 1); |
| 4611 std::unique_ptr<CFXJSE_Value> deleteValue = GetSimpleValue(pThis, args, 2); | 4602 std::unique_ptr<CFXJSE_Value> deleteValue = GetSimpleValue(pThis, args, 2); |
| 4612 if (!FXJSE_Value_IsNull(sourceValue.get()) && | 4603 if (!sourceValue->IsNull() && !startValue->IsNull() && |
| 4613 !FXJSE_Value_IsNull(startValue.get()) && | 4604 !deleteValue->IsNull()) { |
| 4614 !FXJSE_Value_IsNull(deleteValue.get())) { | |
| 4615 ValueToUTF8String(sourceValue.get(), sourceString); | 4605 ValueToUTF8String(sourceValue.get(), sourceString); |
| 4616 iLength = sourceString.GetLength(); | 4606 iLength = sourceString.GetLength(); |
| 4617 iStart = (int32_t)ValueToFloat(pThis, startValue.get()); | 4607 iStart = (int32_t)ValueToFloat(pThis, startValue.get()); |
| 4618 if (iStart < 1) { | 4608 if (iStart < 1) { |
| 4619 iStart = 1; | 4609 iStart = 1; |
| 4620 } | 4610 } |
| 4621 if (iStart > iLength) { | 4611 if (iStart > iLength) { |
| 4622 iStart = iLength; | 4612 iStart = iLength; |
| 4623 } | 4613 } |
| 4624 iDelete = (int32_t)ValueToFloat(pThis, deleteValue.get()); | 4614 iDelete = (int32_t)ValueToFloat(pThis, deleteValue.get()); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4763 void CXFA_FM2JSContext::WordNum(CFXJSE_Value* pThis, | 4753 void CXFA_FM2JSContext::WordNum(CFXJSE_Value* pThis, |
| 4764 const CFX_ByteStringC& szFuncName, | 4754 const CFX_ByteStringC& szFuncName, |
| 4765 CFXJSE_Arguments& args) { | 4755 CFXJSE_Arguments& args) { |
| 4766 int32_t argc = args.GetLength(); | 4756 int32_t argc = args.GetLength(); |
| 4767 if ((argc > 0) && (argc < 4)) { | 4757 if ((argc > 0) && (argc < 4)) { |
| 4768 FX_BOOL bFlags = FALSE; | 4758 FX_BOOL bFlags = FALSE; |
| 4769 FX_FLOAT fNumber = 0.0f; | 4759 FX_FLOAT fNumber = 0.0f; |
| 4770 int32_t iIdentifier = 0; | 4760 int32_t iIdentifier = 0; |
| 4771 CFX_ByteString localeString; | 4761 CFX_ByteString localeString; |
| 4772 std::unique_ptr<CFXJSE_Value> numberValue = GetSimpleValue(pThis, args, 0); | 4762 std::unique_ptr<CFXJSE_Value> numberValue = GetSimpleValue(pThis, args, 0); |
| 4773 if (FXJSE_Value_IsNull(numberValue.get())) { | 4763 if (numberValue->IsNull()) { |
| 4774 bFlags = TRUE; | 4764 bFlags = TRUE; |
| 4775 } else { | 4765 } else { |
| 4776 fNumber = ValueToFloat(pThis, numberValue.get()); | 4766 fNumber = ValueToFloat(pThis, numberValue.get()); |
| 4777 } | 4767 } |
| 4778 if (argc > 1) { | 4768 if (argc > 1) { |
| 4779 std::unique_ptr<CFXJSE_Value> identifierValue = | 4769 std::unique_ptr<CFXJSE_Value> identifierValue = |
| 4780 GetSimpleValue(pThis, args, 1); | 4770 GetSimpleValue(pThis, args, 1); |
| 4781 if (FXJSE_Value_IsNull(identifierValue.get())) { | 4771 if (identifierValue->IsNull()) { |
| 4782 bFlags = TRUE; | 4772 bFlags = TRUE; |
| 4783 } else { | 4773 } else { |
| 4784 iIdentifier = (int32_t)ValueToFloat(pThis, identifierValue.get()); | 4774 iIdentifier = (int32_t)ValueToFloat(pThis, identifierValue.get()); |
| 4785 } | 4775 } |
| 4786 } | 4776 } |
| 4787 if (argc > 2) { | 4777 if (argc > 2) { |
| 4788 std::unique_ptr<CFXJSE_Value> localeValue = | 4778 std::unique_ptr<CFXJSE_Value> localeValue = |
| 4789 GetSimpleValue(pThis, args, 2); | 4779 GetSimpleValue(pThis, args, 2); |
| 4790 if (FXJSE_Value_IsNull(localeValue.get())) { | 4780 if (localeValue->IsNull()) { |
| 4791 bFlags = TRUE; | 4781 bFlags = TRUE; |
| 4792 } else { | 4782 } else { |
| 4793 ValueToUTF8String(localeValue.get(), localeString); | 4783 ValueToUTF8String(localeValue.get(), localeString); |
| 4794 } | 4784 } |
| 4795 } | 4785 } |
| 4796 if (!bFlags) { | 4786 if (!bFlags) { |
| 4797 if ((fNumber < 0) || (fNumber > 922337203685477550)) { | 4787 if ((fNumber < 0) || (fNumber > 922337203685477550)) { |
| 4798 args.GetReturnValue()->SetString("*"); | 4788 args.GetReturnValue()->SetString("*"); |
| 4799 } else { | 4789 } else { |
| 4800 CFX_ByteTextBuf resultBuf; | 4790 CFX_ByteTextBuf resultBuf; |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5142 // static | 5132 // static |
| 5143 void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis, | 5133 void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis, |
| 5144 const CFX_ByteStringC& szFuncName, | 5134 const CFX_ByteStringC& szFuncName, |
| 5145 CFXJSE_Arguments& args) { | 5135 CFXJSE_Arguments& args) { |
| 5146 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); | 5136 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); |
| 5147 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 5137 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 5148 if (args.GetLength() == 2) { | 5138 if (args.GetLength() == 2) { |
| 5149 std::unique_ptr<CFXJSE_Value> lValue = args.GetValue(0); | 5139 std::unique_ptr<CFXJSE_Value> lValue = args.GetValue(0); |
| 5150 std::unique_ptr<CFXJSE_Value> rValue = GetSimpleValue(pThis, args, 1); | 5140 std::unique_ptr<CFXJSE_Value> rValue = GetSimpleValue(pThis, args, 1); |
| 5151 FX_BOOL bSetStatus = TRUE; | 5141 FX_BOOL bSetStatus = TRUE; |
| 5152 if (FXJSE_Value_IsArray(lValue.get())) { | 5142 if (lValue->IsArray()) { |
| 5153 std::unique_ptr<CFXJSE_Value> leftLengthValue(new CFXJSE_Value(pIsolate)); | 5143 std::unique_ptr<CFXJSE_Value> leftLengthValue(new CFXJSE_Value(pIsolate)); |
| 5154 lValue->GetObjectProperty("length", leftLengthValue.get()); | 5144 lValue->GetObjectProperty("length", leftLengthValue.get()); |
| 5155 int32_t iLeftLength = leftLengthValue->ToInteger(); | 5145 int32_t iLeftLength = leftLengthValue->ToInteger(); |
| 5156 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 5146 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 5157 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 5147 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 5158 lValue->GetObjectPropertyByIdx(1, propertyValue.get()); | 5148 lValue->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 5159 if (FXJSE_Value_IsNull(propertyValue.get())) { | 5149 if (propertyValue->IsNull()) { |
| 5160 for (int32_t i = 2; i < iLeftLength; i++) { | 5150 for (int32_t i = 2; i < iLeftLength; i++) { |
| 5161 lValue->GetObjectPropertyByIdx(i, jsObjectValue.get()); | 5151 lValue->GetObjectPropertyByIdx(i, jsObjectValue.get()); |
| 5162 bSetStatus = SetObjectDefaultValue(jsObjectValue.get(), rValue.get()); | 5152 bSetStatus = SetObjectDefaultValue(jsObjectValue.get(), rValue.get()); |
| 5163 if (!bSetStatus) { | 5153 if (!bSetStatus) { |
| 5164 pContext->ThrowException(XFA_IDS_NOT_DEFAUL_VALUE); | 5154 pContext->ThrowException(XFA_IDS_NOT_DEFAUL_VALUE); |
| 5165 break; | 5155 break; |
| 5166 } | 5156 } |
| 5167 } | 5157 } |
| 5168 } else { | 5158 } else { |
| 5169 CFX_ByteString propertyStr; | 5159 CFX_ByteString propertyStr; |
| 5170 propertyValue->ToString(propertyStr); | 5160 propertyValue->ToString(propertyStr); |
| 5171 for (int32_t i = 2; i < iLeftLength; i++) { | 5161 for (int32_t i = 2; i < iLeftLength; i++) { |
| 5172 lValue->GetObjectPropertyByIdx(i, jsObjectValue.get()); | 5162 lValue->GetObjectPropertyByIdx(i, jsObjectValue.get()); |
| 5173 jsObjectValue->SetObjectProperty(propertyStr.AsStringC(), | 5163 jsObjectValue->SetObjectProperty(propertyStr.AsStringC(), |
| 5174 rValue.get()); | 5164 rValue.get()); |
| 5175 } | 5165 } |
| 5176 } | 5166 } |
| 5177 } else if (FXJSE_Value_IsObject(lValue.get())) { | 5167 } else if (lValue->IsObject()) { |
| 5178 bSetStatus = SetObjectDefaultValue(lValue.get(), rValue.get()); | 5168 bSetStatus = SetObjectDefaultValue(lValue.get(), rValue.get()); |
| 5179 if (!bSetStatus) { | 5169 if (!bSetStatus) { |
| 5180 pContext->ThrowException(XFA_IDS_NOT_DEFAUL_VALUE); | 5170 pContext->ThrowException(XFA_IDS_NOT_DEFAUL_VALUE); |
| 5181 } | 5171 } |
| 5182 } | 5172 } |
| 5183 args.GetReturnValue()->Assign(rValue.get()); | 5173 args.GetReturnValue()->Assign(rValue.get()); |
| 5184 } else { | 5174 } else { |
| 5185 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); | 5175 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5186 } | 5176 } |
| 5187 } | 5177 } |
| 5188 | 5178 |
| 5189 // static | 5179 // static |
| 5190 void CXFA_FM2JSContext::logical_or_operator(CFXJSE_Value* pThis, | 5180 void CXFA_FM2JSContext::logical_or_operator(CFXJSE_Value* pThis, |
| 5191 const CFX_ByteStringC& szFuncName, | 5181 const CFX_ByteStringC& szFuncName, |
| 5192 CFXJSE_Arguments& args) { | 5182 CFXJSE_Arguments& args) { |
| 5193 if (args.GetLength() == 2) { | 5183 if (args.GetLength() == 2) { |
| 5194 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5184 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5195 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5185 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5196 if (FXJSE_Value_IsNull(argFirst.get()) && | 5186 if (argFirst->IsNull() && argSecond->IsNull()) { |
| 5197 FXJSE_Value_IsNull(argSecond.get())) { | |
| 5198 args.GetReturnValue()->SetNull(); | 5187 args.GetReturnValue()->SetNull(); |
| 5199 } else { | 5188 } else { |
| 5200 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); | 5189 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); |
| 5201 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); | 5190 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); |
| 5202 args.GetReturnValue()->SetInteger((first || second) ? 1 : 0); | 5191 args.GetReturnValue()->SetInteger((first || second) ? 1 : 0); |
| 5203 } | 5192 } |
| 5204 } else { | 5193 } else { |
| 5205 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5194 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5206 } | 5195 } |
| 5207 } | 5196 } |
| 5208 | 5197 |
| 5209 // static | 5198 // static |
| 5210 void CXFA_FM2JSContext::logical_and_operator(CFXJSE_Value* pThis, | 5199 void CXFA_FM2JSContext::logical_and_operator(CFXJSE_Value* pThis, |
| 5211 const CFX_ByteStringC& szFuncName, | 5200 const CFX_ByteStringC& szFuncName, |
| 5212 CFXJSE_Arguments& args) { | 5201 CFXJSE_Arguments& args) { |
| 5213 if (args.GetLength() == 2) { | 5202 if (args.GetLength() == 2) { |
| 5214 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5203 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5215 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5204 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5216 if (FXJSE_Value_IsNull(argFirst.get()) && | 5205 if (argFirst->IsNull() && argSecond->IsNull()) { |
| 5217 FXJSE_Value_IsNull(argSecond.get())) { | |
| 5218 args.GetReturnValue()->SetNull(); | 5206 args.GetReturnValue()->SetNull(); |
| 5219 } else { | 5207 } else { |
| 5220 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); | 5208 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); |
| 5221 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); | 5209 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); |
| 5222 args.GetReturnValue()->SetInteger((first && second) ? 1 : 0); | 5210 args.GetReturnValue()->SetInteger((first && second) ? 1 : 0); |
| 5223 } | 5211 } |
| 5224 } else { | 5212 } else { |
| 5225 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5213 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5226 } | 5214 } |
| 5227 } | 5215 } |
| 5228 | 5216 |
| 5229 // static | 5217 // static |
| 5230 void CXFA_FM2JSContext::equality_operator(CFXJSE_Value* pThis, | 5218 void CXFA_FM2JSContext::equality_operator(CFXJSE_Value* pThis, |
| 5231 const CFX_ByteStringC& szFuncName, | 5219 const CFX_ByteStringC& szFuncName, |
| 5232 CFXJSE_Arguments& args) { | 5220 CFXJSE_Arguments& args) { |
| 5233 if (args.GetLength() == 2) { | 5221 if (args.GetLength() == 2) { |
| 5234 if (fm_ref_equal(pThis, args)) { | 5222 if (fm_ref_equal(pThis, args)) { |
| 5235 args.GetReturnValue()->SetInteger(1); | 5223 args.GetReturnValue()->SetInteger(1); |
| 5236 } else { | 5224 } else { |
| 5237 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5225 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5238 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5226 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5239 if (FXJSE_Value_IsNull(argFirst.get()) || | 5227 if (argFirst->IsNull() || argSecond->IsNull()) { |
| 5240 FXJSE_Value_IsNull(argSecond.get())) { | 5228 args.GetReturnValue()->SetInteger( |
| 5241 args.GetReturnValue()->SetInteger((FXJSE_Value_IsNull(argFirst.get()) && | 5229 (argFirst->IsNull() && argSecond->IsNull()) ? 1 : 0); |
| 5242 FXJSE_Value_IsNull(argSecond.get())) | 5230 } else if (argFirst->IsString() && argSecond->IsString()) { |
| 5243 ? 1 | |
| 5244 : 0); | |
| 5245 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) && | |
| 5246 FXJSE_Value_IsUTF8String(argSecond.get())) { | |
| 5247 CFX_ByteString firstOutput; | 5231 CFX_ByteString firstOutput; |
| 5248 CFX_ByteString secondOutput; | 5232 CFX_ByteString secondOutput; |
| 5249 argFirst->ToString(firstOutput); | 5233 argFirst->ToString(firstOutput); |
| 5250 argSecond->ToString(secondOutput); | 5234 argSecond->ToString(secondOutput); |
| 5251 args.GetReturnValue()->SetInteger(firstOutput == secondOutput); | 5235 args.GetReturnValue()->SetInteger(firstOutput == secondOutput); |
| 5252 } else { | 5236 } else { |
| 5253 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5237 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5254 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5238 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5255 args.GetReturnValue()->SetInteger((first == second) ? 1 : 0); | 5239 args.GetReturnValue()->SetInteger((first == second) ? 1 : 0); |
| 5256 } | 5240 } |
| 5257 } | 5241 } |
| 5258 } else { | 5242 } else { |
| 5259 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5243 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5260 } | 5244 } |
| 5261 } | 5245 } |
| 5262 | 5246 |
| 5263 // static | 5247 // static |
| 5264 void CXFA_FM2JSContext::notequality_operator(CFXJSE_Value* pThis, | 5248 void CXFA_FM2JSContext::notequality_operator(CFXJSE_Value* pThis, |
| 5265 const CFX_ByteStringC& szFuncName, | 5249 const CFX_ByteStringC& szFuncName, |
| 5266 CFXJSE_Arguments& args) { | 5250 CFXJSE_Arguments& args) { |
| 5267 if (args.GetLength() == 2) { | 5251 if (args.GetLength() == 2) { |
| 5268 if (fm_ref_equal(pThis, args)) { | 5252 if (fm_ref_equal(pThis, args)) { |
| 5269 args.GetReturnValue()->SetInteger(0); | 5253 args.GetReturnValue()->SetInteger(0); |
| 5270 } else { | 5254 } else { |
| 5271 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5255 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5272 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5256 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5273 if (FXJSE_Value_IsNull(argFirst.get()) || | 5257 if (argFirst->IsNull() || argSecond->IsNull()) { |
| 5274 FXJSE_Value_IsNull(argSecond.get())) { | 5258 args.GetReturnValue()->SetInteger( |
| 5275 args.GetReturnValue()->SetInteger((FXJSE_Value_IsNull(argFirst.get()) && | 5259 (argFirst->IsNull() && argSecond->IsNull()) ? 0 : 1); |
| 5276 FXJSE_Value_IsNull(argSecond.get())) | 5260 } else if (argFirst->IsString() && argSecond->IsString()) { |
| 5277 ? 0 | |
| 5278 : 1); | |
| 5279 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) && | |
| 5280 FXJSE_Value_IsUTF8String(argSecond.get())) { | |
| 5281 CFX_ByteString firstOutput; | 5261 CFX_ByteString firstOutput; |
| 5282 CFX_ByteString secondOutput; | 5262 CFX_ByteString secondOutput; |
| 5283 argFirst->ToString(firstOutput); | 5263 argFirst->ToString(firstOutput); |
| 5284 argSecond->ToString(secondOutput); | 5264 argSecond->ToString(secondOutput); |
| 5285 args.GetReturnValue()->SetInteger(firstOutput != secondOutput); | 5265 args.GetReturnValue()->SetInteger(firstOutput != secondOutput); |
| 5286 } else { | 5266 } else { |
| 5287 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5267 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5288 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5268 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5289 args.GetReturnValue()->SetInteger(first != second); | 5269 args.GetReturnValue()->SetInteger(first != second); |
| 5290 } | 5270 } |
| 5291 } | 5271 } |
| 5292 } else { | 5272 } else { |
| 5293 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5273 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5294 } | 5274 } |
| 5295 } | 5275 } |
| 5296 | 5276 |
| 5297 // static | 5277 // static |
| 5298 FX_BOOL CXFA_FM2JSContext::fm_ref_equal(CFXJSE_Value* pThis, | 5278 FX_BOOL CXFA_FM2JSContext::fm_ref_equal(CFXJSE_Value* pThis, |
| 5299 CFXJSE_Arguments& args) { | 5279 CFXJSE_Arguments& args) { |
| 5300 FX_BOOL bRet = FALSE; | 5280 FX_BOOL bRet = FALSE; |
| 5301 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); | 5281 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); |
| 5302 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0); | 5282 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0); |
| 5303 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1); | 5283 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1); |
| 5304 if (FXJSE_Value_IsArray(argFirst.get()) && | 5284 if (argFirst->IsArray() && argSecond->IsArray()) { |
| 5305 FXJSE_Value_IsArray(argSecond.get())) { | |
| 5306 std::unique_ptr<CFXJSE_Value> firstFlagValue(new CFXJSE_Value(pIsolate)); | 5285 std::unique_ptr<CFXJSE_Value> firstFlagValue(new CFXJSE_Value(pIsolate)); |
| 5307 std::unique_ptr<CFXJSE_Value> secondFlagValue(new CFXJSE_Value(pIsolate)); | 5286 std::unique_ptr<CFXJSE_Value> secondFlagValue(new CFXJSE_Value(pIsolate)); |
| 5308 argFirst->GetObjectPropertyByIdx(0, firstFlagValue.get()); | 5287 argFirst->GetObjectPropertyByIdx(0, firstFlagValue.get()); |
| 5309 argSecond->GetObjectPropertyByIdx(0, secondFlagValue.get()); | 5288 argSecond->GetObjectPropertyByIdx(0, secondFlagValue.get()); |
| 5310 if (firstFlagValue->ToInteger() == 3 && secondFlagValue->ToInteger() == 3) { | 5289 if (firstFlagValue->ToInteger() == 3 && secondFlagValue->ToInteger() == 3) { |
| 5311 std::unique_ptr<CFXJSE_Value> firstJSObject(new CFXJSE_Value(pIsolate)); | 5290 std::unique_ptr<CFXJSE_Value> firstJSObject(new CFXJSE_Value(pIsolate)); |
| 5312 std::unique_ptr<CFXJSE_Value> secondJSObject(new CFXJSE_Value(pIsolate)); | 5291 std::unique_ptr<CFXJSE_Value> secondJSObject(new CFXJSE_Value(pIsolate)); |
| 5313 argFirst->GetObjectPropertyByIdx(2, firstJSObject.get()); | 5292 argFirst->GetObjectPropertyByIdx(2, firstJSObject.get()); |
| 5314 argSecond->GetObjectPropertyByIdx(2, secondJSObject.get()); | 5293 argSecond->GetObjectPropertyByIdx(2, secondJSObject.get()); |
| 5315 if (!FXJSE_Value_IsNull(firstJSObject.get()) && | 5294 if (!firstJSObject->IsNull() && !secondJSObject->IsNull()) { |
| 5316 !FXJSE_Value_IsNull(secondJSObject.get())) { | |
| 5317 bRet = (firstJSObject->ToHostObject(nullptr) == | 5295 bRet = (firstJSObject->ToHostObject(nullptr) == |
| 5318 secondJSObject->ToHostObject(nullptr)); | 5296 secondJSObject->ToHostObject(nullptr)); |
| 5319 } | 5297 } |
| 5320 } | 5298 } |
| 5321 } | 5299 } |
| 5322 return bRet; | 5300 return bRet; |
| 5323 } | 5301 } |
| 5324 | 5302 |
| 5325 // static | 5303 // static |
| 5326 void CXFA_FM2JSContext::less_operator(CFXJSE_Value* pThis, | 5304 void CXFA_FM2JSContext::less_operator(CFXJSE_Value* pThis, |
| 5327 const CFX_ByteStringC& szFuncName, | 5305 const CFX_ByteStringC& szFuncName, |
| 5328 CFXJSE_Arguments& args) { | 5306 CFXJSE_Arguments& args) { |
| 5329 if (args.GetLength() == 2) { | 5307 if (args.GetLength() == 2) { |
| 5330 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5308 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5331 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5309 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5332 if (FXJSE_Value_IsNull(argFirst.get()) || | 5310 if (argFirst->IsNull() || argSecond->IsNull()) { |
| 5333 FXJSE_Value_IsNull(argSecond.get())) { | |
| 5334 args.GetReturnValue()->SetInteger(0); | 5311 args.GetReturnValue()->SetInteger(0); |
| 5335 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) && | 5312 } else if (argFirst->IsString() && argSecond->IsString()) { |
| 5336 FXJSE_Value_IsUTF8String(argSecond.get())) { | |
| 5337 CFX_ByteString firstOutput; | 5313 CFX_ByteString firstOutput; |
| 5338 CFX_ByteString secondOutput; | 5314 CFX_ByteString secondOutput; |
| 5339 argFirst->ToString(firstOutput); | 5315 argFirst->ToString(firstOutput); |
| 5340 argSecond->ToString(secondOutput); | 5316 argSecond->ToString(secondOutput); |
| 5341 args.GetReturnValue()->SetInteger( | 5317 args.GetReturnValue()->SetInteger( |
| 5342 firstOutput.Compare(secondOutput.AsStringC()) == -1); | 5318 firstOutput.Compare(secondOutput.AsStringC()) == -1); |
| 5343 } else { | 5319 } else { |
| 5344 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5320 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5345 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5321 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5346 args.GetReturnValue()->SetInteger((first < second) ? 1 : 0); | 5322 args.GetReturnValue()->SetInteger((first < second) ? 1 : 0); |
| 5347 } | 5323 } |
| 5348 } else { | 5324 } else { |
| 5349 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5325 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5350 } | 5326 } |
| 5351 } | 5327 } |
| 5352 | 5328 |
| 5353 // static | 5329 // static |
| 5354 void CXFA_FM2JSContext::lessequal_operator(CFXJSE_Value* pThis, | 5330 void CXFA_FM2JSContext::lessequal_operator(CFXJSE_Value* pThis, |
| 5355 const CFX_ByteStringC& szFuncName, | 5331 const CFX_ByteStringC& szFuncName, |
| 5356 CFXJSE_Arguments& args) { | 5332 CFXJSE_Arguments& args) { |
| 5357 if (args.GetLength() == 2) { | 5333 if (args.GetLength() == 2) { |
| 5358 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5334 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5359 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5335 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5360 if (FXJSE_Value_IsNull(argFirst.get()) || | 5336 if (argFirst->IsNull() || argSecond->IsNull()) { |
| 5361 FXJSE_Value_IsNull(argSecond.get())) { | 5337 args.GetReturnValue()->SetInteger( |
| 5362 args.GetReturnValue()->SetInteger((FXJSE_Value_IsNull(argFirst.get()) && | 5338 (argFirst->IsNull() && argSecond->IsNull()) ? 1 : 0); |
| 5363 FXJSE_Value_IsNull(argSecond.get())) | 5339 } else if (argFirst->IsString() && argSecond->IsString()) { |
| 5364 ? 1 | |
| 5365 : 0); | |
| 5366 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) && | |
| 5367 FXJSE_Value_IsUTF8String(argSecond.get())) { | |
| 5368 CFX_ByteString firstOutput; | 5340 CFX_ByteString firstOutput; |
| 5369 CFX_ByteString secondOutput; | 5341 CFX_ByteString secondOutput; |
| 5370 argFirst->ToString(firstOutput); | 5342 argFirst->ToString(firstOutput); |
| 5371 argSecond->ToString(secondOutput); | 5343 argSecond->ToString(secondOutput); |
| 5372 args.GetReturnValue()->SetInteger( | 5344 args.GetReturnValue()->SetInteger( |
| 5373 firstOutput.Compare(secondOutput.AsStringC()) != 1); | 5345 firstOutput.Compare(secondOutput.AsStringC()) != 1); |
| 5374 } else { | 5346 } else { |
| 5375 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5347 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5376 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5348 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5377 args.GetReturnValue()->SetInteger((first <= second) ? 1 : 0); | 5349 args.GetReturnValue()->SetInteger((first <= second) ? 1 : 0); |
| 5378 } | 5350 } |
| 5379 } else { | 5351 } else { |
| 5380 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5352 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5381 } | 5353 } |
| 5382 } | 5354 } |
| 5383 | 5355 |
| 5384 // static | 5356 // static |
| 5385 void CXFA_FM2JSContext::greater_operator(CFXJSE_Value* pThis, | 5357 void CXFA_FM2JSContext::greater_operator(CFXJSE_Value* pThis, |
| 5386 const CFX_ByteStringC& szFuncName, | 5358 const CFX_ByteStringC& szFuncName, |
| 5387 CFXJSE_Arguments& args) { | 5359 CFXJSE_Arguments& args) { |
| 5388 if (args.GetLength() == 2) { | 5360 if (args.GetLength() == 2) { |
| 5389 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5361 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5390 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5362 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5391 if (FXJSE_Value_IsNull(argFirst.get()) || | 5363 if (argFirst->IsNull() || argSecond->IsNull()) { |
| 5392 FXJSE_Value_IsNull(argSecond.get())) { | |
| 5393 args.GetReturnValue()->SetInteger(0); | 5364 args.GetReturnValue()->SetInteger(0); |
| 5394 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) && | 5365 } else if (argFirst->IsString() && argSecond->IsString()) { |
| 5395 FXJSE_Value_IsUTF8String(argSecond.get())) { | |
| 5396 CFX_ByteString firstOutput; | 5366 CFX_ByteString firstOutput; |
| 5397 CFX_ByteString secondOutput; | 5367 CFX_ByteString secondOutput; |
| 5398 argFirst->ToString(firstOutput); | 5368 argFirst->ToString(firstOutput); |
| 5399 argSecond->ToString(secondOutput); | 5369 argSecond->ToString(secondOutput); |
| 5400 args.GetReturnValue()->SetInteger( | 5370 args.GetReturnValue()->SetInteger( |
| 5401 firstOutput.Compare(secondOutput.AsStringC()) == 1); | 5371 firstOutput.Compare(secondOutput.AsStringC()) == 1); |
| 5402 } else { | 5372 } else { |
| 5403 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5373 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5404 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5374 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5405 args.GetReturnValue()->SetInteger((first > second) ? 1 : 0); | 5375 args.GetReturnValue()->SetInteger((first > second) ? 1 : 0); |
| 5406 } | 5376 } |
| 5407 } else { | 5377 } else { |
| 5408 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5378 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5409 } | 5379 } |
| 5410 } | 5380 } |
| 5411 | 5381 |
| 5412 // static | 5382 // static |
| 5413 void CXFA_FM2JSContext::greaterequal_operator(CFXJSE_Value* pThis, | 5383 void CXFA_FM2JSContext::greaterequal_operator(CFXJSE_Value* pThis, |
| 5414 const CFX_ByteStringC& szFuncName, | 5384 const CFX_ByteStringC& szFuncName, |
| 5415 CFXJSE_Arguments& args) { | 5385 CFXJSE_Arguments& args) { |
| 5416 if (args.GetLength() == 2) { | 5386 if (args.GetLength() == 2) { |
| 5417 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5387 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5418 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5388 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5419 if (FXJSE_Value_IsNull(argFirst.get()) || | 5389 if (argFirst->IsNull() || argSecond->IsNull()) { |
| 5420 FXJSE_Value_IsNull(argSecond.get())) { | 5390 args.GetReturnValue()->SetInteger( |
| 5421 args.GetReturnValue()->SetInteger((FXJSE_Value_IsNull(argFirst.get()) && | 5391 (argFirst->IsNull() && argSecond->IsNull()) ? 1 : 0); |
| 5422 FXJSE_Value_IsNull(argSecond.get())) | 5392 } else if (argFirst->IsString() && argSecond->IsString()) { |
| 5423 ? 1 | |
| 5424 : 0); | |
| 5425 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) && | |
| 5426 FXJSE_Value_IsUTF8String(argSecond.get())) { | |
| 5427 CFX_ByteString firstOutput; | 5393 CFX_ByteString firstOutput; |
| 5428 CFX_ByteString secondOutput; | 5394 CFX_ByteString secondOutput; |
| 5429 argFirst->ToString(firstOutput); | 5395 argFirst->ToString(firstOutput); |
| 5430 argSecond->ToString(secondOutput); | 5396 argSecond->ToString(secondOutput); |
| 5431 args.GetReturnValue()->SetInteger( | 5397 args.GetReturnValue()->SetInteger( |
| 5432 firstOutput.Compare(secondOutput.AsStringC()) != -1); | 5398 firstOutput.Compare(secondOutput.AsStringC()) != -1); |
| 5433 } else { | 5399 } else { |
| 5434 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5400 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5435 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5401 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5436 args.GetReturnValue()->SetInteger((first >= second) ? 1 : 0); | 5402 args.GetReturnValue()->SetInteger((first >= second) ? 1 : 0); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 5460 } | 5426 } |
| 5461 } | 5427 } |
| 5462 | 5428 |
| 5463 // static | 5429 // static |
| 5464 void CXFA_FM2JSContext::minus_operator(CFXJSE_Value* pThis, | 5430 void CXFA_FM2JSContext::minus_operator(CFXJSE_Value* pThis, |
| 5465 const CFX_ByteStringC& szFuncName, | 5431 const CFX_ByteStringC& szFuncName, |
| 5466 CFXJSE_Arguments& args) { | 5432 CFXJSE_Arguments& args) { |
| 5467 if (args.GetLength() == 2) { | 5433 if (args.GetLength() == 2) { |
| 5468 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5434 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5469 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5435 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5470 if (FXJSE_Value_IsNull(argFirst.get()) && | 5436 if (argFirst->IsNull() && argSecond->IsNull()) { |
| 5471 FXJSE_Value_IsNull(argSecond.get())) { | |
| 5472 args.GetReturnValue()->SetNull(); | 5437 args.GetReturnValue()->SetNull(); |
| 5473 } else { | 5438 } else { |
| 5474 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5439 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5475 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5440 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5476 args.GetReturnValue()->SetDouble(first - second); | 5441 args.GetReturnValue()->SetDouble(first - second); |
| 5477 } | 5442 } |
| 5478 } else { | 5443 } else { |
| 5479 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5444 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5480 } | 5445 } |
| 5481 } | 5446 } |
| 5482 | 5447 |
| 5483 // static | 5448 // static |
| 5484 void CXFA_FM2JSContext::multiple_operator(CFXJSE_Value* pThis, | 5449 void CXFA_FM2JSContext::multiple_operator(CFXJSE_Value* pThis, |
| 5485 const CFX_ByteStringC& szFuncName, | 5450 const CFX_ByteStringC& szFuncName, |
| 5486 CFXJSE_Arguments& args) { | 5451 CFXJSE_Arguments& args) { |
| 5487 if (args.GetLength() == 2) { | 5452 if (args.GetLength() == 2) { |
| 5488 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5453 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5489 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5454 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5490 if (FXJSE_Value_IsNull(argFirst.get()) && | 5455 if (argFirst->IsNull() && argSecond->IsNull()) { |
| 5491 FXJSE_Value_IsNull(argSecond.get())) { | |
| 5492 args.GetReturnValue()->SetNull(); | 5456 args.GetReturnValue()->SetNull(); |
| 5493 } else { | 5457 } else { |
| 5494 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5458 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5495 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5459 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5496 args.GetReturnValue()->SetDouble(first * second); | 5460 args.GetReturnValue()->SetDouble(first * second); |
| 5497 } | 5461 } |
| 5498 } else { | 5462 } else { |
| 5499 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5463 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5500 } | 5464 } |
| 5501 } | 5465 } |
| 5502 | 5466 |
| 5503 // static | 5467 // static |
| 5504 void CXFA_FM2JSContext::divide_operator(CFXJSE_Value* pThis, | 5468 void CXFA_FM2JSContext::divide_operator(CFXJSE_Value* pThis, |
| 5505 const CFX_ByteStringC& szFuncName, | 5469 const CFX_ByteStringC& szFuncName, |
| 5506 CFXJSE_Arguments& args) { | 5470 CFXJSE_Arguments& args) { |
| 5507 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); | 5471 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); |
| 5508 if (args.GetLength() == 2) { | 5472 if (args.GetLength() == 2) { |
| 5509 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5473 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5510 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5474 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5511 if (FXJSE_Value_IsNull(argFirst.get()) && | 5475 if (argFirst->IsNull() && argSecond->IsNull()) { |
| 5512 FXJSE_Value_IsNull(argSecond.get())) { | |
| 5513 args.GetReturnValue()->SetNull(); | 5476 args.GetReturnValue()->SetNull(); |
| 5514 } else { | 5477 } else { |
| 5515 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5478 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5516 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5479 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5517 if (second == 0.0) { | 5480 if (second == 0.0) { |
| 5518 pContext->ThrowException(XFA_IDS_DIVIDE_ZERO); | 5481 pContext->ThrowException(XFA_IDS_DIVIDE_ZERO); |
| 5519 } else { | 5482 } else { |
| 5520 args.GetReturnValue()->SetDouble(first / second); | 5483 args.GetReturnValue()->SetDouble(first / second); |
| 5521 } | 5484 } |
| 5522 } | 5485 } |
| 5523 } else { | 5486 } else { |
| 5524 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); | 5487 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5525 } | 5488 } |
| 5526 } | 5489 } |
| 5527 | 5490 |
| 5528 // static | 5491 // static |
| 5529 void CXFA_FM2JSContext::positive_operator(CFXJSE_Value* pThis, | 5492 void CXFA_FM2JSContext::positive_operator(CFXJSE_Value* pThis, |
| 5530 const CFX_ByteStringC& szFuncName, | 5493 const CFX_ByteStringC& szFuncName, |
| 5531 CFXJSE_Arguments& args) { | 5494 CFXJSE_Arguments& args) { |
| 5532 if (args.GetLength() == 1) { | 5495 if (args.GetLength() == 1) { |
| 5533 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 5496 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 5534 if (FXJSE_Value_IsNull(argOne.get())) { | 5497 if (argOne->IsNull()) { |
| 5535 args.GetReturnValue()->SetNull(); | 5498 args.GetReturnValue()->SetNull(); |
| 5536 } else { | 5499 } else { |
| 5537 args.GetReturnValue()->SetDouble(0.0 + | 5500 args.GetReturnValue()->SetDouble(0.0 + |
| 5538 ValueToDouble(pThis, argOne.get())); | 5501 ValueToDouble(pThis, argOne.get())); |
| 5539 } | 5502 } |
| 5540 } else { | 5503 } else { |
| 5541 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5504 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5542 } | 5505 } |
| 5543 } | 5506 } |
| 5544 | 5507 |
| 5545 // static | 5508 // static |
| 5546 void CXFA_FM2JSContext::negative_operator(CFXJSE_Value* pThis, | 5509 void CXFA_FM2JSContext::negative_operator(CFXJSE_Value* pThis, |
| 5547 const CFX_ByteStringC& szFuncName, | 5510 const CFX_ByteStringC& szFuncName, |
| 5548 CFXJSE_Arguments& args) { | 5511 CFXJSE_Arguments& args) { |
| 5549 if (args.GetLength() == 1) { | 5512 if (args.GetLength() == 1) { |
| 5550 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 5513 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 5551 if (FXJSE_Value_IsNull(argOne.get())) { | 5514 if (argOne->IsNull()) { |
| 5552 args.GetReturnValue()->SetNull(); | 5515 args.GetReturnValue()->SetNull(); |
| 5553 } else { | 5516 } else { |
| 5554 args.GetReturnValue()->SetDouble(0.0 - | 5517 args.GetReturnValue()->SetDouble(0.0 - |
| 5555 ValueToDouble(pThis, argOne.get())); | 5518 ValueToDouble(pThis, argOne.get())); |
| 5556 } | 5519 } |
| 5557 } else { | 5520 } else { |
| 5558 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5521 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5559 } | 5522 } |
| 5560 } | 5523 } |
| 5561 | 5524 |
| 5562 // static | 5525 // static |
| 5563 void CXFA_FM2JSContext::logical_not_operator(CFXJSE_Value* pThis, | 5526 void CXFA_FM2JSContext::logical_not_operator(CFXJSE_Value* pThis, |
| 5564 const CFX_ByteStringC& szFuncName, | 5527 const CFX_ByteStringC& szFuncName, |
| 5565 CFXJSE_Arguments& args) { | 5528 CFXJSE_Arguments& args) { |
| 5566 if (args.GetLength() == 1) { | 5529 if (args.GetLength() == 1) { |
| 5567 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 5530 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 5568 if (FXJSE_Value_IsNull(argOne.get())) { | 5531 if (argOne->IsNull()) { |
| 5569 args.GetReturnValue()->SetNull(); | 5532 args.GetReturnValue()->SetNull(); |
| 5570 } else { | 5533 } else { |
| 5571 FX_DOUBLE first = ValueToDouble(pThis, argOne.get()); | 5534 FX_DOUBLE first = ValueToDouble(pThis, argOne.get()); |
| 5572 args.GetReturnValue()->SetInteger((first == 0.0) ? 1 : 0); | 5535 args.GetReturnValue()->SetInteger((first == 0.0) ? 1 : 0); |
| 5573 } | 5536 } |
| 5574 } else { | 5537 } else { |
| 5575 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5538 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5576 } | 5539 } |
| 5577 } | 5540 } |
| 5578 | 5541 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 5591 int32_t iIndexFlags = args.GetInt32(3); | 5554 int32_t iIndexFlags = args.GetInt32(3); |
| 5592 int32_t iIndexValue = 0; | 5555 int32_t iIndexValue = 0; |
| 5593 if (argc > 4) { | 5556 if (argc > 4) { |
| 5594 bIsStar = FALSE; | 5557 bIsStar = FALSE; |
| 5595 std::unique_ptr<CFXJSE_Value> argIndex = args.GetValue(4); | 5558 std::unique_ptr<CFXJSE_Value> argIndex = args.GetValue(4); |
| 5596 iIndexValue = ValueToInteger(pThis, argIndex.get()); | 5559 iIndexValue = ValueToInteger(pThis, argIndex.get()); |
| 5597 } | 5560 } |
| 5598 CFX_ByteString szSomExp; | 5561 CFX_ByteString szSomExp; |
| 5599 GenerateSomExpression(szName.AsStringC(), iIndexFlags, iIndexValue, bIsStar, | 5562 GenerateSomExpression(szName.AsStringC(), iIndexFlags, iIndexValue, bIsStar, |
| 5600 szSomExp); | 5563 szSomExp); |
| 5601 if (FXJSE_Value_IsArray(argAccessor.get())) { | 5564 if (argAccessor->IsArray()) { |
| 5602 std::unique_ptr<CFXJSE_Value> pLengthValue(new CFXJSE_Value(pIsolate)); | 5565 std::unique_ptr<CFXJSE_Value> pLengthValue(new CFXJSE_Value(pIsolate)); |
| 5603 argAccessor->GetObjectProperty("length", pLengthValue.get()); | 5566 argAccessor->GetObjectProperty("length", pLengthValue.get()); |
| 5604 int32_t iLength = pLengthValue->ToInteger(); | 5567 int32_t iLength = pLengthValue->ToInteger(); |
| 5605 int32_t iCounter = 0; | 5568 int32_t iCounter = 0; |
| 5606 CFXJSE_Value*** hResolveValues = FX_Alloc(CFXJSE_Value**, iLength - 2); | 5569 CFXJSE_Value*** hResolveValues = FX_Alloc(CFXJSE_Value**, iLength - 2); |
| 5607 int32_t* iSizes = FX_Alloc(int32_t, iLength - 2); | 5570 int32_t* iSizes = FX_Alloc(int32_t, iLength - 2); |
| 5608 for (int32_t i = 0; i < (iLength - 2); i++) { | 5571 for (int32_t i = 0; i < (iLength - 2); i++) { |
| 5609 iSizes[i] = 0; | 5572 iSizes[i] = 0; |
| 5610 } | 5573 } |
| 5611 std::unique_ptr<CFXJSE_Value> hJSObjValue(new CFXJSE_Value(pIsolate)); | 5574 std::unique_ptr<CFXJSE_Value> hJSObjValue(new CFXJSE_Value(pIsolate)); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5660 | 5623 |
| 5661 if (iSizes[i] > 0) { | 5624 if (iSizes[i] > 0) { |
| 5662 FX_Free(hResolveValues[i]); | 5625 FX_Free(hResolveValues[i]); |
| 5663 } | 5626 } |
| 5664 } | 5627 } |
| 5665 FX_Free(hResolveValues); | 5628 FX_Free(hResolveValues); |
| 5666 FX_Free(iSizes); | 5629 FX_Free(iSizes); |
| 5667 } else { | 5630 } else { |
| 5668 XFA_RESOLVENODE_RS resoveNodeRS; | 5631 XFA_RESOLVENODE_RS resoveNodeRS; |
| 5669 int32_t iRet = 0; | 5632 int32_t iRet = 0; |
| 5670 if (FXJSE_Value_IsObject(argAccessor.get()) || | 5633 if (argAccessor->IsObject() || |
| 5671 (FXJSE_Value_IsNull(argAccessor.get()) && bsAccessorName.IsEmpty())) { | 5634 (argAccessor->IsNull() && bsAccessorName.IsEmpty())) { |
| 5672 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), | 5635 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), |
| 5673 resoveNodeRS, TRUE, szName.IsEmpty()); | 5636 resoveNodeRS, TRUE, szName.IsEmpty()); |
| 5674 } else if (!FXJSE_Value_IsObject(argAccessor.get()) && | 5637 } else if (!argAccessor->IsObject() && !bsAccessorName.IsEmpty()) { |
| 5675 !bsAccessorName.IsEmpty()) { | |
| 5676 FX_BOOL bGetObject = GetObjectByName(pThis, argAccessor.get(), | 5638 FX_BOOL bGetObject = GetObjectByName(pThis, argAccessor.get(), |
| 5677 bsAccessorName.AsStringC()); | 5639 bsAccessorName.AsStringC()); |
| 5678 if (bGetObject) { | 5640 if (bGetObject) { |
| 5679 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), | 5641 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), |
| 5680 resoveNodeRS, TRUE, szName.IsEmpty()); | 5642 resoveNodeRS, TRUE, szName.IsEmpty()); |
| 5681 } | 5643 } |
| 5682 } | 5644 } |
| 5683 if (iRet > 0) { | 5645 if (iRet > 0) { |
| 5684 CFXJSE_Value** hResolveValues; | 5646 CFXJSE_Value** hResolveValues; |
| 5685 int32_t iSize = 0; | 5647 int32_t iSize = 0; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5738 int32_t iIndexFlags = args.GetInt32(3); | 5700 int32_t iIndexFlags = args.GetInt32(3); |
| 5739 int32_t iIndexValue = 0; | 5701 int32_t iIndexValue = 0; |
| 5740 if (argc > 4) { | 5702 if (argc > 4) { |
| 5741 bIsStar = FALSE; | 5703 bIsStar = FALSE; |
| 5742 std::unique_ptr<CFXJSE_Value> argIndex = args.GetValue(4); | 5704 std::unique_ptr<CFXJSE_Value> argIndex = args.GetValue(4); |
| 5743 iIndexValue = ValueToInteger(pThis, argIndex.get()); | 5705 iIndexValue = ValueToInteger(pThis, argIndex.get()); |
| 5744 } | 5706 } |
| 5745 CFX_ByteString szSomExp; | 5707 CFX_ByteString szSomExp; |
| 5746 GenerateSomExpression(szName.AsStringC(), iIndexFlags, iIndexValue, bIsStar, | 5708 GenerateSomExpression(szName.AsStringC(), iIndexFlags, iIndexValue, bIsStar, |
| 5747 szSomExp); | 5709 szSomExp); |
| 5748 if (FXJSE_Value_IsArray(argAccessor.get())) { | 5710 if (argAccessor->IsArray()) { |
| 5749 std::unique_ptr<CFXJSE_Value> pLengthValue(new CFXJSE_Value(pIsolate)); | 5711 std::unique_ptr<CFXJSE_Value> pLengthValue(new CFXJSE_Value(pIsolate)); |
| 5750 argAccessor->GetObjectProperty("length", pLengthValue.get()); | 5712 argAccessor->GetObjectProperty("length", pLengthValue.get()); |
| 5751 int32_t iLength = pLengthValue->ToInteger(); | 5713 int32_t iLength = pLengthValue->ToInteger(); |
| 5752 int32_t iCounter = 0; | 5714 int32_t iCounter = 0; |
| 5753 CFXJSE_Value*** hResolveValues = FX_Alloc(CFXJSE_Value**, iLength - 2); | 5715 CFXJSE_Value*** hResolveValues = FX_Alloc(CFXJSE_Value**, iLength - 2); |
| 5754 int32_t* iSizes = FX_Alloc(int32_t, iLength - 2); | 5716 int32_t* iSizes = FX_Alloc(int32_t, iLength - 2); |
| 5755 std::unique_ptr<CFXJSE_Value> hJSObjValue(new CFXJSE_Value(pIsolate)); | 5717 std::unique_ptr<CFXJSE_Value> hJSObjValue(new CFXJSE_Value(pIsolate)); |
| 5756 FX_BOOL bAttribute = FALSE; | 5718 FX_BOOL bAttribute = FALSE; |
| 5757 for (int32_t i = 2; i < iLength; i++) { | 5719 for (int32_t i = 2; i < iLength; i++) { |
| 5758 argAccessor->GetObjectPropertyByIdx(i, hJSObjValue.get()); | 5720 argAccessor->GetObjectPropertyByIdx(i, hJSObjValue.get()); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5802 for (int32_t j = 0; j < iSizes[i]; j++) | 5764 for (int32_t j = 0; j < iSizes[i]; j++) |
| 5803 delete hResolveValues[i][j]; | 5765 delete hResolveValues[i][j]; |
| 5804 | 5766 |
| 5805 FX_Free(hResolveValues[i]); | 5767 FX_Free(hResolveValues[i]); |
| 5806 } | 5768 } |
| 5807 FX_Free(hResolveValues); | 5769 FX_Free(hResolveValues); |
| 5808 FX_Free(iSizes); | 5770 FX_Free(iSizes); |
| 5809 } else { | 5771 } else { |
| 5810 XFA_RESOLVENODE_RS resoveNodeRS; | 5772 XFA_RESOLVENODE_RS resoveNodeRS; |
| 5811 int32_t iRet = 0; | 5773 int32_t iRet = 0; |
| 5812 if (FXJSE_Value_IsObject(argAccessor.get()) || | 5774 if (argAccessor->IsObject() || |
| 5813 (FXJSE_Value_IsNull(argAccessor.get()) && bsAccessorName.IsEmpty())) { | 5775 (argAccessor->IsNull() && bsAccessorName.IsEmpty())) { |
| 5814 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), | 5776 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), |
| 5815 resoveNodeRS, FALSE); | 5777 resoveNodeRS, FALSE); |
| 5816 } else if (!FXJSE_Value_IsObject(argAccessor.get()) && | 5778 } else if (!argAccessor->IsObject() && !bsAccessorName.IsEmpty()) { |
| 5817 !bsAccessorName.IsEmpty()) { | |
| 5818 FX_BOOL bGetObject = GetObjectByName(pThis, argAccessor.get(), | 5779 FX_BOOL bGetObject = GetObjectByName(pThis, argAccessor.get(), |
| 5819 bsAccessorName.AsStringC()); | 5780 bsAccessorName.AsStringC()); |
| 5820 if (bGetObject) { | 5781 if (bGetObject) { |
| 5821 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), | 5782 iRet = ResolveObjects(pThis, argAccessor.get(), szSomExp.AsStringC(), |
| 5822 resoveNodeRS, FALSE); | 5783 resoveNodeRS, FALSE); |
| 5823 } | 5784 } |
| 5824 } | 5785 } |
| 5825 if (iRet > 0) { | 5786 if (iRet > 0) { |
| 5826 CFXJSE_Value** hResolveValues; | 5787 CFXJSE_Value** hResolveValues; |
| 5827 int32_t iSize = 0; | 5788 int32_t iSize = 0; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5896 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Eval"); | 5857 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Eval"); |
| 5897 } | 5858 } |
| 5898 } | 5859 } |
| 5899 | 5860 |
| 5900 // static | 5861 // static |
| 5901 void CXFA_FM2JSContext::is_fm_object(CFXJSE_Value* pThis, | 5862 void CXFA_FM2JSContext::is_fm_object(CFXJSE_Value* pThis, |
| 5902 const CFX_ByteStringC& szFuncName, | 5863 const CFX_ByteStringC& szFuncName, |
| 5903 CFXJSE_Arguments& args) { | 5864 CFXJSE_Arguments& args) { |
| 5904 if (args.GetLength() == 1) { | 5865 if (args.GetLength() == 1) { |
| 5905 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 5866 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 5906 args.GetReturnValue()->SetBoolean(FXJSE_Value_IsObject(argOne.get())); | 5867 args.GetReturnValue()->SetBoolean(argOne->IsObject()); |
| 5907 } else { | 5868 } else { |
| 5908 args.GetReturnValue()->SetBoolean(FALSE); | 5869 args.GetReturnValue()->SetBoolean(FALSE); |
| 5909 } | 5870 } |
| 5910 } | 5871 } |
| 5911 | 5872 |
| 5912 // static | 5873 // static |
| 5913 void CXFA_FM2JSContext::is_fm_array(CFXJSE_Value* pThis, | 5874 void CXFA_FM2JSContext::is_fm_array(CFXJSE_Value* pThis, |
| 5914 const CFX_ByteStringC& szFuncName, | 5875 const CFX_ByteStringC& szFuncName, |
| 5915 CFXJSE_Arguments& args) { | 5876 CFXJSE_Arguments& args) { |
| 5916 if (args.GetLength() == 1) { | 5877 if (args.GetLength() == 1) { |
| 5917 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 5878 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 5918 FX_BOOL bIsArray = FXJSE_Value_IsArray(argOne.get()); | 5879 args.GetReturnValue()->SetBoolean(argOne->IsArray()); |
| 5919 args.GetReturnValue()->SetBoolean(bIsArray); | |
| 5920 } else { | 5880 } else { |
| 5921 args.GetReturnValue()->SetBoolean(FALSE); | 5881 args.GetReturnValue()->SetBoolean(FALSE); |
| 5922 } | 5882 } |
| 5923 } | 5883 } |
| 5924 | 5884 |
| 5925 // static | 5885 // static |
| 5926 void CXFA_FM2JSContext::get_fm_value(CFXJSE_Value* pThis, | 5886 void CXFA_FM2JSContext::get_fm_value(CFXJSE_Value* pThis, |
| 5927 const CFX_ByteStringC& szFuncName, | 5887 const CFX_ByteStringC& szFuncName, |
| 5928 CFXJSE_Arguments& args) { | 5888 CFXJSE_Arguments& args) { |
| 5929 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); | 5889 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); |
| 5930 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 5890 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 5931 if (args.GetLength() == 1) { | 5891 if (args.GetLength() == 1) { |
| 5932 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 5892 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 5933 if (FXJSE_Value_IsArray(argOne.get())) { | 5893 if (argOne->IsArray()) { |
| 5934 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 5894 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 5935 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 5895 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 5936 argOne->GetObjectPropertyByIdx(1, propertyValue.get()); | 5896 argOne->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 5937 argOne->GetObjectPropertyByIdx(2, jsObjectValue.get()); | 5897 argOne->GetObjectPropertyByIdx(2, jsObjectValue.get()); |
| 5938 if (FXJSE_Value_IsNull(propertyValue.get())) { | 5898 if (propertyValue->IsNull()) { |
| 5939 GetObjectDefaultValue(jsObjectValue.get(), args.GetReturnValue()); | 5899 GetObjectDefaultValue(jsObjectValue.get(), args.GetReturnValue()); |
| 5940 } else { | 5900 } else { |
| 5941 CFX_ByteString propertyStr; | 5901 CFX_ByteString propertyStr; |
| 5942 propertyValue->ToString(propertyStr); | 5902 propertyValue->ToString(propertyStr); |
| 5943 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), | 5903 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), |
| 5944 args.GetReturnValue()); | 5904 args.GetReturnValue()); |
| 5945 } | 5905 } |
| 5946 } else if (FXJSE_Value_IsObject(argOne.get())) { | 5906 } else if (argOne->IsObject()) { |
| 5947 GetObjectDefaultValue(argOne.get(), args.GetReturnValue()); | 5907 GetObjectDefaultValue(argOne.get(), args.GetReturnValue()); |
| 5948 } else { | 5908 } else { |
| 5949 args.GetReturnValue()->Assign(argOne.get()); | 5909 args.GetReturnValue()->Assign(argOne.get()); |
| 5950 } | 5910 } |
| 5951 } else { | 5911 } else { |
| 5952 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); | 5912 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5953 } | 5913 } |
| 5954 } | 5914 } |
| 5955 | 5915 |
| 5956 // static | 5916 // static |
| 5957 void CXFA_FM2JSContext::get_fm_jsobj(CFXJSE_Value* pThis, | 5917 void CXFA_FM2JSContext::get_fm_jsobj(CFXJSE_Value* pThis, |
| 5958 const CFX_ByteStringC& szFuncName, | 5918 const CFX_ByteStringC& szFuncName, |
| 5959 CFXJSE_Arguments& args) { | 5919 CFXJSE_Arguments& args) { |
| 5960 if (args.GetLength() == 1) { | 5920 if (args.GetLength() == 1) { |
| 5961 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 5921 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 5962 if (FXJSE_Value_IsArray(argOne.get())) { | 5922 if (argOne->IsArray()) { |
| 5963 #ifndef NDEBUG | 5923 #ifndef NDEBUG |
| 5964 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); | 5924 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); |
| 5965 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 5925 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 5966 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 5926 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 5967 argOne->GetObjectProperty("length", lengthValue.get()); | 5927 argOne->GetObjectProperty("length", lengthValue.get()); |
| 5968 ASSERT(lengthValue->ToInteger() >= 3); | 5928 ASSERT(lengthValue->ToInteger() >= 3); |
| 5969 #endif | 5929 #endif |
| 5970 argOne->GetObjectPropertyByIdx(2, args.GetReturnValue()); | 5930 argOne->GetObjectPropertyByIdx(2, args.GetReturnValue()); |
| 5971 } else { | 5931 } else { |
| 5972 args.GetReturnValue()->Assign(argOne.get()); | 5932 args.GetReturnValue()->Assign(argOne.get()); |
| 5973 } | 5933 } |
| 5974 } else { | 5934 } else { |
| 5975 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); | 5935 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); |
| 5976 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); | 5936 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5977 } | 5937 } |
| 5978 } | 5938 } |
| 5979 | 5939 |
| 5980 // static | 5940 // static |
| 5981 void CXFA_FM2JSContext::fm_var_filter(CFXJSE_Value* pThis, | 5941 void CXFA_FM2JSContext::fm_var_filter(CFXJSE_Value* pThis, |
| 5982 const CFX_ByteStringC& szFuncName, | 5942 const CFX_ByteStringC& szFuncName, |
| 5983 CFXJSE_Arguments& args) { | 5943 CFXJSE_Arguments& args) { |
| 5984 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); | 5944 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); |
| 5985 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 5945 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 5986 if (args.GetLength() == 1) { | 5946 if (args.GetLength() == 1) { |
| 5987 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 5947 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 5988 if (FXJSE_Value_IsArray(argOne.get())) { | 5948 if (argOne->IsArray()) { |
| 5989 #ifndef NDEBUG | 5949 #ifndef NDEBUG |
| 5990 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 5950 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 5991 argOne->GetObjectProperty("length", lengthValue.get()); | 5951 argOne->GetObjectProperty("length", lengthValue.get()); |
| 5992 ASSERT(lengthValue->ToInteger() >= 3); | 5952 ASSERT(lengthValue->ToInteger() >= 3); |
| 5993 #endif | 5953 #endif |
| 5994 std::unique_ptr<CFXJSE_Value> flagsValue(new CFXJSE_Value(pIsolate)); | 5954 std::unique_ptr<CFXJSE_Value> flagsValue(new CFXJSE_Value(pIsolate)); |
| 5995 argOne->GetObjectPropertyByIdx(0, flagsValue.get()); | 5955 argOne->GetObjectPropertyByIdx(0, flagsValue.get()); |
| 5996 int32_t iFlags = flagsValue->ToInteger(); | 5956 int32_t iFlags = flagsValue->ToInteger(); |
| 5997 if (iFlags == 4) { | 5957 if (iFlags == 4) { |
| 5998 CFXJSE_Value* rgValues[3]; | 5958 CFXJSE_Value* rgValues[3]; |
| 5999 for (int32_t i = 0; i < 3; i++) | 5959 for (int32_t i = 0; i < 3; i++) |
| 6000 rgValues[i] = new CFXJSE_Value(pIsolate); | 5960 rgValues[i] = new CFXJSE_Value(pIsolate); |
| 6001 | 5961 |
| 6002 rgValues[0]->SetInteger(3); | 5962 rgValues[0]->SetInteger(3); |
| 6003 rgValues[1]->SetNull(); | 5963 rgValues[1]->SetNull(); |
| 6004 rgValues[2]->SetNull(); | 5964 rgValues[2]->SetNull(); |
| 6005 args.GetReturnValue()->SetArray(3, rgValues); | 5965 args.GetReturnValue()->SetArray(3, rgValues); |
| 6006 for (int32_t i = 0; i < 3; i++) | 5966 for (int32_t i = 0; i < 3; i++) |
| 6007 delete rgValues[i]; | 5967 delete rgValues[i]; |
| 6008 } else if (iFlags == 3) { | 5968 } else if (iFlags == 3) { |
| 6009 std::unique_ptr<CFXJSE_Value> objectValue(new CFXJSE_Value(pIsolate)); | 5969 std::unique_ptr<CFXJSE_Value> objectValue(new CFXJSE_Value(pIsolate)); |
| 6010 argOne->GetObjectPropertyByIdx(2, objectValue.get()); | 5970 argOne->GetObjectPropertyByIdx(2, objectValue.get()); |
| 6011 if (!FXJSE_Value_IsNull(objectValue.get())) { | 5971 if (!objectValue->IsNull()) { |
| 6012 args.GetReturnValue()->Assign(argOne.get()); | 5972 args.GetReturnValue()->Assign(argOne.get()); |
| 6013 } else { | 5973 } else { |
| 6014 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); | 5974 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 6015 } | 5975 } |
| 6016 } else { | 5976 } else { |
| 6017 std::unique_ptr<CFXJSE_Value> simpleValue = | 5977 std::unique_ptr<CFXJSE_Value> simpleValue = |
| 6018 GetSimpleValue(pThis, args, 0); | 5978 GetSimpleValue(pThis, args, 0); |
| 6019 args.GetReturnValue()->Assign(simpleValue.get()); | 5979 args.GetReturnValue()->Assign(simpleValue.get()); |
| 6020 } | 5980 } |
| 6021 } else { | 5981 } else { |
| 6022 std::unique_ptr<CFXJSE_Value> simpleValue = | 5982 std::unique_ptr<CFXJSE_Value> simpleValue = |
| 6023 GetSimpleValue(pThis, args, 0); | 5983 GetSimpleValue(pThis, args, 0); |
| 6024 args.GetReturnValue()->Assign(simpleValue.get()); | 5984 args.GetReturnValue()->Assign(simpleValue.get()); |
| 6025 } | 5985 } |
| 6026 } else { | 5986 } else { |
| 6027 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); | 5987 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 6028 } | 5988 } |
| 6029 } | 5989 } |
| 6030 | 5990 |
| 6031 // static | 5991 // static |
| 6032 void CXFA_FM2JSContext::concat_fm_object(CFXJSE_Value* pThis, | 5992 void CXFA_FM2JSContext::concat_fm_object(CFXJSE_Value* pThis, |
| 6033 const CFX_ByteStringC& szFuncName, | 5993 const CFX_ByteStringC& szFuncName, |
| 6034 CFXJSE_Arguments& args) { | 5994 CFXJSE_Arguments& args) { |
| 6035 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); | 5995 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); |
| 6036 uint32_t iLength = 0; | 5996 uint32_t iLength = 0; |
| 6037 int32_t argc = args.GetLength(); | 5997 int32_t argc = args.GetLength(); |
| 6038 std::vector<std::unique_ptr<CFXJSE_Value>> argValues; | 5998 std::vector<std::unique_ptr<CFXJSE_Value>> argValues; |
| 6039 for (int32_t i = 0; i < argc; i++) { | 5999 for (int32_t i = 0; i < argc; i++) { |
| 6040 argValues.push_back(args.GetValue(i)); | 6000 argValues.push_back(args.GetValue(i)); |
| 6041 if (FXJSE_Value_IsArray(argValues[i].get())) { | 6001 if (argValues[i]->IsArray()) { |
| 6042 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 6002 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 6043 argValues[i]->GetObjectProperty("length", lengthValue.get()); | 6003 argValues[i]->GetObjectProperty("length", lengthValue.get()); |
| 6044 int32_t length = lengthValue->ToInteger(); | 6004 int32_t length = lengthValue->ToInteger(); |
| 6045 iLength = iLength + ((length > 2) ? (length - 2) : 0); | 6005 iLength = iLength + ((length > 2) ? (length - 2) : 0); |
| 6046 } | 6006 } |
| 6047 iLength += 1; | 6007 iLength += 1; |
| 6048 } | 6008 } |
| 6049 CFXJSE_Value** returnValues = FX_Alloc(CFXJSE_Value*, iLength); | 6009 CFXJSE_Value** returnValues = FX_Alloc(CFXJSE_Value*, iLength); |
| 6050 for (int32_t i = 0; i < (int32_t)iLength; i++) | 6010 for (int32_t i = 0; i < (int32_t)iLength; i++) |
| 6051 returnValues[i] = new CFXJSE_Value(pIsolate); | 6011 returnValues[i] = new CFXJSE_Value(pIsolate); |
| 6052 | 6012 |
| 6053 int32_t index = 0; | 6013 int32_t index = 0; |
| 6054 for (int32_t i = 0; i < argc; i++) { | 6014 for (int32_t i = 0; i < argc; i++) { |
| 6055 if (FXJSE_Value_IsArray(argValues[i].get())) { | 6015 if (argValues[i]->IsArray()) { |
| 6056 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 6016 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 6057 argValues[i]->GetObjectProperty("length", lengthValue.get()); | 6017 argValues[i]->GetObjectProperty("length", lengthValue.get()); |
| 6058 int32_t length = lengthValue->ToInteger(); | 6018 int32_t length = lengthValue->ToInteger(); |
| 6059 for (int32_t j = 2; j < length; j++) { | 6019 for (int32_t j = 2; j < length; j++) { |
| 6060 argValues[i]->GetObjectPropertyByIdx(j, returnValues[index]); | 6020 argValues[i]->GetObjectPropertyByIdx(j, returnValues[index]); |
| 6061 index++; | 6021 index++; |
| 6062 } | 6022 } |
| 6063 } | 6023 } |
| 6064 returnValues[index]->Assign(argValues[i].get()); | 6024 returnValues[index]->Assign(argValues[i].get()); |
| 6065 index++; | 6025 index++; |
| 6066 } | 6026 } |
| 6067 args.GetReturnValue()->SetArray(iLength, returnValues); | 6027 args.GetReturnValue()->SetArray(iLength, returnValues); |
| 6068 for (int32_t i = 0; i < (int32_t)iLength; i++) | 6028 for (int32_t i = 0; i < (int32_t)iLength; i++) |
| 6069 delete returnValues[i]; | 6029 delete returnValues[i]; |
| 6070 | 6030 |
| 6071 FX_Free(returnValues); | 6031 FX_Free(returnValues); |
| 6072 } | 6032 } |
| 6073 | 6033 |
| 6074 // static | 6034 // static |
| 6075 std::unique_ptr<CFXJSE_Value> CXFA_FM2JSContext::GetSimpleValue( | 6035 std::unique_ptr<CFXJSE_Value> CXFA_FM2JSContext::GetSimpleValue( |
| 6076 CFXJSE_Value* pThis, | 6036 CFXJSE_Value* pThis, |
| 6077 CFXJSE_Arguments& args, | 6037 CFXJSE_Arguments& args, |
| 6078 uint32_t index) { | 6038 uint32_t index) { |
| 6079 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); | 6039 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); |
| 6080 ASSERT(index < (uint32_t)args.GetLength()); | 6040 ASSERT(index < (uint32_t)args.GetLength()); |
| 6081 std::unique_ptr<CFXJSE_Value> argIndex = args.GetValue(index); | 6041 std::unique_ptr<CFXJSE_Value> argIndex = args.GetValue(index); |
| 6082 if (FXJSE_Value_IsArray(argIndex.get())) { | 6042 if (argIndex->IsArray()) { |
| 6083 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 6043 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 6084 argIndex->GetObjectProperty("length", lengthValue.get()); | 6044 argIndex->GetObjectProperty("length", lengthValue.get()); |
| 6085 int32_t iLength = lengthValue->ToInteger(); | 6045 int32_t iLength = lengthValue->ToInteger(); |
| 6086 std::unique_ptr<CFXJSE_Value> simpleValue(new CFXJSE_Value(pIsolate)); | 6046 std::unique_ptr<CFXJSE_Value> simpleValue(new CFXJSE_Value(pIsolate)); |
| 6087 if (iLength > 2) { | 6047 if (iLength > 2) { |
| 6088 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 6048 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 6089 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 6049 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 6090 argIndex->GetObjectPropertyByIdx(1, propertyValue.get()); | 6050 argIndex->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 6091 argIndex->GetObjectPropertyByIdx(2, jsObjectValue.get()); | 6051 argIndex->GetObjectPropertyByIdx(2, jsObjectValue.get()); |
| 6092 if (FXJSE_Value_IsNull(propertyValue.get())) { | 6052 if (propertyValue->IsNull()) { |
| 6093 GetObjectDefaultValue(jsObjectValue.get(), simpleValue.get()); | 6053 GetObjectDefaultValue(jsObjectValue.get(), simpleValue.get()); |
| 6094 } else { | 6054 } else { |
| 6095 CFX_ByteString propertyStr; | 6055 CFX_ByteString propertyStr; |
| 6096 propertyValue->ToString(propertyStr); | 6056 propertyValue->ToString(propertyStr); |
| 6097 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), | 6057 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), |
| 6098 simpleValue.get()); | 6058 simpleValue.get()); |
| 6099 } | 6059 } |
| 6100 } else { | 6060 } else { |
| 6101 simpleValue.get()->SetUndefined(); | 6061 simpleValue.get()->SetUndefined(); |
| 6102 } | 6062 } |
| 6103 return simpleValue; | 6063 return simpleValue; |
| 6104 } else if (FXJSE_Value_IsObject(argIndex.get())) { | 6064 } else if (argIndex->IsObject()) { |
| 6105 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); | 6065 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); |
| 6106 GetObjectDefaultValue(argIndex.get(), defaultValue.get()); | 6066 GetObjectDefaultValue(argIndex.get(), defaultValue.get()); |
| 6107 return defaultValue; | 6067 return defaultValue; |
| 6108 } else { | 6068 } else { |
| 6109 return argIndex; | 6069 return argIndex; |
| 6110 } | 6070 } |
| 6111 } | 6071 } |
| 6112 | 6072 |
| 6113 // static | 6073 // static |
| 6114 FX_BOOL CXFA_FM2JSContext::ValueIsNull(CFXJSE_Value* pThis, CFXJSE_Value* arg) { | 6074 FX_BOOL CXFA_FM2JSContext::ValueIsNull(CFXJSE_Value* pThis, CFXJSE_Value* arg) { |
| 6115 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); | 6075 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); |
| 6116 FX_BOOL isNull = FALSE; | 6076 FX_BOOL isNull = FALSE; |
| 6117 if (FXJSE_Value_IsNull(arg)) { | 6077 if (!arg || arg->IsNull()) { |
| 6118 isNull = TRUE; | 6078 isNull = TRUE; |
| 6119 } else if (FXJSE_Value_IsArray(arg)) { | 6079 } else if (arg->IsArray()) { |
| 6120 int32_t iLength = hvalue_get_array_length(pThis, arg); | 6080 int32_t iLength = hvalue_get_array_length(pThis, arg); |
| 6121 if (iLength > 2) { | 6081 if (iLength > 2) { |
| 6122 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 6082 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 6123 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 6083 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 6124 arg->GetObjectPropertyByIdx(1, propertyValue.get()); | 6084 arg->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 6125 arg->GetObjectPropertyByIdx(2, jsObjectValue.get()); | 6085 arg->GetObjectPropertyByIdx(2, jsObjectValue.get()); |
| 6126 if (FXJSE_Value_IsNull(propertyValue.get())) { | 6086 if (propertyValue->IsNull()) { |
| 6127 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); | 6087 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); |
| 6128 GetObjectDefaultValue(jsObjectValue.get(), defaultValue.get()); | 6088 GetObjectDefaultValue(jsObjectValue.get(), defaultValue.get()); |
| 6129 if (FXJSE_Value_IsNull(defaultValue.get())) { | 6089 if (defaultValue->IsNull()) { |
| 6130 isNull = TRUE; | 6090 isNull = TRUE; |
| 6131 } | 6091 } |
| 6132 } else { | 6092 } else { |
| 6133 CFX_ByteString propertyStr; | 6093 CFX_ByteString propertyStr; |
| 6134 propertyValue->ToString(propertyStr); | 6094 propertyValue->ToString(propertyStr); |
| 6135 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 6095 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 6136 new CFXJSE_Value(pIsolate)); | 6096 new CFXJSE_Value(pIsolate)); |
| 6137 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), | 6097 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), |
| 6138 newPropertyValue.get()); | 6098 newPropertyValue.get()); |
| 6139 if (FXJSE_Value_IsNull(newPropertyValue.get())) { | 6099 if (newPropertyValue->IsNull()) { |
| 6140 isNull = TRUE; | 6100 isNull = TRUE; |
| 6141 } | 6101 } |
| 6142 } | 6102 } |
| 6143 } else { | 6103 } else { |
| 6144 isNull = TRUE; | 6104 isNull = TRUE; |
| 6145 } | 6105 } |
| 6146 } else if (FXJSE_Value_IsObject(arg)) { | 6106 } else if (arg->IsObject()) { |
| 6147 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); | 6107 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); |
| 6148 GetObjectDefaultValue(arg, defaultValue.get()); | 6108 GetObjectDefaultValue(arg, defaultValue.get()); |
| 6149 if (FXJSE_Value_IsNull(defaultValue.get())) { | 6109 if (defaultValue->IsNull()) { |
| 6150 isNull = TRUE; | 6110 isNull = TRUE; |
| 6151 } | 6111 } |
| 6152 } | 6112 } |
| 6153 return isNull; | 6113 return isNull; |
| 6154 } | 6114 } |
| 6155 | 6115 |
| 6156 // static | 6116 // static |
| 6157 int32_t CXFA_FM2JSContext::hvalue_get_array_length(CFXJSE_Value* pThis, | 6117 int32_t CXFA_FM2JSContext::hvalue_get_array_length(CFXJSE_Value* pThis, |
| 6158 CFXJSE_Value* arg) { | 6118 CFXJSE_Value* arg) { |
| 6119 if (!arg || !arg->IsArray()) |
| 6120 return 0; |
| 6121 |
| 6159 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); | 6122 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); |
| 6160 int32_t iLength = 0; | 6123 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 6161 if (FXJSE_Value_IsArray(arg)) { | 6124 arg->GetObjectProperty("length", lengthValue.get()); |
| 6162 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 6125 return lengthValue->ToInteger(); |
| 6163 arg->GetObjectProperty("length", lengthValue.get()); | |
| 6164 iLength = lengthValue->ToInteger(); | |
| 6165 } | |
| 6166 return iLength; | |
| 6167 } | 6126 } |
| 6168 | 6127 |
| 6169 // static | 6128 // static |
| 6170 FX_BOOL CXFA_FM2JSContext::simpleValueCompare(CFXJSE_Value* pThis, | 6129 FX_BOOL CXFA_FM2JSContext::simpleValueCompare(CFXJSE_Value* pThis, |
| 6171 CFXJSE_Value* firstValue, | 6130 CFXJSE_Value* firstValue, |
| 6172 CFXJSE_Value* secondValue) { | 6131 CFXJSE_Value* secondValue) { |
| 6132 if (!firstValue) |
| 6133 return FALSE; |
| 6134 |
| 6173 FX_BOOL bReturn = FALSE; | 6135 FX_BOOL bReturn = FALSE; |
| 6174 if (FXJSE_Value_IsUTF8String(firstValue)) { | 6136 if (firstValue->IsString()) { |
| 6175 CFX_ByteString firstString, secondString; | 6137 CFX_ByteString firstString, secondString; |
| 6176 ValueToUTF8String(firstValue, firstString); | 6138 ValueToUTF8String(firstValue, firstString); |
| 6177 ValueToUTF8String(secondValue, secondString); | 6139 ValueToUTF8String(secondValue, secondString); |
| 6178 bReturn = firstString == secondString; | 6140 bReturn = firstString == secondString; |
| 6179 } else if (FXJSE_Value_IsNumber(firstValue)) { | 6141 } else if (firstValue->IsNumber()) { |
| 6180 FX_FLOAT first = ValueToFloat(pThis, firstValue); | 6142 FX_FLOAT first = ValueToFloat(pThis, firstValue); |
| 6181 FX_FLOAT second = ValueToFloat(pThis, secondValue); | 6143 FX_FLOAT second = ValueToFloat(pThis, secondValue); |
| 6182 bReturn = (first == second); | 6144 bReturn = (first == second); |
| 6183 } else if (FXJSE_Value_IsBoolean(firstValue)) { | 6145 } else if (firstValue->IsBoolean()) { |
| 6184 bReturn = (firstValue->ToBoolean() == secondValue->ToBoolean()); | 6146 bReturn = (firstValue->ToBoolean() == secondValue->ToBoolean()); |
| 6185 } else if (FXJSE_Value_IsNull(firstValue) && | 6147 } else if (firstValue->IsNull() && secondValue && secondValue->IsNull()) { |
| 6186 FXJSE_Value_IsNull(secondValue)) { | |
| 6187 bReturn = TRUE; | 6148 bReturn = TRUE; |
| 6188 } | 6149 } |
| 6189 return bReturn; | 6150 return bReturn; |
| 6190 } | 6151 } |
| 6191 | 6152 |
| 6192 // static | 6153 // static |
| 6193 void CXFA_FM2JSContext::unfoldArgs(CFXJSE_Value* pThis, | 6154 void CXFA_FM2JSContext::unfoldArgs(CFXJSE_Value* pThis, |
| 6194 CFXJSE_Arguments& args, | 6155 CFXJSE_Arguments& args, |
| 6195 CFXJSE_Value**& resultValues, | 6156 CFXJSE_Value**& resultValues, |
| 6196 int32_t& iCount, | 6157 int32_t& iCount, |
| 6197 int32_t iStart) { | 6158 int32_t iStart) { |
| 6198 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); | 6159 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); |
| 6199 iCount = 0; | 6160 iCount = 0; |
| 6200 int32_t argc = args.GetLength(); | 6161 int32_t argc = args.GetLength(); |
| 6201 std::vector<std::unique_ptr<CFXJSE_Value>> argsValue; | 6162 std::vector<std::unique_ptr<CFXJSE_Value>> argsValue; |
| 6202 for (int32_t i = 0; i < argc - iStart; i++) { | 6163 for (int32_t i = 0; i < argc - iStart; i++) { |
| 6203 argsValue.push_back(args.GetValue(i + iStart)); | 6164 argsValue.push_back(args.GetValue(i + iStart)); |
| 6204 if (FXJSE_Value_IsArray(argsValue[i].get())) { | 6165 if (argsValue[i]->IsArray()) { |
| 6205 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 6166 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 6206 argsValue[i]->GetObjectProperty("length", lengthValue.get()); | 6167 argsValue[i]->GetObjectProperty("length", lengthValue.get()); |
| 6207 int32_t iLength = lengthValue->ToInteger(); | 6168 int32_t iLength = lengthValue->ToInteger(); |
| 6208 iCount += ((iLength > 2) ? (iLength - 2) : 0); | 6169 iCount += ((iLength > 2) ? (iLength - 2) : 0); |
| 6209 } else { | 6170 } else { |
| 6210 iCount += 1; | 6171 iCount += 1; |
| 6211 } | 6172 } |
| 6212 } | 6173 } |
| 6213 resultValues = FX_Alloc(CFXJSE_Value*, iCount); | 6174 resultValues = FX_Alloc(CFXJSE_Value*, iCount); |
| 6214 for (int32_t i = 0; i < iCount; i++) | 6175 for (int32_t i = 0; i < iCount; i++) |
| 6215 resultValues[i] = new CFXJSE_Value(pIsolate); | 6176 resultValues[i] = new CFXJSE_Value(pIsolate); |
| 6216 | 6177 |
| 6217 int32_t index = 0; | 6178 int32_t index = 0; |
| 6218 for (int32_t i = 0; i < argc - iStart; i++) { | 6179 for (int32_t i = 0; i < argc - iStart; i++) { |
| 6219 if (FXJSE_Value_IsArray(argsValue[i].get())) { | 6180 if (argsValue[i]->IsArray()) { |
| 6220 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 6181 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 6221 argsValue[i]->GetObjectProperty("length", lengthValue.get()); | 6182 argsValue[i]->GetObjectProperty("length", lengthValue.get()); |
| 6222 int32_t iLength = lengthValue->ToInteger(); | 6183 int32_t iLength = lengthValue->ToInteger(); |
| 6223 if (iLength > 2) { | 6184 if (iLength > 2) { |
| 6224 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 6185 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 6225 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 6186 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 6226 argsValue[i]->GetObjectPropertyByIdx(1, propertyValue.get()); | 6187 argsValue[i]->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 6227 if (FXJSE_Value_IsNull(propertyValue.get())) { | 6188 if (propertyValue->IsNull()) { |
| 6228 for (int32_t j = 2; j < iLength; j++) { | 6189 for (int32_t j = 2; j < iLength; j++) { |
| 6229 argsValue[i]->GetObjectPropertyByIdx(j, jsObjectValue.get()); | 6190 argsValue[i]->GetObjectPropertyByIdx(j, jsObjectValue.get()); |
| 6230 GetObjectDefaultValue(jsObjectValue.get(), resultValues[index]); | 6191 GetObjectDefaultValue(jsObjectValue.get(), resultValues[index]); |
| 6231 index++; | 6192 index++; |
| 6232 } | 6193 } |
| 6233 } else { | 6194 } else { |
| 6234 CFX_ByteString propertyString; | 6195 CFX_ByteString propertyString; |
| 6235 propertyValue->ToString(propertyString); | 6196 propertyValue->ToString(propertyString); |
| 6236 for (int32_t j = 2; j < iLength; j++) { | 6197 for (int32_t j = 2; j < iLength; j++) { |
| 6237 argsValue[i]->GetObjectPropertyByIdx(j, jsObjectValue.get()); | 6198 argsValue[i]->GetObjectPropertyByIdx(j, jsObjectValue.get()); |
| 6238 jsObjectValue->GetObjectProperty(propertyString.AsStringC(), | 6199 jsObjectValue->GetObjectProperty(propertyString.AsStringC(), |
| 6239 resultValues[index]); | 6200 resultValues[index]); |
| 6240 index++; | 6201 index++; |
| 6241 } | 6202 } |
| 6242 } | 6203 } |
| 6243 } | 6204 } |
| 6244 } else if (FXJSE_Value_IsObject(argsValue[i].get())) { | 6205 } else if (argsValue[i]->IsObject()) { |
| 6245 GetObjectDefaultValue(argsValue[i].get(), resultValues[index]); | 6206 GetObjectDefaultValue(argsValue[i].get(), resultValues[index]); |
| 6246 index++; | 6207 index++; |
| 6247 } else { | 6208 } else { |
| 6248 resultValues[index]->Assign(argsValue[i].get()); | 6209 resultValues[index]->Assign(argsValue[i].get()); |
| 6249 index++; | 6210 index++; |
| 6250 } | 6211 } |
| 6251 } | 6212 } |
| 6252 } | 6213 } |
| 6253 | 6214 |
| 6254 // static | 6215 // static |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6340 CFX_WideString wsSomExpression = CFX_WideString::FromUTF8(bsSomExp); | 6301 CFX_WideString wsSomExpression = CFX_WideString::FromUTF8(bsSomExp); |
| 6341 int32_t iRet = -1; | 6302 int32_t iRet = -1; |
| 6342 CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument(); | 6303 CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument(); |
| 6343 if (!pDoc) { | 6304 if (!pDoc) { |
| 6344 return iRet; | 6305 return iRet; |
| 6345 } | 6306 } |
| 6346 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); | 6307 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); |
| 6347 CXFA_Object* pNode = nullptr; | 6308 CXFA_Object* pNode = nullptr; |
| 6348 uint32_t dFlags = 0UL; | 6309 uint32_t dFlags = 0UL; |
| 6349 if (bdotAccessor) { | 6310 if (bdotAccessor) { |
| 6350 if (FXJSE_Value_IsNull(pRefValue)) { | 6311 if (pRefValue && pRefValue->IsNull()) { |
| 6351 pNode = pScriptContext->GetThisObject(); | 6312 pNode = pScriptContext->GetThisObject(); |
| 6352 dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; | 6313 dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; |
| 6353 } else { | 6314 } else { |
| 6354 pNode = CXFA_ScriptContext::ToObject(pRefValue, nullptr); | 6315 pNode = CXFA_ScriptContext::ToObject(pRefValue, nullptr); |
| 6355 ASSERT(pNode); | 6316 ASSERT(pNode); |
| 6356 if (bHasNoResolveName) { | 6317 if (bHasNoResolveName) { |
| 6357 CFX_WideString wsName; | 6318 CFX_WideString wsName; |
| 6358 if (CXFA_Node* pXFANode = pNode->AsNode()) { | 6319 if (CXFA_Node* pXFANode = pNode->AsNode()) { |
| 6359 pXFANode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); | 6320 pXFANode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); |
| 6360 } | 6321 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6401 resultValues[i] = new CFXJSE_Value(pIsolate); | 6362 resultValues[i] = new CFXJSE_Value(pIsolate); |
| 6402 resultValues[i]->Assign( | 6363 resultValues[i]->Assign( |
| 6403 pContext->GetDocument()->GetScriptContext()->GetJSValueFromMap( | 6364 pContext->GetDocument()->GetScriptContext()->GetJSValueFromMap( |
| 6404 resoveNodeRS.nodes.GetAt(i))); | 6365 resoveNodeRS.nodes.GetAt(i))); |
| 6405 } | 6366 } |
| 6406 } else { | 6367 } else { |
| 6407 CXFA_ValueArray objectProperties(pIsolate); | 6368 CXFA_ValueArray objectProperties(pIsolate); |
| 6408 int32_t iRet = resoveNodeRS.GetAttributeResult(objectProperties); | 6369 int32_t iRet = resoveNodeRS.GetAttributeResult(objectProperties); |
| 6409 bAttribute = (iRet == 0); | 6370 bAttribute = (iRet == 0); |
| 6410 if (bAttribute) { | 6371 if (bAttribute) { |
| 6411 if (FXJSE_Value_IsObject(pParentValue)) { | 6372 if (pParentValue && pParentValue->IsObject()) { |
| 6412 iSize = 1; | 6373 iSize = 1; |
| 6413 resultValues = FX_Alloc(CFXJSE_Value*, 1); | 6374 resultValues = FX_Alloc(CFXJSE_Value*, 1); |
| 6414 resultValues[0] = new CFXJSE_Value(pIsolate); | 6375 resultValues[0] = new CFXJSE_Value(pIsolate); |
| 6415 resultValues[0]->Assign(pParentValue); | 6376 resultValues[0]->Assign(pParentValue); |
| 6416 } | 6377 } |
| 6417 } else { | 6378 } else { |
| 6418 iSize = iRet; | 6379 iSize = iRet; |
| 6419 resultValues = FX_Alloc(CFXJSE_Value*, iSize); | 6380 resultValues = FX_Alloc(CFXJSE_Value*, iSize); |
| 6420 for (int32_t i = 0; i < iSize; i++) { | 6381 for (int32_t i = 0; i < iSize; i++) { |
| 6421 resultValues[i] = new CFXJSE_Value(pIsolate); | 6382 resultValues[i] = new CFXJSE_Value(pIsolate); |
| 6422 resultValues[i]->Assign(objectProperties[i]); | 6383 resultValues[i]->Assign(objectProperties[i]); |
| 6423 } | 6384 } |
| 6424 } | 6385 } |
| 6425 } | 6386 } |
| 6426 } | 6387 } |
| 6427 | 6388 |
| 6428 // static | 6389 // static |
| 6429 int32_t CXFA_FM2JSContext::ValueToInteger(CFXJSE_Value* pThis, | 6390 int32_t CXFA_FM2JSContext::ValueToInteger(CFXJSE_Value* pThis, |
| 6430 CFXJSE_Value* pValue) { | 6391 CFXJSE_Value* pValue) { |
| 6392 if (!pValue) |
| 6393 return 0; |
| 6394 |
| 6431 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); | 6395 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); |
| 6432 int32_t iValue = 0; | 6396 int32_t iValue = 0; |
| 6433 if (FXJSE_Value_IsArray(pValue)) { | 6397 if (pValue->IsArray()) { |
| 6434 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 6398 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 6435 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 6399 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 6436 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 6400 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
| 6437 pValue->GetObjectPropertyByIdx(1, propertyValue.get()); | 6401 pValue->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 6438 pValue->GetObjectPropertyByIdx(2, jsObjectValue.get()); | 6402 pValue->GetObjectPropertyByIdx(2, jsObjectValue.get()); |
| 6439 if (FXJSE_Value_IsNull(propertyValue.get())) { | 6403 if (propertyValue->IsNull()) { |
| 6440 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 6404 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
| 6441 } else { | 6405 } else { |
| 6442 CFX_ByteString propertyStr; | 6406 CFX_ByteString propertyStr; |
| 6443 propertyValue->ToString(propertyStr); | 6407 propertyValue->ToString(propertyStr); |
| 6444 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), | 6408 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), |
| 6445 newPropertyValue.get()); | 6409 newPropertyValue.get()); |
| 6446 } | 6410 } |
| 6447 iValue = ValueToInteger(pThis, newPropertyValue.get()); | 6411 iValue = ValueToInteger(pThis, newPropertyValue.get()); |
| 6448 return iValue; | 6412 return iValue; |
| 6449 } else if (FXJSE_Value_IsObject(pValue)) { | 6413 } else if (pValue->IsObject()) { |
| 6450 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 6414 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
| 6451 GetObjectDefaultValue(pValue, newPropertyValue.get()); | 6415 GetObjectDefaultValue(pValue, newPropertyValue.get()); |
| 6452 iValue = ValueToInteger(pThis, newPropertyValue.get()); | 6416 iValue = ValueToInteger(pThis, newPropertyValue.get()); |
| 6453 return iValue; | 6417 return iValue; |
| 6454 } else if (FXJSE_Value_IsUTF8String(pValue)) { | 6418 } else if (pValue->IsString()) { |
| 6455 CFX_ByteString szValue; | 6419 CFX_ByteString szValue; |
| 6456 pValue->ToString(szValue); | 6420 pValue->ToString(szValue); |
| 6457 iValue = FXSYS_atoi(szValue.c_str()); | 6421 iValue = FXSYS_atoi(szValue.c_str()); |
| 6458 } else { | 6422 } else { |
| 6459 iValue = pValue->ToInteger(); | 6423 iValue = pValue->ToInteger(); |
| 6460 } | 6424 } |
| 6461 return iValue; | 6425 return iValue; |
| 6462 } | 6426 } |
| 6463 | 6427 |
| 6464 // static | 6428 // static |
| 6465 FX_FLOAT CXFA_FM2JSContext::ValueToFloat(CFXJSE_Value* pThis, | 6429 FX_FLOAT CXFA_FM2JSContext::ValueToFloat(CFXJSE_Value* pThis, |
| 6466 CFXJSE_Value* arg) { | 6430 CFXJSE_Value* arg) { |
| 6431 if (!arg) |
| 6432 return 0.0f; |
| 6433 |
| 6467 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); | 6434 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); |
| 6468 FX_FLOAT fRet = 0.0f; | 6435 FX_FLOAT fRet = 0.0f; |
| 6469 if (FXJSE_Value_IsArray(arg)) { | 6436 if (arg->IsArray()) { |
| 6470 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 6437 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 6471 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 6438 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 6472 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 6439 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
| 6473 arg->GetObjectPropertyByIdx(1, propertyValue.get()); | 6440 arg->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 6474 arg->GetObjectPropertyByIdx(2, jsObjectValue.get()); | 6441 arg->GetObjectPropertyByIdx(2, jsObjectValue.get()); |
| 6475 if (FXJSE_Value_IsNull(propertyValue.get())) { | 6442 if (propertyValue->IsNull()) { |
| 6476 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 6443 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
| 6477 } else { | 6444 } else { |
| 6478 CFX_ByteString propertyStr; | 6445 CFX_ByteString propertyStr; |
| 6479 propertyValue->ToString(propertyStr); | 6446 propertyValue->ToString(propertyStr); |
| 6480 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), | 6447 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), |
| 6481 newPropertyValue.get()); | 6448 newPropertyValue.get()); |
| 6482 } | 6449 } |
| 6483 fRet = ValueToFloat(pThis, newPropertyValue.get()); | 6450 fRet = ValueToFloat(pThis, newPropertyValue.get()); |
| 6484 } else if (FXJSE_Value_IsObject(arg)) { | 6451 } else if (arg->IsObject()) { |
| 6485 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 6452 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
| 6486 GetObjectDefaultValue(arg, newPropertyValue.get()); | 6453 GetObjectDefaultValue(arg, newPropertyValue.get()); |
| 6487 fRet = ValueToFloat(pThis, newPropertyValue.get()); | 6454 fRet = ValueToFloat(pThis, newPropertyValue.get()); |
| 6488 } else if (FXJSE_Value_IsUTF8String(arg)) { | 6455 } else if (arg->IsString()) { |
| 6489 CFX_ByteString bsOutput; | 6456 CFX_ByteString bsOutput; |
| 6490 arg->ToString(bsOutput); | 6457 arg->ToString(bsOutput); |
| 6491 fRet = (FX_FLOAT)XFA_ByteStringToDouble(bsOutput.AsStringC()); | 6458 fRet = (FX_FLOAT)XFA_ByteStringToDouble(bsOutput.AsStringC()); |
| 6492 } else if (FXJSE_Value_IsUndefined(arg)) { | 6459 } else if (arg->IsUndefined()) { |
| 6493 fRet = 0; | 6460 fRet = 0; |
| 6494 } else { | 6461 } else { |
| 6495 fRet = arg->ToFloat(); | 6462 fRet = arg->ToFloat(); |
| 6496 } | 6463 } |
| 6497 return fRet; | 6464 return fRet; |
| 6498 } | 6465 } |
| 6499 | 6466 |
| 6500 // static | 6467 // static |
| 6501 FX_DOUBLE CXFA_FM2JSContext::ValueToDouble(CFXJSE_Value* pThis, | 6468 FX_DOUBLE CXFA_FM2JSContext::ValueToDouble(CFXJSE_Value* pThis, |
| 6502 CFXJSE_Value* arg) { | 6469 CFXJSE_Value* arg) { |
| 6470 if (!arg) |
| 6471 return 0; |
| 6472 |
| 6503 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); | 6473 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); |
| 6504 FX_DOUBLE dRet = 0; | 6474 FX_DOUBLE dRet = 0; |
| 6505 if (FXJSE_Value_IsArray(arg)) { | 6475 if (arg->IsArray()) { |
| 6506 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 6476 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 6507 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 6477 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 6508 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 6478 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
| 6509 arg->GetObjectPropertyByIdx(1, propertyValue.get()); | 6479 arg->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 6510 arg->GetObjectPropertyByIdx(2, jsObjectValue.get()); | 6480 arg->GetObjectPropertyByIdx(2, jsObjectValue.get()); |
| 6511 if (FXJSE_Value_IsNull(propertyValue.get())) { | 6481 if (propertyValue->IsNull()) { |
| 6512 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 6482 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
| 6513 } else { | 6483 } else { |
| 6514 CFX_ByteString propertyStr; | 6484 CFX_ByteString propertyStr; |
| 6515 propertyValue->ToString(propertyStr); | 6485 propertyValue->ToString(propertyStr); |
| 6516 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), | 6486 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), |
| 6517 newPropertyValue.get()); | 6487 newPropertyValue.get()); |
| 6518 } | 6488 } |
| 6519 dRet = ValueToDouble(pThis, newPropertyValue.get()); | 6489 dRet = ValueToDouble(pThis, newPropertyValue.get()); |
| 6520 } else if (FXJSE_Value_IsObject(arg)) { | 6490 } else if (arg->IsObject()) { |
| 6521 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 6491 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
| 6522 GetObjectDefaultValue(arg, newPropertyValue.get()); | 6492 GetObjectDefaultValue(arg, newPropertyValue.get()); |
| 6523 dRet = ValueToDouble(pThis, newPropertyValue.get()); | 6493 dRet = ValueToDouble(pThis, newPropertyValue.get()); |
| 6524 } else if (FXJSE_Value_IsUTF8String(arg)) { | 6494 } else if (arg->IsString()) { |
| 6525 CFX_ByteString bsOutput; | 6495 CFX_ByteString bsOutput; |
| 6526 arg->ToString(bsOutput); | 6496 arg->ToString(bsOutput); |
| 6527 dRet = XFA_ByteStringToDouble(bsOutput.AsStringC()); | 6497 dRet = XFA_ByteStringToDouble(bsOutput.AsStringC()); |
| 6528 } else if (FXJSE_Value_IsUndefined(arg)) { | 6498 } else if (arg->IsUndefined()) { |
| 6529 dRet = 0; | 6499 dRet = 0; |
| 6530 } else { | 6500 } else { |
| 6531 dRet = arg->ToDouble(); | 6501 dRet = arg->ToDouble(); |
| 6532 } | 6502 } |
| 6533 return dRet; | 6503 return dRet; |
| 6534 } | 6504 } |
| 6535 | 6505 |
| 6536 // static. | 6506 // static. |
| 6537 double CXFA_FM2JSContext::ExtractDouble(CFXJSE_Value* pThis, | 6507 double CXFA_FM2JSContext::ExtractDouble(CFXJSE_Value* pThis, |
| 6538 CFXJSE_Value* src, | 6508 CFXJSE_Value* src, |
| 6539 bool* ret) { | 6509 bool* ret) { |
| 6540 ASSERT(ret); | 6510 ASSERT(ret); |
| 6541 | 6511 |
| 6542 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); | 6512 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); |
| 6543 *ret = true; | 6513 *ret = true; |
| 6544 | 6514 |
| 6545 if (FXJSE_Value_IsArray(src)) { | 6515 if (!src) |
| 6516 return 0; |
| 6517 |
| 6518 if (src->IsArray()) { |
| 6546 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 6519 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 6547 src->GetObjectProperty("length", lengthValue.get()); | 6520 src->GetObjectProperty("length", lengthValue.get()); |
| 6548 int32_t iLength = lengthValue->ToInteger(); | 6521 int32_t iLength = lengthValue->ToInteger(); |
| 6549 if (iLength <= 2) { | 6522 if (iLength <= 2) { |
| 6550 *ret = false; | 6523 *ret = false; |
| 6551 return 0.0; | 6524 return 0.0; |
| 6552 } | 6525 } |
| 6553 | 6526 |
| 6554 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 6527 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 6555 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 6528 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 6556 src->GetObjectPropertyByIdx(1, propertyValue.get()); | 6529 src->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 6557 src->GetObjectPropertyByIdx(2, jsObjectValue.get()); | 6530 src->GetObjectPropertyByIdx(2, jsObjectValue.get()); |
| 6558 if (FXJSE_Value_IsNull(propertyValue.get())) | 6531 if (propertyValue->IsNull()) |
| 6559 return ValueToDouble(pThis, jsObjectValue.get()); | 6532 return ValueToDouble(pThis, jsObjectValue.get()); |
| 6560 | 6533 |
| 6561 CFX_ByteString propertyStr; | 6534 CFX_ByteString propertyStr; |
| 6562 propertyValue->ToString(propertyStr); | 6535 propertyValue->ToString(propertyStr); |
| 6563 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 6536 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
| 6564 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), | 6537 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), |
| 6565 newPropertyValue.get()); | 6538 newPropertyValue.get()); |
| 6566 return ValueToDouble(pThis, newPropertyValue.get()); | 6539 return ValueToDouble(pThis, newPropertyValue.get()); |
| 6567 } | 6540 } |
| 6568 return ValueToDouble(pThis, src); | 6541 return ValueToDouble(pThis, src); |
| 6569 } | 6542 } |
| 6570 | 6543 |
| 6571 // static | 6544 // static |
| 6572 void CXFA_FM2JSContext::ValueToUTF8String(CFXJSE_Value* arg, | 6545 void CXFA_FM2JSContext::ValueToUTF8String(CFXJSE_Value* arg, |
| 6573 CFX_ByteString& szOutputString) { | 6546 CFX_ByteString& szOutputString) { |
| 6574 if (FXJSE_Value_IsNull(arg) || FXJSE_Value_IsUndefined(arg)) { | 6547 if (!arg) |
| 6548 return; |
| 6549 |
| 6550 if (arg->IsNull() || arg->IsUndefined()) { |
| 6575 szOutputString = ""; | 6551 szOutputString = ""; |
| 6576 } else if (FXJSE_Value_IsBoolean(arg)) { | 6552 } else if (arg->IsBoolean()) { |
| 6577 szOutputString = arg->ToBoolean() ? "1" : "0"; | 6553 szOutputString = arg->ToBoolean() ? "1" : "0"; |
| 6578 } else { | 6554 } else { |
| 6579 szOutputString = ""; | 6555 szOutputString = ""; |
| 6580 arg->ToString(szOutputString); | 6556 arg->ToString(szOutputString); |
| 6581 } | 6557 } |
| 6582 } | 6558 } |
| 6583 | 6559 |
| 6584 // static. | 6560 // static. |
| 6585 int32_t CXFA_FM2JSContext::Translate(const CFX_WideStringC& wsFormcalc, | 6561 int32_t CXFA_FM2JSContext::Translate(const CFX_WideStringC& wsFormcalc, |
| 6586 CFX_WideTextBuf& wsJavascript, | 6562 CFX_WideTextBuf& wsJavascript, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 6603 return status; | 6579 return status; |
| 6604 } | 6580 } |
| 6605 program.TranslateProgram(wsJavascript); | 6581 program.TranslateProgram(wsJavascript); |
| 6606 return 0; | 6582 return 0; |
| 6607 } | 6583 } |
| 6608 | 6584 |
| 6609 CXFA_FM2JSContext::CXFA_FM2JSContext(v8::Isolate* pScriptIsolate, | 6585 CXFA_FM2JSContext::CXFA_FM2JSContext(v8::Isolate* pScriptIsolate, |
| 6610 CFXJSE_Context* pScriptContext, | 6586 CFXJSE_Context* pScriptContext, |
| 6611 CXFA_Document* pDoc) | 6587 CXFA_Document* pDoc) |
| 6612 : m_pIsolate(pScriptIsolate), | 6588 : m_pIsolate(pScriptIsolate), |
| 6613 m_pFMClass(FXJSE_DefineClass(pScriptContext, &formcalc_fm2js_descriptor)), | 6589 m_pFMClass( |
| 6590 CFXJSE_Class::Create(pScriptContext, &formcalc_fm2js_descriptor)), |
| 6614 m_pValue(new CFXJSE_Value(pScriptIsolate)), | 6591 m_pValue(new CFXJSE_Value(pScriptIsolate)), |
| 6615 m_pDocument(pDoc) { | 6592 m_pDocument(pDoc) { |
| 6616 m_pValue.get()->SetNull(); | 6593 m_pValue.get()->SetNull(); |
| 6617 m_pValue.get()->SetObject(this, m_pFMClass); | 6594 m_pValue.get()->SetObject(this, m_pFMClass); |
| 6618 } | 6595 } |
| 6619 | 6596 |
| 6620 CXFA_FM2JSContext::~CXFA_FM2JSContext() {} | 6597 CXFA_FM2JSContext::~CXFA_FM2JSContext() {} |
| 6621 | 6598 |
| 6622 void CXFA_FM2JSContext::GlobalPropertyGetter(CFXJSE_Value* pValue) { | 6599 void CXFA_FM2JSContext::GlobalPropertyGetter(CFXJSE_Value* pValue) { |
| 6623 pValue->Assign(m_pValue.get()); | 6600 pValue->Assign(m_pValue.get()); |
| 6624 } | 6601 } |
| 6625 | 6602 |
| 6626 void CXFA_FM2JSContext::ThrowException(int32_t iStringID, ...) { | 6603 void CXFA_FM2JSContext::ThrowException(int32_t iStringID, ...) { |
| 6627 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); | 6604 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); |
| 6628 ASSERT(pAppProvider); | 6605 ASSERT(pAppProvider); |
| 6629 CFX_WideString wsFormat; | 6606 CFX_WideString wsFormat; |
| 6630 pAppProvider->LoadString(iStringID, wsFormat); | 6607 pAppProvider->LoadString(iStringID, wsFormat); |
| 6631 CFX_WideString wsMessage; | 6608 CFX_WideString wsMessage; |
| 6632 va_list arg_ptr; | 6609 va_list arg_ptr; |
| 6633 va_start(arg_ptr, iStringID); | 6610 va_start(arg_ptr, iStringID); |
| 6634 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); | 6611 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); |
| 6635 va_end(arg_ptr); | 6612 va_end(arg_ptr); |
| 6636 FXJSE_ThrowMessage( | 6613 FXJSE_ThrowMessage( |
| 6637 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); | 6614 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); |
| 6638 } | 6615 } |
| OLD | NEW |