| 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 |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 return false; | 494 return false; |
| 495 } | 495 } |
| 496 | 496 |
| 497 } // namespace | 497 } // namespace |
| 498 | 498 |
| 499 // static | 499 // static |
| 500 void CXFA_FM2JSContext::Abs(CFXJSE_Value* pThis, | 500 void CXFA_FM2JSContext::Abs(CFXJSE_Value* pThis, |
| 501 const CFX_ByteStringC& szFuncName, | 501 const CFX_ByteStringC& szFuncName, |
| 502 CFXJSE_Arguments& args) { | 502 CFXJSE_Arguments& args) { |
| 503 if (args.GetLength() != 1) { | 503 if (args.GetLength() != 1) { |
| 504 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 504 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 505 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Abs"); | 505 L"Abs"); |
| 506 return; | 506 return; |
| 507 } | 507 } |
| 508 | 508 |
| 509 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 509 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 510 if (ValueIsNull(pThis, argOne.get())) { | 510 if (ValueIsNull(pThis, argOne.get())) { |
| 511 FXJSE_Value_SetNull(args.GetReturnValue()); | 511 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 512 return; | 512 return; |
| 513 } | 513 } |
| 514 | 514 |
| 515 FX_DOUBLE dValue = ValueToDouble(pThis, argOne.get()); | 515 FX_DOUBLE dValue = ValueToDouble(pThis, argOne.get()); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 } | 591 } |
| 592 | 592 |
| 593 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum / uCount); | 593 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum / uCount); |
| 594 } | 594 } |
| 595 | 595 |
| 596 // static | 596 // static |
| 597 void CXFA_FM2JSContext::Ceil(CFXJSE_Value* pThis, | 597 void CXFA_FM2JSContext::Ceil(CFXJSE_Value* pThis, |
| 598 const CFX_ByteStringC& szFuncName, | 598 const CFX_ByteStringC& szFuncName, |
| 599 CFXJSE_Arguments& args) { | 599 CFXJSE_Arguments& args) { |
| 600 if (args.GetLength() != 1) { | 600 if (args.GetLength() != 1) { |
| 601 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 601 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 602 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Ceil"); | 602 L"Ceil"); |
| 603 return; | 603 return; |
| 604 } | 604 } |
| 605 | 605 |
| 606 std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, args, 0); | 606 std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, args, 0); |
| 607 if (ValueIsNull(pThis, argValue.get())) { | 607 if (ValueIsNull(pThis, argValue.get())) { |
| 608 FXJSE_Value_SetNull(args.GetReturnValue()); | 608 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 609 return; | 609 return; |
| 610 } | 610 } |
| 611 | 611 |
| 612 FXJSE_Value_SetFloat(args.GetReturnValue(), | 612 FXJSE_Value_SetFloat(args.GetReturnValue(), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 624 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); | 624 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); |
| 625 if (FXJSE_Value_IsNull(argValue.get())) | 625 if (FXJSE_Value_IsNull(argValue.get())) |
| 626 continue; | 626 continue; |
| 627 | 627 |
| 628 if (FXJSE_Value_IsArray(argValue.get())) { | 628 if (FXJSE_Value_IsArray(argValue.get())) { |
| 629 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 629 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 630 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); | 630 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); |
| 631 | 631 |
| 632 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); | 632 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); |
| 633 if (iLength <= 2) { | 633 if (iLength <= 2) { |
| 634 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 634 pContext->Throw(XFA_IDS_ARGUMENT_MISMATCH); |
| 635 return; | 635 return; |
| 636 } | 636 } |
| 637 | 637 |
| 638 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 638 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 639 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 639 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 640 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 640 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 641 new CFXJSE_Value(pIsolate)); | 641 new CFXJSE_Value(pIsolate)); |
| 642 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); | 642 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); |
| 643 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); | 643 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); |
| 644 if (FXJSE_Value_IsNull(propertyValue.get())) { | 644 if (FXJSE_Value_IsNull(propertyValue.get())) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 672 } | 672 } |
| 673 } | 673 } |
| 674 FXJSE_Value_SetInteger(args.GetReturnValue(), iCount); | 674 FXJSE_Value_SetInteger(args.GetReturnValue(), iCount); |
| 675 } | 675 } |
| 676 | 676 |
| 677 // static | 677 // static |
| 678 void CXFA_FM2JSContext::Floor(CFXJSE_Value* pThis, | 678 void CXFA_FM2JSContext::Floor(CFXJSE_Value* pThis, |
| 679 const CFX_ByteStringC& szFuncName, | 679 const CFX_ByteStringC& szFuncName, |
| 680 CFXJSE_Arguments& args) { | 680 CFXJSE_Arguments& args) { |
| 681 if (args.GetLength() != 1) { | 681 if (args.GetLength() != 1) { |
| 682 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 682 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 683 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Floor"); | 683 L"Floor"); |
| 684 return; | 684 return; |
| 685 } | 685 } |
| 686 | 686 |
| 687 std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, args, 0); | 687 std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, args, 0); |
| 688 if (ValueIsNull(pThis, argValue.get())) { | 688 if (ValueIsNull(pThis, argValue.get())) { |
| 689 FXJSE_Value_SetNull(args.GetReturnValue()); | 689 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 690 return; | 690 return; |
| 691 } | 691 } |
| 692 | 692 |
| 693 FXJSE_Value_SetFloat(args.GetReturnValue(), | 693 FXJSE_Value_SetFloat(args.GetReturnValue(), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 705 for (int32_t i = 0; i < args.GetLength(); i++) { | 705 for (int32_t i = 0; i < args.GetLength(); i++) { |
| 706 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); | 706 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); |
| 707 if (FXJSE_Value_IsNull(argValue.get())) | 707 if (FXJSE_Value_IsNull(argValue.get())) |
| 708 continue; | 708 continue; |
| 709 | 709 |
| 710 if (FXJSE_Value_IsArray(argValue.get())) { | 710 if (FXJSE_Value_IsArray(argValue.get())) { |
| 711 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 711 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 712 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); | 712 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); |
| 713 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); | 713 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); |
| 714 if (iLength <= 2) { | 714 if (iLength <= 2) { |
| 715 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 715 pContext->Throw(XFA_IDS_ARGUMENT_MISMATCH); |
| 716 return; | 716 return; |
| 717 } | 717 } |
| 718 | 718 |
| 719 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 719 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 720 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 720 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 721 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 721 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 722 new CFXJSE_Value(pIsolate)); | 722 new CFXJSE_Value(pIsolate)); |
| 723 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); | 723 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); |
| 724 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); | 724 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); |
| 725 if (FXJSE_Value_IsNull(propertyValue.get())) { | 725 if (FXJSE_Value_IsNull(propertyValue.get())) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 for (int32_t i = 0; i < args.GetLength(); i++) { | 786 for (int32_t i = 0; i < args.GetLength(); i++) { |
| 787 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); | 787 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); |
| 788 if (FXJSE_Value_IsNull(argValue.get())) | 788 if (FXJSE_Value_IsNull(argValue.get())) |
| 789 continue; | 789 continue; |
| 790 | 790 |
| 791 if (FXJSE_Value_IsArray(argValue.get())) { | 791 if (FXJSE_Value_IsArray(argValue.get())) { |
| 792 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 792 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 793 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); | 793 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); |
| 794 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); | 794 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); |
| 795 if (iLength <= 2) { | 795 if (iLength <= 2) { |
| 796 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 796 pContext->Throw(XFA_IDS_ARGUMENT_MISMATCH); |
| 797 return; | 797 return; |
| 798 } | 798 } |
| 799 | 799 |
| 800 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 800 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 801 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 801 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 802 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 802 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 803 new CFXJSE_Value(pIsolate)); | 803 new CFXJSE_Value(pIsolate)); |
| 804 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); | 804 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); |
| 805 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); | 805 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); |
| 806 if (FXJSE_Value_IsNull(propertyValue.get())) { | 806 if (FXJSE_Value_IsNull(propertyValue.get())) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 FXJSE_Value_SetDouble(args.GetReturnValue(), dMinValue); | 856 FXJSE_Value_SetDouble(args.GetReturnValue(), dMinValue); |
| 857 } | 857 } |
| 858 | 858 |
| 859 // static | 859 // static |
| 860 void CXFA_FM2JSContext::Mod(CFXJSE_Value* pThis, | 860 void CXFA_FM2JSContext::Mod(CFXJSE_Value* pThis, |
| 861 const CFX_ByteStringC& szFuncName, | 861 const CFX_ByteStringC& szFuncName, |
| 862 CFXJSE_Arguments& args) { | 862 CFXJSE_Arguments& args) { |
| 863 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); | 863 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); |
| 864 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 864 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 865 if (args.GetLength() != 2) { | 865 if (args.GetLength() != 2) { |
| 866 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 866 pContext->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Mod"); |
| 867 L"Mod"); | |
| 868 return; | 867 return; |
| 869 } | 868 } |
| 870 | 869 |
| 871 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 870 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 872 std::unique_ptr<CFXJSE_Value> argTwo = args.GetValue(1); | 871 std::unique_ptr<CFXJSE_Value> argTwo = args.GetValue(1); |
| 873 if (FXJSE_Value_IsNull(argOne.get()) || FXJSE_Value_IsNull(argTwo.get())) { | 872 if (FXJSE_Value_IsNull(argOne.get()) || FXJSE_Value_IsNull(argTwo.get())) { |
| 874 FXJSE_Value_SetNull(args.GetReturnValue()); | 873 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 875 return; | 874 return; |
| 876 } | 875 } |
| 877 | 876 |
| 878 FX_DOUBLE dDividend = 0.0; | 877 FX_DOUBLE dDividend = 0.0; |
| 879 FX_DOUBLE dDividor = 0.0; | 878 FX_DOUBLE dDividor = 0.0; |
| 880 if (FXJSE_Value_IsArray(argOne.get())) { | 879 if (FXJSE_Value_IsArray(argOne.get())) { |
| 881 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 880 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 882 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get()); | 881 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get()); |
| 883 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); | 882 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); |
| 884 if (iLength <= 2) { | 883 if (iLength <= 2) { |
| 885 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 884 pContext->Throw(XFA_IDS_ARGUMENT_MISMATCH); |
| 886 return; | 885 return; |
| 887 } | 886 } |
| 888 | 887 |
| 889 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 888 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 890 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 889 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 891 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 1, propertyValue.get()); | 890 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 1, propertyValue.get()); |
| 892 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, jsObjectValue.get()); | 891 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, jsObjectValue.get()); |
| 893 if (FXJSE_Value_IsNull(propertyValue.get())) { | 892 if (FXJSE_Value_IsNull(propertyValue.get())) { |
| 894 dDividend = ValueToDouble(pThis, jsObjectValue.get()); | 893 dDividend = ValueToDouble(pThis, jsObjectValue.get()); |
| 895 } else { | 894 } else { |
| 896 CFX_ByteString propertyStr; | 895 CFX_ByteString propertyStr; |
| 897 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); | 896 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); |
| 898 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 897 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 899 new CFXJSE_Value(pIsolate)); | 898 new CFXJSE_Value(pIsolate)); |
| 900 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), | 899 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), |
| 901 newPropertyValue.get()); | 900 newPropertyValue.get()); |
| 902 dDividend = ValueToDouble(pThis, newPropertyValue.get()); | 901 dDividend = ValueToDouble(pThis, newPropertyValue.get()); |
| 903 } | 902 } |
| 904 } else { | 903 } else { |
| 905 dDividend = ValueToDouble(pThis, argOne.get()); | 904 dDividend = ValueToDouble(pThis, argOne.get()); |
| 906 } | 905 } |
| 907 | 906 |
| 908 if (FXJSE_Value_IsArray(argTwo.get())) { | 907 if (FXJSE_Value_IsArray(argTwo.get())) { |
| 909 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 908 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 910 FXJSE_Value_GetObjectProp(argTwo.get(), "length", lengthValue.get()); | 909 FXJSE_Value_GetObjectProp(argTwo.get(), "length", lengthValue.get()); |
| 911 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); | 910 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); |
| 912 if (iLength <= 2) { | 911 if (iLength <= 2) { |
| 913 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 912 pContext->Throw(XFA_IDS_ARGUMENT_MISMATCH); |
| 914 return; | 913 return; |
| 915 } | 914 } |
| 916 | 915 |
| 917 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 916 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 918 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 917 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 919 FXJSE_Value_GetObjectPropByIdx(argTwo.get(), 1, propertyValue.get()); | 918 FXJSE_Value_GetObjectPropByIdx(argTwo.get(), 1, propertyValue.get()); |
| 920 FXJSE_Value_GetObjectPropByIdx(argTwo.get(), 2, jsObjectValue.get()); | 919 FXJSE_Value_GetObjectPropByIdx(argTwo.get(), 2, jsObjectValue.get()); |
| 921 if (FXJSE_Value_IsNull(propertyValue.get())) { | 920 if (FXJSE_Value_IsNull(propertyValue.get())) { |
| 922 dDividor = ValueToDouble(pThis, jsObjectValue.get()); | 921 dDividor = ValueToDouble(pThis, jsObjectValue.get()); |
| 923 } else { | 922 } else { |
| 924 CFX_ByteString propertyStr; | 923 CFX_ByteString propertyStr; |
| 925 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); | 924 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); |
| 926 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 925 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 927 new CFXJSE_Value(pIsolate)); | 926 new CFXJSE_Value(pIsolate)); |
| 928 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), | 927 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), |
| 929 newPropertyValue.get()); | 928 newPropertyValue.get()); |
| 930 dDividor = ValueToDouble(pThis, newPropertyValue.get()); | 929 dDividor = ValueToDouble(pThis, newPropertyValue.get()); |
| 931 } | 930 } |
| 932 } else { | 931 } else { |
| 933 dDividor = ValueToDouble(pThis, argTwo.get()); | 932 dDividor = ValueToDouble(pThis, argTwo.get()); |
| 934 } | 933 } |
| 935 | 934 |
| 936 if (dDividor == 0) { | 935 if (dDividor == 0) { |
| 937 pContext->ThrowScriptErrorMessage(XFA_IDS_DIVIDE_ZERO); | 936 pContext->Throw(XFA_IDS_DIVIDE_ZERO); |
| 938 return; | 937 return; |
| 939 } | 938 } |
| 940 | 939 |
| 941 FXJSE_Value_SetDouble(args.GetReturnValue(), | 940 FXJSE_Value_SetDouble(args.GetReturnValue(), |
| 942 dDividend - dDividor * (int32_t)(dDividend / dDividor)); | 941 dDividend - dDividor * (int32_t)(dDividend / dDividor)); |
| 943 } | 942 } |
| 944 | 943 |
| 945 // static | 944 // static |
| 946 void CXFA_FM2JSContext::Round(CFXJSE_Value* pThis, | 945 void CXFA_FM2JSContext::Round(CFXJSE_Value* pThis, |
| 947 const CFX_ByteStringC& szFuncName, | 946 const CFX_ByteStringC& szFuncName, |
| 948 CFXJSE_Arguments& args) { | 947 CFXJSE_Arguments& args) { |
| 949 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); | 948 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); |
| 950 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 949 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 951 int32_t argc = args.GetLength(); | 950 int32_t argc = args.GetLength(); |
| 952 uint8_t uPrecision = 0; | 951 uint8_t uPrecision = 0; |
| 953 | 952 |
| 954 if (argc != 1 && argc != 2) { | 953 if (argc != 1 && argc != 2) { |
| 955 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 954 pContext->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Round"); |
| 956 L"Round"); | |
| 957 return; | 955 return; |
| 958 } | 956 } |
| 959 | 957 |
| 960 if (argc == 1) { | 958 if (argc == 1) { |
| 961 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 959 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 962 if (FXJSE_Value_IsNull(argOne.get())) { | 960 if (FXJSE_Value_IsNull(argOne.get())) { |
| 963 FXJSE_Value_SetNull(args.GetReturnValue()); | 961 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 964 return; | 962 return; |
| 965 } | 963 } |
| 966 | 964 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1067 for (int32_t i = 0; i < argc; i++) { | 1065 for (int32_t i = 0; i < argc; i++) { |
| 1068 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); | 1066 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); |
| 1069 if (FXJSE_Value_IsNull(argValue.get())) | 1067 if (FXJSE_Value_IsNull(argValue.get())) |
| 1070 continue; | 1068 continue; |
| 1071 | 1069 |
| 1072 if (FXJSE_Value_IsArray(argValue.get())) { | 1070 if (FXJSE_Value_IsArray(argValue.get())) { |
| 1073 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 1071 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 1074 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); | 1072 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); |
| 1075 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); | 1073 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); |
| 1076 if (iLength <= 2) { | 1074 if (iLength <= 2) { |
| 1077 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 1075 pContext->Throw(XFA_IDS_ARGUMENT_MISMATCH); |
| 1078 return; | 1076 return; |
| 1079 } | 1077 } |
| 1080 | 1078 |
| 1081 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 1079 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 1082 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); | 1080 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); |
| 1083 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 1081 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 1084 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 1082 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 1085 new CFXJSE_Value(pIsolate)); | 1083 new CFXJSE_Value(pIsolate)); |
| 1086 if (FXJSE_Value_IsNull(propertyValue.get())) { | 1084 if (FXJSE_Value_IsNull(propertyValue.get())) { |
| 1087 for (int32_t j = 2; j < iLength; j++) { | 1085 for (int32_t j = 2; j < iLength; j++) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 } | 1128 } |
| 1131 | 1129 |
| 1132 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum); | 1130 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum); |
| 1133 } | 1131 } |
| 1134 | 1132 |
| 1135 // static | 1133 // static |
| 1136 void CXFA_FM2JSContext::Date(CFXJSE_Value* pThis, | 1134 void CXFA_FM2JSContext::Date(CFXJSE_Value* pThis, |
| 1137 const CFX_ByteStringC& szFuncName, | 1135 const CFX_ByteStringC& szFuncName, |
| 1138 CFXJSE_Arguments& args) { | 1136 CFXJSE_Arguments& args) { |
| 1139 if (args.GetLength() != 0) { | 1137 if (args.GetLength() != 0) { |
| 1140 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 1138 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1141 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Date"); | 1139 L"Date"); |
| 1142 return; | 1140 return; |
| 1143 } | 1141 } |
| 1144 | 1142 |
| 1145 time_t currentTime; | 1143 time_t currentTime; |
| 1146 time(¤tTime); | 1144 time(¤tTime); |
| 1147 struct tm* pTmStruct = gmtime(¤tTime); | 1145 struct tm* pTmStruct = gmtime(¤tTime); |
| 1148 | 1146 |
| 1149 CFX_ByteString bufferYear; | 1147 CFX_ByteString bufferYear; |
| 1150 CFX_ByteString bufferMon; | 1148 CFX_ByteString bufferMon; |
| 1151 CFX_ByteString bufferDay; | 1149 CFX_ByteString bufferDay; |
| 1152 bufferYear.Format("%d", pTmStruct->tm_year + 1900); | 1150 bufferYear.Format("%d", pTmStruct->tm_year + 1900); |
| 1153 bufferMon.Format("%02d", pTmStruct->tm_mon + 1); | 1151 bufferMon.Format("%02d", pTmStruct->tm_mon + 1); |
| 1154 bufferDay.Format("%02d", pTmStruct->tm_mday); | 1152 bufferDay.Format("%02d", pTmStruct->tm_mday); |
| 1155 | 1153 |
| 1156 CFX_ByteString bufferCurrent = bufferYear + bufferMon + bufferDay; | 1154 CFX_ByteString bufferCurrent = bufferYear + bufferMon + bufferDay; |
| 1157 FXJSE_Value_SetInteger(args.GetReturnValue(), | 1155 FXJSE_Value_SetInteger(args.GetReturnValue(), |
| 1158 DateString2Num(bufferCurrent.AsStringC())); | 1156 DateString2Num(bufferCurrent.AsStringC())); |
| 1159 } | 1157 } |
| 1160 | 1158 |
| 1161 // static | 1159 // static |
| 1162 void CXFA_FM2JSContext::Date2Num(CFXJSE_Value* pThis, | 1160 void CXFA_FM2JSContext::Date2Num(CFXJSE_Value* pThis, |
| 1163 const CFX_ByteStringC& szFuncName, | 1161 const CFX_ByteStringC& szFuncName, |
| 1164 CFXJSE_Arguments& args) { | 1162 CFXJSE_Arguments& args) { |
| 1165 int32_t argc = args.GetLength(); | 1163 int32_t argc = args.GetLength(); |
| 1166 if ((argc <= 0) || (argc >= 4)) { | 1164 if ((argc <= 0) || (argc >= 4)) { |
| 1167 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 1165 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1168 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Date2Num"); | 1166 L"Date2Num"); |
| 1169 return; | 1167 return; |
| 1170 } | 1168 } |
| 1171 | 1169 |
| 1172 std::unique_ptr<CFXJSE_Value> dateValue = GetSimpleValue(pThis, args, 0); | 1170 std::unique_ptr<CFXJSE_Value> dateValue = GetSimpleValue(pThis, args, 0); |
| 1173 if (ValueIsNull(pThis, dateValue.get())) { | 1171 if (ValueIsNull(pThis, dateValue.get())) { |
| 1174 FXJSE_Value_SetNull(args.GetReturnValue()); | 1172 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1175 return; | 1173 return; |
| 1176 } | 1174 } |
| 1177 | 1175 |
| 1178 CFX_ByteString dateString; | 1176 CFX_ByteString dateString; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1208 FXJSE_Value_SetInteger(args.GetReturnValue(), | 1206 FXJSE_Value_SetInteger(args.GetReturnValue(), |
| 1209 DateString2Num(szIsoDateString.AsStringC())); | 1207 DateString2Num(szIsoDateString.AsStringC())); |
| 1210 } | 1208 } |
| 1211 | 1209 |
| 1212 // static | 1210 // static |
| 1213 void CXFA_FM2JSContext::DateFmt(CFXJSE_Value* pThis, | 1211 void CXFA_FM2JSContext::DateFmt(CFXJSE_Value* pThis, |
| 1214 const CFX_ByteStringC& szFuncName, | 1212 const CFX_ByteStringC& szFuncName, |
| 1215 CFXJSE_Arguments& args) { | 1213 CFXJSE_Arguments& args) { |
| 1216 int32_t argc = args.GetLength(); | 1214 int32_t argc = args.GetLength(); |
| 1217 if (argc >= 3) { | 1215 if (argc >= 3) { |
| 1218 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 1216 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1219 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Date2Num"); | 1217 L"Date2Num"); |
| 1220 return; | 1218 return; |
| 1221 } | 1219 } |
| 1222 | 1220 |
| 1223 int32_t iStyle = 0; | 1221 int32_t iStyle = 0; |
| 1224 if (argc > 0) { | 1222 if (argc > 0) { |
| 1225 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0); | 1223 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0); |
| 1226 if (FXJSE_Value_IsNull(argStyle.get())) { | 1224 if (FXJSE_Value_IsNull(argStyle.get())) { |
| 1227 FXJSE_Value_SetNull(args.GetReturnValue()); | 1225 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1228 return; | 1226 return; |
| 1229 } | 1227 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1249 formatStr = ""; | 1247 formatStr = ""; |
| 1250 | 1248 |
| 1251 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); | 1249 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); |
| 1252 } | 1250 } |
| 1253 | 1251 |
| 1254 // static | 1252 // static |
| 1255 void CXFA_FM2JSContext::IsoDate2Num(CFXJSE_Value* pThis, | 1253 void CXFA_FM2JSContext::IsoDate2Num(CFXJSE_Value* pThis, |
| 1256 const CFX_ByteStringC& szFuncName, | 1254 const CFX_ByteStringC& szFuncName, |
| 1257 CFXJSE_Arguments& args) { | 1255 CFXJSE_Arguments& args) { |
| 1258 if (args.GetLength() != 1) { | 1256 if (args.GetLength() != 1) { |
| 1259 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 1257 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1260 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"IsoDate2Num"); | 1258 L"IsoDate2Num"); |
| 1261 return; | 1259 return; |
| 1262 } | 1260 } |
| 1263 | 1261 |
| 1264 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 1262 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 1265 if (FXJSE_Value_IsNull(argOne.get())) { | 1263 if (FXJSE_Value_IsNull(argOne.get())) { |
| 1266 FXJSE_Value_SetNull(args.GetReturnValue()); | 1264 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1267 return; | 1265 return; |
| 1268 } | 1266 } |
| 1269 | 1267 |
| 1270 CFX_ByteString szArgString; | 1268 CFX_ByteString szArgString; |
| 1271 ValueToUTF8String(argOne.get(), szArgString); | 1269 ValueToUTF8String(argOne.get(), szArgString); |
| 1272 FXJSE_Value_SetInteger(args.GetReturnValue(), | 1270 FXJSE_Value_SetInteger(args.GetReturnValue(), |
| 1273 DateString2Num(szArgString.AsStringC())); | 1271 DateString2Num(szArgString.AsStringC())); |
| 1274 } | 1272 } |
| 1275 | 1273 |
| 1276 // static | 1274 // static |
| 1277 void CXFA_FM2JSContext::IsoTime2Num(CFXJSE_Value* pThis, | 1275 void CXFA_FM2JSContext::IsoTime2Num(CFXJSE_Value* pThis, |
| 1278 const CFX_ByteStringC& szFuncName, | 1276 const CFX_ByteStringC& szFuncName, |
| 1279 CFXJSE_Arguments& args) { | 1277 CFXJSE_Arguments& args) { |
| 1280 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); | 1278 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); |
| 1281 if (args.GetLength() != 1) { | 1279 if (args.GetLength() != 1) { |
| 1282 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1280 pContext->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"IsoTime2Num"); |
| 1283 L"IsoTime2Num"); | |
| 1284 return; | 1281 return; |
| 1285 } | 1282 } |
| 1286 | 1283 |
| 1287 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 1284 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 1288 if (ValueIsNull(pThis, argOne.get())) { | 1285 if (ValueIsNull(pThis, argOne.get())) { |
| 1289 FXJSE_Value_SetNull(args.GetReturnValue()); | 1286 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1290 return; | 1287 return; |
| 1291 } | 1288 } |
| 1292 | 1289 |
| 1293 CXFA_Document* pDoc = pContext->GetDocument(); | 1290 CXFA_Document* pDoc = pContext->GetDocument(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1362 CFX_ByteString formatStr; | 1359 CFX_ByteString formatStr; |
| 1363 GetLocalDateFormat(pThis, iStyle, szLocal.AsStringC(), formatStr, FALSE); | 1360 GetLocalDateFormat(pThis, iStyle, szLocal.AsStringC(), formatStr, FALSE); |
| 1364 if (formatStr.IsEmpty()) { | 1361 if (formatStr.IsEmpty()) { |
| 1365 formatStr = ""; | 1362 formatStr = ""; |
| 1366 } | 1363 } |
| 1367 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); | 1364 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); |
| 1368 } else { | 1365 } else { |
| 1369 FXJSE_Value_SetNull(args.GetReturnValue()); | 1366 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1370 } | 1367 } |
| 1371 } else { | 1368 } else { |
| 1372 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 1369 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1373 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"LocalDateFmt"); | 1370 L"LocalDateFmt"); |
| 1374 } | 1371 } |
| 1375 } | 1372 } |
| 1376 | 1373 |
| 1377 // static | 1374 // static |
| 1378 void CXFA_FM2JSContext::LocalTimeFmt(CFXJSE_Value* pThis, | 1375 void CXFA_FM2JSContext::LocalTimeFmt(CFXJSE_Value* pThis, |
| 1379 const CFX_ByteStringC& szFuncName, | 1376 const CFX_ByteStringC& szFuncName, |
| 1380 CFXJSE_Arguments& args) { | 1377 CFXJSE_Arguments& args) { |
| 1381 int32_t argc = args.GetLength(); | 1378 int32_t argc = args.GetLength(); |
| 1382 if (argc < 3) { | 1379 if (argc < 3) { |
| 1383 FX_BOOL bFlags = FALSE; | 1380 FX_BOOL bFlags = FALSE; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1405 CFX_ByteString formatStr; | 1402 CFX_ByteString formatStr; |
| 1406 GetLocalTimeFormat(pThis, iStyle, szLocal.AsStringC(), formatStr, FALSE); | 1403 GetLocalTimeFormat(pThis, iStyle, szLocal.AsStringC(), formatStr, FALSE); |
| 1407 if (formatStr.IsEmpty()) { | 1404 if (formatStr.IsEmpty()) { |
| 1408 formatStr = ""; | 1405 formatStr = ""; |
| 1409 } | 1406 } |
| 1410 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); | 1407 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); |
| 1411 } else { | 1408 } else { |
| 1412 FXJSE_Value_SetNull(args.GetReturnValue()); | 1409 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1413 } | 1410 } |
| 1414 } else { | 1411 } else { |
| 1415 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 1412 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1416 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"LocalTimeFmt"); | 1413 L"LocalTimeFmt"); |
| 1417 } | 1414 } |
| 1418 } | 1415 } |
| 1419 | 1416 |
| 1420 // static | 1417 // static |
| 1421 void CXFA_FM2JSContext::Num2Date(CFXJSE_Value* pThis, | 1418 void CXFA_FM2JSContext::Num2Date(CFXJSE_Value* pThis, |
| 1422 const CFX_ByteStringC& szFuncName, | 1419 const CFX_ByteStringC& szFuncName, |
| 1423 CFXJSE_Arguments& args) { | 1420 CFXJSE_Arguments& args) { |
| 1424 int32_t argc = args.GetLength(); | 1421 int32_t argc = args.GetLength(); |
| 1425 if ((argc > 0) && (argc < 4)) { | 1422 if ((argc > 0) && (argc < 4)) { |
| 1426 FX_BOOL bFlags = FALSE; | 1423 FX_BOOL bFlags = FALSE; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1552 szLocalDateString); | 1549 szLocalDateString); |
| 1553 if (szLocalDateString.IsEmpty()) { | 1550 if (szLocalDateString.IsEmpty()) { |
| 1554 szLocalDateString = ""; | 1551 szLocalDateString = ""; |
| 1555 } | 1552 } |
| 1556 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 1553 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 1557 szLocalDateString.AsStringC()); | 1554 szLocalDateString.AsStringC()); |
| 1558 } else { | 1555 } else { |
| 1559 FXJSE_Value_SetNull(args.GetReturnValue()); | 1556 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1560 } | 1557 } |
| 1561 } else { | 1558 } else { |
| 1562 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 1559 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1563 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2Date"); | 1560 L"Num2Date"); |
| 1564 } | 1561 } |
| 1565 } | 1562 } |
| 1566 | 1563 |
| 1567 // static | 1564 // static |
| 1568 void CXFA_FM2JSContext::Num2GMTime(CFXJSE_Value* pThis, | 1565 void CXFA_FM2JSContext::Num2GMTime(CFXJSE_Value* pThis, |
| 1569 const CFX_ByteStringC& szFuncName, | 1566 const CFX_ByteStringC& szFuncName, |
| 1570 CFXJSE_Arguments& args) { | 1567 CFXJSE_Arguments& args) { |
| 1571 int32_t argc = args.GetLength(); | 1568 int32_t argc = args.GetLength(); |
| 1572 if ((argc > 0) && (argc < 4)) { | 1569 if ((argc > 0) && (argc < 4)) { |
| 1573 FX_BOOL bFlags = FALSE; | 1570 FX_BOOL bFlags = FALSE; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1606 localString.AsStringC(), TRUE, szGMTTimeString); | 1603 localString.AsStringC(), TRUE, szGMTTimeString); |
| 1607 if (szGMTTimeString.IsEmpty()) { | 1604 if (szGMTTimeString.IsEmpty()) { |
| 1608 szGMTTimeString = ""; | 1605 szGMTTimeString = ""; |
| 1609 } | 1606 } |
| 1610 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 1607 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 1611 szGMTTimeString.AsStringC()); | 1608 szGMTTimeString.AsStringC()); |
| 1612 } else { | 1609 } else { |
| 1613 FXJSE_Value_SetNull(args.GetReturnValue()); | 1610 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1614 } | 1611 } |
| 1615 } else { | 1612 } else { |
| 1616 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 1613 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1617 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2GMTime"); | 1614 L"Num2GMTime"); |
| 1618 } | 1615 } |
| 1619 } | 1616 } |
| 1620 | 1617 |
| 1621 // static | 1618 // static |
| 1622 void CXFA_FM2JSContext::Num2Time(CFXJSE_Value* pThis, | 1619 void CXFA_FM2JSContext::Num2Time(CFXJSE_Value* pThis, |
| 1623 const CFX_ByteStringC& szFuncName, | 1620 const CFX_ByteStringC& szFuncName, |
| 1624 CFXJSE_Arguments& args) { | 1621 CFXJSE_Arguments& args) { |
| 1625 int32_t argc = args.GetLength(); | 1622 int32_t argc = args.GetLength(); |
| 1626 if ((argc > 0) && (argc < 4)) { | 1623 if ((argc > 0) && (argc < 4)) { |
| 1627 FX_BOOL bFlags = FALSE; | 1624 FX_BOOL bFlags = FALSE; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1660 localString.AsStringC(), FALSE, szLocalTimeString); | 1657 localString.AsStringC(), FALSE, szLocalTimeString); |
| 1661 if (szLocalTimeString.IsEmpty()) { | 1658 if (szLocalTimeString.IsEmpty()) { |
| 1662 szLocalTimeString = ""; | 1659 szLocalTimeString = ""; |
| 1663 } | 1660 } |
| 1664 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 1661 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 1665 szLocalTimeString.AsStringC()); | 1662 szLocalTimeString.AsStringC()); |
| 1666 } else { | 1663 } else { |
| 1667 FXJSE_Value_SetNull(args.GetReturnValue()); | 1664 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1668 } | 1665 } |
| 1669 } else { | 1666 } else { |
| 1670 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 1667 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1671 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2Time"); | 1668 L"Num2Time"); |
| 1672 } | 1669 } |
| 1673 } | 1670 } |
| 1674 | 1671 |
| 1675 // static | 1672 // static |
| 1676 void CXFA_FM2JSContext::Time(CFXJSE_Value* pThis, | 1673 void CXFA_FM2JSContext::Time(CFXJSE_Value* pThis, |
| 1677 const CFX_ByteStringC& szFuncName, | 1674 const CFX_ByteStringC& szFuncName, |
| 1678 CFXJSE_Arguments& args) { | 1675 CFXJSE_Arguments& args) { |
| 1679 if (args.GetLength() == 0) { | 1676 if (args.GetLength() == 0) { |
| 1680 time_t now; | 1677 time_t now; |
| 1681 time(&now); | 1678 time(&now); |
| 1682 struct tm* pGmt = gmtime(&now); | 1679 struct tm* pGmt = gmtime(&now); |
| 1683 int32_t iGMHour = pGmt->tm_hour; | 1680 int32_t iGMHour = pGmt->tm_hour; |
| 1684 int32_t iGMMin = pGmt->tm_min; | 1681 int32_t iGMMin = pGmt->tm_min; |
| 1685 int32_t iGMSec = pGmt->tm_sec; | 1682 int32_t iGMSec = pGmt->tm_sec; |
| 1686 FXJSE_Value_SetInteger(args.GetReturnValue(), | 1683 FXJSE_Value_SetInteger(args.GetReturnValue(), |
| 1687 ((iGMHour * 3600 + iGMMin * 60 + iGMSec) * 1000)); | 1684 ((iGMHour * 3600 + iGMMin * 60 + iGMSec) * 1000)); |
| 1688 } else { | 1685 } else { |
| 1689 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 1686 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1690 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Time"); | 1687 L"Time"); |
| 1691 } | 1688 } |
| 1692 } | 1689 } |
| 1693 | 1690 |
| 1694 // static | 1691 // static |
| 1695 void CXFA_FM2JSContext::Time2Num(CFXJSE_Value* pThis, | 1692 void CXFA_FM2JSContext::Time2Num(CFXJSE_Value* pThis, |
| 1696 const CFX_ByteStringC& szFuncName, | 1693 const CFX_ByteStringC& szFuncName, |
| 1697 CFXJSE_Arguments& args) { | 1694 CFXJSE_Arguments& args) { |
| 1698 int32_t argc = args.GetLength(); | 1695 int32_t argc = args.GetLength(); |
| 1699 if ((argc > 0) && (argc < 4)) { | 1696 if ((argc > 0) && (argc < 4)) { |
| 1700 FX_BOOL bFlags = FALSE; | 1697 FX_BOOL bFlags = FALSE; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1773 int32_t iResult = | 1770 int32_t iResult = |
| 1774 hour * 3600000 + min * 60000 + second * 1000 + milSecond + 1; | 1771 hour * 3600000 + min * 60000 + second * 1000 + milSecond + 1; |
| 1775 FXJSE_Value_SetInteger(args.GetReturnValue(), iResult); | 1772 FXJSE_Value_SetInteger(args.GetReturnValue(), iResult); |
| 1776 } else { | 1773 } else { |
| 1777 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 1774 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
| 1778 } | 1775 } |
| 1779 } else { | 1776 } else { |
| 1780 FXJSE_Value_SetNull(args.GetReturnValue()); | 1777 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1781 } | 1778 } |
| 1782 } else { | 1779 } else { |
| 1783 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 1780 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1784 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Time2Num"); | 1781 L"Time2Num"); |
| 1785 } | 1782 } |
| 1786 } | 1783 } |
| 1787 | 1784 |
| 1788 // static | 1785 // static |
| 1789 void CXFA_FM2JSContext::TimeFmt(CFXJSE_Value* pThis, | 1786 void CXFA_FM2JSContext::TimeFmt(CFXJSE_Value* pThis, |
| 1790 const CFX_ByteStringC& szFuncName, | 1787 const CFX_ByteStringC& szFuncName, |
| 1791 CFXJSE_Arguments& args) { | 1788 CFXJSE_Arguments& args) { |
| 1792 int32_t argc = args.GetLength(); | 1789 int32_t argc = args.GetLength(); |
| 1793 if (argc < 3) { | 1790 if (argc < 3) { |
| 1794 FX_BOOL bFlags = FALSE; | 1791 FX_BOOL bFlags = FALSE; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1816 CFX_ByteString formatStr; | 1813 CFX_ByteString formatStr; |
| 1817 GetStandardTimeFormat(pThis, iStyle, szLocal.AsStringC(), formatStr); | 1814 GetStandardTimeFormat(pThis, iStyle, szLocal.AsStringC(), formatStr); |
| 1818 if (formatStr.IsEmpty()) { | 1815 if (formatStr.IsEmpty()) { |
| 1819 formatStr = ""; | 1816 formatStr = ""; |
| 1820 } | 1817 } |
| 1821 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); | 1818 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); |
| 1822 } else { | 1819 } else { |
| 1823 FXJSE_Value_SetNull(args.GetReturnValue()); | 1820 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1824 } | 1821 } |
| 1825 } else { | 1822 } else { |
| 1826 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 1823 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1827 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"TimeFmt"); | 1824 L"TimeFmt"); |
| 1828 } | 1825 } |
| 1829 } | 1826 } |
| 1830 | 1827 |
| 1831 // static | 1828 // static |
| 1832 FX_BOOL CXFA_FM2JSContext::IsIsoDateFormat(const FX_CHAR* pData, | 1829 FX_BOOL CXFA_FM2JSContext::IsIsoDateFormat(const FX_CHAR* pData, |
| 1833 int32_t iLength, | 1830 int32_t iLength, |
| 1834 int32_t& iStyle, | 1831 int32_t& iStyle, |
| 1835 int32_t& iYear, | 1832 int32_t& iYear, |
| 1836 int32_t& iMonth, | 1833 int32_t& iMonth, |
| 1837 int32_t& iDay) { | 1834 int32_t& iDay) { |
| (...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2619 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || | 2616 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || |
| 2620 ValueIsNull(pThis, argThree.get())); | 2617 ValueIsNull(pThis, argThree.get())); |
| 2621 if (bFlags) { | 2618 if (bFlags) { |
| 2622 FXJSE_Value_SetNull(args.GetReturnValue()); | 2619 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2623 } else { | 2620 } else { |
| 2624 nPrincipal = ValueToDouble(pThis, argOne.get()); | 2621 nPrincipal = ValueToDouble(pThis, argOne.get()); |
| 2625 nPayment = ValueToDouble(pThis, argTwo.get()); | 2622 nPayment = ValueToDouble(pThis, argTwo.get()); |
| 2626 nPeriods = ValueToDouble(pThis, argThree.get()); | 2623 nPeriods = ValueToDouble(pThis, argThree.get()); |
| 2627 bFlags = ((nPrincipal <= 0) || (nPayment <= 0) || (nPeriods <= 0)); | 2624 bFlags = ((nPrincipal <= 0) || (nPayment <= 0) || (nPeriods <= 0)); |
| 2628 if (bFlags) { | 2625 if (bFlags) { |
| 2629 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2626 pContext->Throw(XFA_IDS_ARGUMENT_MISMATCH); |
| 2630 } else { | 2627 } else { |
| 2631 FX_DOUBLE r = | 2628 FX_DOUBLE r = |
| 2632 2 * (nPeriods * nPayment - nPrincipal) / (nPeriods * nPrincipal); | 2629 2 * (nPeriods * nPayment - nPrincipal) / (nPeriods * nPrincipal); |
| 2633 FX_DOUBLE nTemp = 1; | 2630 FX_DOUBLE nTemp = 1; |
| 2634 for (int32_t i = 0; i < nPeriods; ++i) { | 2631 for (int32_t i = 0; i < nPeriods; ++i) { |
| 2635 nTemp *= (1 + r); | 2632 nTemp *= (1 + r); |
| 2636 } | 2633 } |
| 2637 FX_DOUBLE nRet = r * nTemp / (nTemp - 1) - nPayment / nPrincipal; | 2634 FX_DOUBLE nRet = r * nTemp / (nTemp - 1) - nPayment / nPrincipal; |
| 2638 while (fabs(nRet) > kFinancialPrecision && !bFlags) { | 2635 while (fabs(nRet) > kFinancialPrecision && !bFlags) { |
| 2639 FX_DOUBLE nDerivative = 0; | 2636 FX_DOUBLE nDerivative = 0; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2654 } | 2651 } |
| 2655 if (bFlags) { | 2652 if (bFlags) { |
| 2656 FXJSE_Value_SetNull(args.GetReturnValue()); | 2653 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2657 } else { | 2654 } else { |
| 2658 r = r * 12; | 2655 r = r * 12; |
| 2659 FXJSE_Value_SetDouble(args.GetReturnValue(), r); | 2656 FXJSE_Value_SetDouble(args.GetReturnValue(), r); |
| 2660 } | 2657 } |
| 2661 } | 2658 } |
| 2662 } | 2659 } |
| 2663 } else { | 2660 } else { |
| 2664 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2661 pContext->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Apr"); |
| 2665 L"Apr"); | |
| 2666 } | 2662 } |
| 2667 } | 2663 } |
| 2668 | 2664 |
| 2669 // static | 2665 // static |
| 2670 void CXFA_FM2JSContext::CTerm(CFXJSE_Value* pThis, | 2666 void CXFA_FM2JSContext::CTerm(CFXJSE_Value* pThis, |
| 2671 const CFX_ByteStringC& szFuncName, | 2667 const CFX_ByteStringC& szFuncName, |
| 2672 CFXJSE_Arguments& args) { | 2668 CFXJSE_Arguments& args) { |
| 2673 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); | 2669 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); |
| 2674 if (args.GetLength() == 3) { | 2670 if (args.GetLength() == 3) { |
| 2675 FX_BOOL bFlags = FALSE; | 2671 FX_BOOL bFlags = FALSE; |
| 2676 FX_FLOAT nRate = 0; | 2672 FX_FLOAT nRate = 0; |
| 2677 FX_FLOAT nFutureValue = 0; | 2673 FX_FLOAT nFutureValue = 0; |
| 2678 FX_FLOAT nInitAmount = 0; | 2674 FX_FLOAT nInitAmount = 0; |
| 2679 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 2675 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 2680 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | 2676 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
| 2681 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); | 2677 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); |
| 2682 bFlags = | 2678 bFlags = |
| 2683 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || | 2679 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || |
| 2684 ValueIsNull(pThis, argThree.get())); | 2680 ValueIsNull(pThis, argThree.get())); |
| 2685 if (bFlags) { | 2681 if (bFlags) { |
| 2686 FXJSE_Value_SetNull(args.GetReturnValue()); | 2682 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2687 } else { | 2683 } else { |
| 2688 nRate = ValueToFloat(pThis, argOne.get()); | 2684 nRate = ValueToFloat(pThis, argOne.get()); |
| 2689 nFutureValue = ValueToFloat(pThis, argTwo.get()); | 2685 nFutureValue = ValueToFloat(pThis, argTwo.get()); |
| 2690 nInitAmount = ValueToFloat(pThis, argThree.get()); | 2686 nInitAmount = ValueToFloat(pThis, argThree.get()); |
| 2691 bFlags = ((nRate <= 0) || (nFutureValue <= 0) || (nInitAmount <= 0)); | 2687 bFlags = ((nRate <= 0) || (nFutureValue <= 0) || (nInitAmount <= 0)); |
| 2692 if (bFlags) { | 2688 if (bFlags) { |
| 2693 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2689 pContext->Throw(XFA_IDS_ARGUMENT_MISMATCH); |
| 2694 } else { | 2690 } else { |
| 2695 FXJSE_Value_SetFloat(args.GetReturnValue(), | 2691 FXJSE_Value_SetFloat(args.GetReturnValue(), |
| 2696 FXSYS_log((FX_FLOAT)(nFutureValue / nInitAmount)) / | 2692 FXSYS_log((FX_FLOAT)(nFutureValue / nInitAmount)) / |
| 2697 FXSYS_log((FX_FLOAT)(1 + nRate))); | 2693 FXSYS_log((FX_FLOAT)(1 + nRate))); |
| 2698 } | 2694 } |
| 2699 } | 2695 } |
| 2700 } else { | 2696 } else { |
| 2701 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2697 pContext->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"CTerm"); |
| 2702 L"CTerm"); | |
| 2703 } | 2698 } |
| 2704 } | 2699 } |
| 2705 | 2700 |
| 2706 // static | 2701 // static |
| 2707 void CXFA_FM2JSContext::FV(CFXJSE_Value* pThis, | 2702 void CXFA_FM2JSContext::FV(CFXJSE_Value* pThis, |
| 2708 const CFX_ByteStringC& szFuncName, | 2703 const CFX_ByteStringC& szFuncName, |
| 2709 CFXJSE_Arguments& args) { | 2704 CFXJSE_Arguments& args) { |
| 2710 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); | 2705 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); |
| 2711 if (args.GetLength() == 3) { | 2706 if (args.GetLength() == 3) { |
| 2712 FX_BOOL bFlags = FALSE; | 2707 FX_BOOL bFlags = FALSE; |
| 2713 FX_DOUBLE nAmount = 0; | 2708 FX_DOUBLE nAmount = 0; |
| 2714 FX_DOUBLE nRate = 0; | 2709 FX_DOUBLE nRate = 0; |
| 2715 FX_DOUBLE nPeriod = 0; | 2710 FX_DOUBLE nPeriod = 0; |
| 2716 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 2711 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 2717 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | 2712 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
| 2718 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); | 2713 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); |
| 2719 bFlags = | 2714 bFlags = |
| 2720 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || | 2715 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || |
| 2721 ValueIsNull(pThis, argThree.get())); | 2716 ValueIsNull(pThis, argThree.get())); |
| 2722 if (bFlags) { | 2717 if (bFlags) { |
| 2723 FXJSE_Value_SetNull(args.GetReturnValue()); | 2718 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2724 } else { | 2719 } else { |
| 2725 nAmount = ValueToDouble(pThis, argOne.get()); | 2720 nAmount = ValueToDouble(pThis, argOne.get()); |
| 2726 nRate = ValueToDouble(pThis, argTwo.get()); | 2721 nRate = ValueToDouble(pThis, argTwo.get()); |
| 2727 nPeriod = ValueToDouble(pThis, argThree.get()); | 2722 nPeriod = ValueToDouble(pThis, argThree.get()); |
| 2728 bFlags = ((nRate < 0) || (nPeriod <= 0) || (nAmount <= 0)); | 2723 bFlags = ((nRate < 0) || (nPeriod <= 0) || (nAmount <= 0)); |
| 2729 if (bFlags) { | 2724 if (bFlags) { |
| 2730 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2725 pContext->Throw(XFA_IDS_ARGUMENT_MISMATCH); |
| 2731 } else { | 2726 } else { |
| 2732 FX_DOUBLE dResult = 0; | 2727 FX_DOUBLE dResult = 0; |
| 2733 if (!nRate) { | 2728 if (!nRate) { |
| 2734 dResult = nAmount * nPeriod; | 2729 dResult = nAmount * nPeriod; |
| 2735 } else { | 2730 } else { |
| 2736 FX_DOUBLE nTemp = 1; | 2731 FX_DOUBLE nTemp = 1; |
| 2737 for (int i = 0; i < nPeriod; ++i) { | 2732 for (int i = 0; i < nPeriod; ++i) { |
| 2738 nTemp *= 1 + nRate; | 2733 nTemp *= 1 + nRate; |
| 2739 } | 2734 } |
| 2740 dResult = nAmount * (nTemp - 1) / nRate; | 2735 dResult = nAmount * (nTemp - 1) / nRate; |
| 2741 } | 2736 } |
| 2742 FXJSE_Value_SetDouble(args.GetReturnValue(), dResult); | 2737 FXJSE_Value_SetDouble(args.GetReturnValue(), dResult); |
| 2743 } | 2738 } |
| 2744 } | 2739 } |
| 2745 } else { | 2740 } else { |
| 2746 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2741 pContext->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"FV"); |
| 2747 L"FV"); | |
| 2748 } | 2742 } |
| 2749 } | 2743 } |
| 2750 | 2744 |
| 2751 // static | 2745 // static |
| 2752 void CXFA_FM2JSContext::IPmt(CFXJSE_Value* pThis, | 2746 void CXFA_FM2JSContext::IPmt(CFXJSE_Value* pThis, |
| 2753 const CFX_ByteStringC& szFuncName, | 2747 const CFX_ByteStringC& szFuncName, |
| 2754 CFXJSE_Arguments& args) { | 2748 CFXJSE_Arguments& args) { |
| 2755 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); | 2749 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); |
| 2756 if (args.GetLength() == 5) { | 2750 if (args.GetLength() == 5) { |
| 2757 FX_BOOL bFlags = FALSE; | 2751 FX_BOOL bFlags = FALSE; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2774 FXJSE_Value_SetNull(args.GetReturnValue()); | 2768 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2775 } else { | 2769 } else { |
| 2776 nPrincpalAmount = ValueToFloat(pThis, argOne.get()); | 2770 nPrincpalAmount = ValueToFloat(pThis, argOne.get()); |
| 2777 nRate = ValueToFloat(pThis, argTwo.get()); | 2771 nRate = ValueToFloat(pThis, argTwo.get()); |
| 2778 nPayment = ValueToFloat(pThis, argThree.get()); | 2772 nPayment = ValueToFloat(pThis, argThree.get()); |
| 2779 nFirstMonth = ValueToFloat(pThis, argFour.get()); | 2773 nFirstMonth = ValueToFloat(pThis, argFour.get()); |
| 2780 nNumberOfMonths = ValueToFloat(pThis, argFive.get()); | 2774 nNumberOfMonths = ValueToFloat(pThis, argFive.get()); |
| 2781 bFlags = ((nPrincpalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) || | 2775 bFlags = ((nPrincpalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) || |
| 2782 (nFirstMonth < 0) || (nNumberOfMonths < 0)); | 2776 (nFirstMonth < 0) || (nNumberOfMonths < 0)); |
| 2783 if (bFlags) { | 2777 if (bFlags) { |
| 2784 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2778 pContext->Throw(XFA_IDS_ARGUMENT_MISMATCH); |
| 2785 } else { | 2779 } else { |
| 2786 FX_FLOAT fResult = 0; | 2780 FX_FLOAT fResult = 0; |
| 2787 FX_FLOAT nRateOfMonth = nRate / 12; | 2781 FX_FLOAT nRateOfMonth = nRate / 12; |
| 2788 int32_t iNums = | 2782 int32_t iNums = |
| 2789 (int32_t)((FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount)) - | 2783 (int32_t)((FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount)) - |
| 2790 FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount - | 2784 FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount - |
| 2791 nRateOfMonth))) / | 2785 nRateOfMonth))) / |
| 2792 FXSYS_log10((FX_FLOAT)(1 + nRateOfMonth))); | 2786 FXSYS_log10((FX_FLOAT)(1 + nRateOfMonth))); |
| 2793 int32_t iEnd = (int32_t)(nFirstMonth + nNumberOfMonths - 1); | 2787 int32_t iEnd = (int32_t)(nFirstMonth + nNumberOfMonths - 1); |
| 2794 if (iEnd > iNums) { | 2788 if (iEnd > iNums) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2807 for (; i < iEnd; ++i) { | 2801 for (; i < iEnd; ++i) { |
| 2808 nSum += nPrincpalAmount * nRateOfMonth; | 2802 nSum += nPrincpalAmount * nRateOfMonth; |
| 2809 nPrincpalAmount -= nPayment - nPrincpalAmount * nRateOfMonth; | 2803 nPrincpalAmount -= nPayment - nPrincpalAmount * nRateOfMonth; |
| 2810 } | 2804 } |
| 2811 fResult = nSum; | 2805 fResult = nSum; |
| 2812 } | 2806 } |
| 2813 FXJSE_Value_SetFloat(args.GetReturnValue(), fResult); | 2807 FXJSE_Value_SetFloat(args.GetReturnValue(), fResult); |
| 2814 } | 2808 } |
| 2815 } | 2809 } |
| 2816 } else { | 2810 } else { |
| 2817 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2811 pContext->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"IPmt"); |
| 2818 L"IPmt"); | |
| 2819 } | 2812 } |
| 2820 } | 2813 } |
| 2821 | 2814 |
| 2822 // static | 2815 // static |
| 2823 void CXFA_FM2JSContext::NPV(CFXJSE_Value* pThis, | 2816 void CXFA_FM2JSContext::NPV(CFXJSE_Value* pThis, |
| 2824 const CFX_ByteStringC& szFuncName, | 2817 const CFX_ByteStringC& szFuncName, |
| 2825 CFXJSE_Arguments& args) { | 2818 CFXJSE_Arguments& args) { |
| 2826 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); | 2819 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); |
| 2827 int32_t argc = args.GetLength(); | 2820 int32_t argc = args.GetLength(); |
| 2828 if (argc > 2) { | 2821 if (argc > 2) { |
| 2829 FX_BOOL bFlags = FALSE; | 2822 FX_BOOL bFlags = FALSE; |
| 2830 std::vector<std::unique_ptr<CFXJSE_Value>> argValues; | 2823 std::vector<std::unique_ptr<CFXJSE_Value>> argValues; |
| 2831 for (int32_t i = 0; i < argc; i++) { | 2824 for (int32_t i = 0; i < argc; i++) { |
| 2832 argValues.push_back(GetSimpleValue(pThis, args, i)); | 2825 argValues.push_back(GetSimpleValue(pThis, args, i)); |
| 2833 if (ValueIsNull(pThis, argValues[i].get())) { | 2826 if (ValueIsNull(pThis, argValues[i].get())) { |
| 2834 bFlags = TRUE; | 2827 bFlags = TRUE; |
| 2835 } | 2828 } |
| 2836 } | 2829 } |
| 2837 if (!bFlags && argc > 0) { | 2830 if (!bFlags && argc > 0) { |
| 2838 FX_DOUBLE nRate = 0; | 2831 FX_DOUBLE nRate = 0; |
| 2839 nRate = ValueToDouble(pThis, argValues[0].get()); | 2832 nRate = ValueToDouble(pThis, argValues[0].get()); |
| 2840 if (nRate <= 0) { | 2833 if (nRate <= 0) { |
| 2841 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2834 pContext->Throw(XFA_IDS_ARGUMENT_MISMATCH); |
| 2842 } else { | 2835 } else { |
| 2843 FX_DOUBLE* pData = FX_Alloc(FX_DOUBLE, argc - 1); | 2836 FX_DOUBLE* pData = FX_Alloc(FX_DOUBLE, argc - 1); |
| 2844 for (int32_t i = 1; i < argc; i++) { | 2837 for (int32_t i = 1; i < argc; i++) { |
| 2845 pData[i - 1] = ValueToDouble(pThis, argValues[i].get()); | 2838 pData[i - 1] = ValueToDouble(pThis, argValues[i].get()); |
| 2846 } | 2839 } |
| 2847 FX_DOUBLE nSum = 0; | 2840 FX_DOUBLE nSum = 0; |
| 2848 int32_t iIndex = 0; | 2841 int32_t iIndex = 0; |
| 2849 for (int32_t i = 0; i < argc - 1; i++) { | 2842 for (int32_t i = 0; i < argc - 1; i++) { |
| 2850 FX_DOUBLE nTemp = 1; | 2843 FX_DOUBLE nTemp = 1; |
| 2851 for (int32_t j = 0; j <= i; j++) { | 2844 for (int32_t j = 0; j <= i; j++) { |
| 2852 nTemp *= 1 + nRate; | 2845 nTemp *= 1 + nRate; |
| 2853 } | 2846 } |
| 2854 FX_DOUBLE nNum = *(pData + iIndex++); | 2847 FX_DOUBLE nNum = *(pData + iIndex++); |
| 2855 nSum += nNum / nTemp; | 2848 nSum += nNum / nTemp; |
| 2856 } | 2849 } |
| 2857 FXJSE_Value_SetDouble(args.GetReturnValue(), nSum); | 2850 FXJSE_Value_SetDouble(args.GetReturnValue(), nSum); |
| 2858 FX_Free(pData); | 2851 FX_Free(pData); |
| 2859 pData = 0; | 2852 pData = 0; |
| 2860 } | 2853 } |
| 2861 } else { | 2854 } else { |
| 2862 FXJSE_Value_SetNull(args.GetReturnValue()); | 2855 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2863 } | 2856 } |
| 2864 } else { | 2857 } else { |
| 2865 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2858 pContext->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"NPV"); |
| 2866 L"NPV"); | |
| 2867 } | 2859 } |
| 2868 } | 2860 } |
| 2869 | 2861 |
| 2870 // static | 2862 // static |
| 2871 void CXFA_FM2JSContext::Pmt(CFXJSE_Value* pThis, | 2863 void CXFA_FM2JSContext::Pmt(CFXJSE_Value* pThis, |
| 2872 const CFX_ByteStringC& szFuncName, | 2864 const CFX_ByteStringC& szFuncName, |
| 2873 CFXJSE_Arguments& args) { | 2865 CFXJSE_Arguments& args) { |
| 2874 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); | 2866 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); |
| 2875 if (args.GetLength() == 3) { | 2867 if (args.GetLength() == 3) { |
| 2876 FX_BOOL bFlags = FALSE; | 2868 FX_BOOL bFlags = FALSE; |
| 2877 FX_FLOAT nPrincipal = 0; | 2869 FX_FLOAT nPrincipal = 0; |
| 2878 FX_FLOAT nRate = 0; | 2870 FX_FLOAT nRate = 0; |
| 2879 FX_FLOAT nPeriods = 0; | 2871 FX_FLOAT nPeriods = 0; |
| 2880 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 2872 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 2881 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | 2873 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
| 2882 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); | 2874 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); |
| 2883 bFlags = | 2875 bFlags = |
| 2884 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || | 2876 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || |
| 2885 ValueIsNull(pThis, argThree.get())); | 2877 ValueIsNull(pThis, argThree.get())); |
| 2886 if (bFlags) { | 2878 if (bFlags) { |
| 2887 FXJSE_Value_SetNull(args.GetReturnValue()); | 2879 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2888 } else { | 2880 } else { |
| 2889 nPrincipal = ValueToFloat(pThis, argOne.get()); | 2881 nPrincipal = ValueToFloat(pThis, argOne.get()); |
| 2890 nRate = ValueToFloat(pThis, argTwo.get()); | 2882 nRate = ValueToFloat(pThis, argTwo.get()); |
| 2891 nPeriods = ValueToFloat(pThis, argThree.get()); | 2883 nPeriods = ValueToFloat(pThis, argThree.get()); |
| 2892 bFlags = ((nPrincipal <= 0) || (nRate <= 0) || (nPeriods <= 0)); | 2884 bFlags = ((nPrincipal <= 0) || (nRate <= 0) || (nPeriods <= 0)); |
| 2893 if (bFlags) { | 2885 if (bFlags) { |
| 2894 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2886 pContext->Throw(XFA_IDS_ARGUMENT_MISMATCH); |
| 2895 } else { | 2887 } else { |
| 2896 FX_FLOAT nSum = 0; | 2888 FX_FLOAT nSum = 0; |
| 2897 FX_FLOAT nTmp = 1 + nRate; | 2889 FX_FLOAT nTmp = 1 + nRate; |
| 2898 nSum = nTmp; | 2890 nSum = nTmp; |
| 2899 for (int32_t i = 0; i < nPeriods - 1; ++i) { | 2891 for (int32_t i = 0; i < nPeriods - 1; ++i) { |
| 2900 nSum *= nTmp; | 2892 nSum *= nTmp; |
| 2901 } | 2893 } |
| 2902 FXJSE_Value_SetFloat(args.GetReturnValue(), | 2894 FXJSE_Value_SetFloat(args.GetReturnValue(), |
| 2903 (nPrincipal * nRate * nSum) / (nSum - 1)); | 2895 (nPrincipal * nRate * nSum) / (nSum - 1)); |
| 2904 } | 2896 } |
| 2905 } | 2897 } |
| 2906 } else { | 2898 } else { |
| 2907 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2899 pContext->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Pmt"); |
| 2908 L"Pmt"); | |
| 2909 } | 2900 } |
| 2910 } | 2901 } |
| 2911 | 2902 |
| 2912 // static | 2903 // static |
| 2913 void CXFA_FM2JSContext::PPmt(CFXJSE_Value* pThis, | 2904 void CXFA_FM2JSContext::PPmt(CFXJSE_Value* pThis, |
| 2914 const CFX_ByteStringC& szFuncName, | 2905 const CFX_ByteStringC& szFuncName, |
| 2915 CFXJSE_Arguments& args) { | 2906 CFXJSE_Arguments& args) { |
| 2916 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); | 2907 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); |
| 2917 if (args.GetLength() == 5) { | 2908 if (args.GetLength() == 5) { |
| 2918 FX_BOOL bFlags = FALSE; | 2909 FX_BOOL bFlags = FALSE; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2935 FXJSE_Value_SetNull(args.GetReturnValue()); | 2926 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2936 } else { | 2927 } else { |
| 2937 nPrincpalAmount = ValueToFloat(pThis, argOne.get()); | 2928 nPrincpalAmount = ValueToFloat(pThis, argOne.get()); |
| 2938 nRate = ValueToFloat(pThis, argTwo.get()); | 2929 nRate = ValueToFloat(pThis, argTwo.get()); |
| 2939 nPayment = ValueToFloat(pThis, argThree.get()); | 2930 nPayment = ValueToFloat(pThis, argThree.get()); |
| 2940 nFirstMonth = ValueToFloat(pThis, argFour.get()); | 2931 nFirstMonth = ValueToFloat(pThis, argFour.get()); |
| 2941 nNumberOfMonths = ValueToFloat(pThis, argFive.get()); | 2932 nNumberOfMonths = ValueToFloat(pThis, argFive.get()); |
| 2942 bFlags = ((nPrincpalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) || | 2933 bFlags = ((nPrincpalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) || |
| 2943 (nFirstMonth < 0) || (nNumberOfMonths < 0)); | 2934 (nFirstMonth < 0) || (nNumberOfMonths < 0)); |
| 2944 if (bFlags) { | 2935 if (bFlags) { |
| 2945 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2936 pContext->Throw(XFA_IDS_ARGUMENT_MISMATCH); |
| 2946 } else { | 2937 } else { |
| 2947 int32_t iEnd = (int32_t)(nFirstMonth + nNumberOfMonths - 1); | 2938 int32_t iEnd = (int32_t)(nFirstMonth + nNumberOfMonths - 1); |
| 2948 FX_FLOAT nSum = 0; | 2939 FX_FLOAT nSum = 0; |
| 2949 FX_FLOAT nRateOfMonth = nRate / 12; | 2940 FX_FLOAT nRateOfMonth = nRate / 12; |
| 2950 int32_t iNums = | 2941 int32_t iNums = |
| 2951 (int32_t)((FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount)) - | 2942 (int32_t)((FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount)) - |
| 2952 FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount - | 2943 FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount - |
| 2953 nRateOfMonth))) / | 2944 nRateOfMonth))) / |
| 2954 FXSYS_log10((FX_FLOAT)(1 + nRateOfMonth))); | 2945 FXSYS_log10((FX_FLOAT)(1 + nRateOfMonth))); |
| 2955 if (iEnd > iNums) { | 2946 if (iEnd > iNums) { |
| 2956 iEnd = iNums; | 2947 iEnd = iNums; |
| 2957 } | 2948 } |
| 2958 if (nPayment < nPrincpalAmount * nRateOfMonth) { | 2949 if (nPayment < nPrincpalAmount * nRateOfMonth) { |
| 2959 bFlags = TRUE; | 2950 bFlags = TRUE; |
| 2960 } | 2951 } |
| 2961 if (!bFlags) { | 2952 if (!bFlags) { |
| 2962 int32_t i = 0; | 2953 int32_t i = 0; |
| 2963 for (i = 0; i < nFirstMonth - 1; ++i) { | 2954 for (i = 0; i < nFirstMonth - 1; ++i) { |
| 2964 nPrincpalAmount -= nPayment - nPrincpalAmount * nRateOfMonth; | 2955 nPrincpalAmount -= nPayment - nPrincpalAmount * nRateOfMonth; |
| 2965 } | 2956 } |
| 2966 FX_FLOAT nTemp = 0; | 2957 FX_FLOAT nTemp = 0; |
| 2967 for (; i < iEnd; ++i) { | 2958 for (; i < iEnd; ++i) { |
| 2968 nTemp = nPayment - nPrincpalAmount * nRateOfMonth; | 2959 nTemp = nPayment - nPrincpalAmount * nRateOfMonth; |
| 2969 nSum += nTemp; | 2960 nSum += nTemp; |
| 2970 nPrincpalAmount -= nTemp; | 2961 nPrincpalAmount -= nTemp; |
| 2971 } | 2962 } |
| 2972 FXJSE_Value_SetFloat(args.GetReturnValue(), nSum); | 2963 FXJSE_Value_SetFloat(args.GetReturnValue(), nSum); |
| 2973 } else { | 2964 } else { |
| 2974 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2965 pContext->Throw(XFA_IDS_ARGUMENT_MISMATCH); |
| 2975 } | 2966 } |
| 2976 } | 2967 } |
| 2977 } | 2968 } |
| 2978 } else { | 2969 } else { |
| 2979 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2970 pContext->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"PPmt"); |
| 2980 L"PPmt"); | |
| 2981 } | 2971 } |
| 2982 } | 2972 } |
| 2983 | 2973 |
| 2984 // static | 2974 // static |
| 2985 void CXFA_FM2JSContext::PV(CFXJSE_Value* pThis, | 2975 void CXFA_FM2JSContext::PV(CFXJSE_Value* pThis, |
| 2986 const CFX_ByteStringC& szFuncName, | 2976 const CFX_ByteStringC& szFuncName, |
| 2987 CFXJSE_Arguments& args) { | 2977 CFXJSE_Arguments& args) { |
| 2988 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); | 2978 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); |
| 2989 if (args.GetLength() == 3) { | 2979 if (args.GetLength() == 3) { |
| 2990 FX_BOOL bFlags = FALSE; | 2980 FX_BOOL bFlags = FALSE; |
| 2991 FX_DOUBLE nAmount = 0; | 2981 FX_DOUBLE nAmount = 0; |
| 2992 FX_DOUBLE nRate = 0; | 2982 FX_DOUBLE nRate = 0; |
| 2993 FX_DOUBLE nPeriod = 0; | 2983 FX_DOUBLE nPeriod = 0; |
| 2994 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 2984 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 2995 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | 2985 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
| 2996 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); | 2986 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); |
| 2997 bFlags = | 2987 bFlags = |
| 2998 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || | 2988 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || |
| 2999 ValueIsNull(pThis, argThree.get())); | 2989 ValueIsNull(pThis, argThree.get())); |
| 3000 if (bFlags) { | 2990 if (bFlags) { |
| 3001 FXJSE_Value_SetNull(args.GetReturnValue()); | 2991 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3002 } else { | 2992 } else { |
| 3003 nAmount = ValueToDouble(pThis, argOne.get()); | 2993 nAmount = ValueToDouble(pThis, argOne.get()); |
| 3004 nRate = ValueToDouble(pThis, argTwo.get()); | 2994 nRate = ValueToDouble(pThis, argTwo.get()); |
| 3005 nPeriod = ValueToDouble(pThis, argThree.get()); | 2995 nPeriod = ValueToDouble(pThis, argThree.get()); |
| 3006 bFlags = ((nAmount <= 0) || (nRate < 0) || (nPeriod <= 0)); | 2996 bFlags = ((nAmount <= 0) || (nRate < 0) || (nPeriod <= 0)); |
| 3007 if (bFlags) { | 2997 if (bFlags) { |
| 3008 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2998 pContext->Throw(XFA_IDS_ARGUMENT_MISMATCH); |
| 3009 } else { | 2999 } else { |
| 3010 FX_DOUBLE nTemp = 1; | 3000 FX_DOUBLE nTemp = 1; |
| 3011 for (int32_t i = 0; i < nPeriod; ++i) { | 3001 for (int32_t i = 0; i < nPeriod; ++i) { |
| 3012 nTemp *= 1 + nRate; | 3002 nTemp *= 1 + nRate; |
| 3013 } | 3003 } |
| 3014 nTemp = 1 / nTemp; | 3004 nTemp = 1 / nTemp; |
| 3015 FXJSE_Value_SetDouble(args.GetReturnValue(), | 3005 FXJSE_Value_SetDouble(args.GetReturnValue(), |
| 3016 nAmount * ((1 - nTemp) / nRate)); | 3006 nAmount * ((1 - nTemp) / nRate)); |
| 3017 } | 3007 } |
| 3018 } | 3008 } |
| 3019 } else { | 3009 } else { |
| 3020 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3010 pContext->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"PV"); |
| 3021 L"PV"); | |
| 3022 } | 3011 } |
| 3023 } | 3012 } |
| 3024 | 3013 |
| 3025 // static | 3014 // static |
| 3026 void CXFA_FM2JSContext::Rate(CFXJSE_Value* pThis, | 3015 void CXFA_FM2JSContext::Rate(CFXJSE_Value* pThis, |
| 3027 const CFX_ByteStringC& szFuncName, | 3016 const CFX_ByteStringC& szFuncName, |
| 3028 CFXJSE_Arguments& args) { | 3017 CFXJSE_Arguments& args) { |
| 3029 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); | 3018 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); |
| 3030 if (args.GetLength() == 3) { | 3019 if (args.GetLength() == 3) { |
| 3031 FX_BOOL bFlags = FALSE; | 3020 FX_BOOL bFlags = FALSE; |
| 3032 FX_FLOAT nFuture = 0; | 3021 FX_FLOAT nFuture = 0; |
| 3033 FX_FLOAT nPresent = 0; | 3022 FX_FLOAT nPresent = 0; |
| 3034 FX_FLOAT nTotalNumber = 0; | 3023 FX_FLOAT nTotalNumber = 0; |
| 3035 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 3024 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 3036 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | 3025 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
| 3037 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); | 3026 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); |
| 3038 bFlags = | 3027 bFlags = |
| 3039 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || | 3028 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || |
| 3040 ValueIsNull(pThis, argThree.get())); | 3029 ValueIsNull(pThis, argThree.get())); |
| 3041 if (bFlags) { | 3030 if (bFlags) { |
| 3042 FXJSE_Value_SetNull(args.GetReturnValue()); | 3031 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3043 } else { | 3032 } else { |
| 3044 nFuture = ValueToFloat(pThis, argOne.get()); | 3033 nFuture = ValueToFloat(pThis, argOne.get()); |
| 3045 nPresent = ValueToFloat(pThis, argTwo.get()); | 3034 nPresent = ValueToFloat(pThis, argTwo.get()); |
| 3046 nTotalNumber = ValueToFloat(pThis, argThree.get()); | 3035 nTotalNumber = ValueToFloat(pThis, argThree.get()); |
| 3047 bFlags = ((nFuture <= 0) || (nPresent < 0) || (nTotalNumber <= 0)); | 3036 bFlags = ((nFuture <= 0) || (nPresent < 0) || (nTotalNumber <= 0)); |
| 3048 if (bFlags) { | 3037 if (bFlags) { |
| 3049 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 3038 pContext->Throw(XFA_IDS_ARGUMENT_MISMATCH); |
| 3050 } else { | 3039 } else { |
| 3051 FXJSE_Value_SetFloat(args.GetReturnValue(), | 3040 FXJSE_Value_SetFloat(args.GetReturnValue(), |
| 3052 (FXSYS_pow((FX_FLOAT)(nFuture / nPresent), | 3041 (FXSYS_pow((FX_FLOAT)(nFuture / nPresent), |
| 3053 (FX_FLOAT)(1 / nTotalNumber)) - | 3042 (FX_FLOAT)(1 / nTotalNumber)) - |
| 3054 1)); | 3043 1)); |
| 3055 } | 3044 } |
| 3056 } | 3045 } |
| 3057 } else { | 3046 } else { |
| 3058 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3047 pContext->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Rate"); |
| 3059 L"Rate"); | |
| 3060 } | 3048 } |
| 3061 } | 3049 } |
| 3062 | 3050 |
| 3063 // static | 3051 // static |
| 3064 void CXFA_FM2JSContext::Term(CFXJSE_Value* pThis, | 3052 void CXFA_FM2JSContext::Term(CFXJSE_Value* pThis, |
| 3065 const CFX_ByteStringC& szFuncName, | 3053 const CFX_ByteStringC& szFuncName, |
| 3066 CFXJSE_Arguments& args) { | 3054 CFXJSE_Arguments& args) { |
| 3067 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); | 3055 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); |
| 3068 if (args.GetLength() == 3) { | 3056 if (args.GetLength() == 3) { |
| 3069 FX_BOOL bFlags = FALSE; | 3057 FX_BOOL bFlags = FALSE; |
| 3070 FX_FLOAT nMount = 0; | 3058 FX_FLOAT nMount = 0; |
| 3071 FX_FLOAT nRate = 0; | 3059 FX_FLOAT nRate = 0; |
| 3072 FX_FLOAT nFuture = 0; | 3060 FX_FLOAT nFuture = 0; |
| 3073 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 3061 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 3074 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | 3062 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
| 3075 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); | 3063 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); |
| 3076 bFlags = | 3064 bFlags = |
| 3077 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || | 3065 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || |
| 3078 ValueIsNull(pThis, argThree.get())); | 3066 ValueIsNull(pThis, argThree.get())); |
| 3079 if (bFlags) { | 3067 if (bFlags) { |
| 3080 FXJSE_Value_SetNull(args.GetReturnValue()); | 3068 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3081 } else { | 3069 } else { |
| 3082 nMount = ValueToFloat(pThis, argOne.get()); | 3070 nMount = ValueToFloat(pThis, argOne.get()); |
| 3083 nRate = ValueToFloat(pThis, argTwo.get()); | 3071 nRate = ValueToFloat(pThis, argTwo.get()); |
| 3084 nFuture = ValueToFloat(pThis, argThree.get()); | 3072 nFuture = ValueToFloat(pThis, argThree.get()); |
| 3085 bFlags = ((nMount <= 0) || (nRate <= 0) || (nFuture <= 0)); | 3073 bFlags = ((nMount <= 0) || (nRate <= 0) || (nFuture <= 0)); |
| 3086 if (bFlags) { | 3074 if (bFlags) { |
| 3087 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 3075 pContext->Throw(XFA_IDS_ARGUMENT_MISMATCH); |
| 3088 } else { | 3076 } else { |
| 3089 FXJSE_Value_SetFloat( | 3077 FXJSE_Value_SetFloat( |
| 3090 args.GetReturnValue(), | 3078 args.GetReturnValue(), |
| 3091 (FXSYS_log((FX_FLOAT)(nFuture / nMount * nRate) + 1) / | 3079 (FXSYS_log((FX_FLOAT)(nFuture / nMount * nRate) + 1) / |
| 3092 FXSYS_log((FX_FLOAT)(1 + nRate)))); | 3080 FXSYS_log((FX_FLOAT)(1 + nRate)))); |
| 3093 } | 3081 } |
| 3094 } | 3082 } |
| 3095 } else { | 3083 } else { |
| 3096 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3084 pContext->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Term"); |
| 3097 L"Term"); | |
| 3098 } | 3085 } |
| 3099 } | 3086 } |
| 3100 | 3087 |
| 3101 // static | 3088 // static |
| 3102 void CXFA_FM2JSContext::Choose(CFXJSE_Value* pThis, | 3089 void CXFA_FM2JSContext::Choose(CFXJSE_Value* pThis, |
| 3103 const CFX_ByteStringC& szFuncName, | 3090 const CFX_ByteStringC& szFuncName, |
| 3104 CFXJSE_Arguments& args) { | 3091 CFXJSE_Arguments& args) { |
| 3105 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); | 3092 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); |
| 3106 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 3093 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 3107 int32_t argc = args.GetLength(); | 3094 int32_t argc = args.GetLength(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3171 bFound = TRUE; | 3158 bFound = TRUE; |
| 3172 } | 3159 } |
| 3173 } | 3160 } |
| 3174 iArgIndex++; | 3161 iArgIndex++; |
| 3175 } | 3162 } |
| 3176 if (!bFound) { | 3163 if (!bFound) { |
| 3177 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 3164 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
| 3178 } | 3165 } |
| 3179 } | 3166 } |
| 3180 } else { | 3167 } else { |
| 3181 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3168 pContext->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Choose"); |
| 3182 L"Choose"); | |
| 3183 } | 3169 } |
| 3184 } | 3170 } |
| 3185 | 3171 |
| 3186 // static | 3172 // static |
| 3187 void CXFA_FM2JSContext::Exists(CFXJSE_Value* pThis, | 3173 void CXFA_FM2JSContext::Exists(CFXJSE_Value* pThis, |
| 3188 const CFX_ByteStringC& szFuncName, | 3174 const CFX_ByteStringC& szFuncName, |
| 3189 CFXJSE_Arguments& args) { | 3175 CFXJSE_Arguments& args) { |
| 3190 if (args.GetLength() == 1) { | 3176 if (args.GetLength() == 1) { |
| 3191 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 3177 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 3192 FXJSE_Value_SetInteger(args.GetReturnValue(), | 3178 FXJSE_Value_SetInteger(args.GetReturnValue(), |
| 3193 FXJSE_Value_IsObject(argOne.get())); | 3179 FXJSE_Value_IsObject(argOne.get())); |
| 3194 } else { | 3180 } else { |
| 3195 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 3181 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3196 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Exists"); | 3182 L"Exists"); |
| 3197 } | 3183 } |
| 3198 } | 3184 } |
| 3199 | 3185 |
| 3200 // static | 3186 // static |
| 3201 void CXFA_FM2JSContext::HasValue(CFXJSE_Value* pThis, | 3187 void CXFA_FM2JSContext::HasValue(CFXJSE_Value* pThis, |
| 3202 const CFX_ByteStringC& szFuncName, | 3188 const CFX_ByteStringC& szFuncName, |
| 3203 CFXJSE_Arguments& args) { | 3189 CFXJSE_Arguments& args) { |
| 3204 if (args.GetLength() == 1) { | 3190 if (args.GetLength() == 1) { |
| 3205 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 3191 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 3206 if (FXJSE_Value_IsUTF8String(argOne.get())) { | 3192 if (FXJSE_Value_IsUTF8String(argOne.get())) { |
| 3207 CFX_ByteString valueStr; | 3193 CFX_ByteString valueStr; |
| 3208 FXJSE_Value_ToUTF8String(argOne.get(), valueStr); | 3194 FXJSE_Value_ToUTF8String(argOne.get(), valueStr); |
| 3209 valueStr.TrimLeft(); | 3195 valueStr.TrimLeft(); |
| 3210 FXJSE_Value_SetInteger(args.GetReturnValue(), (!valueStr.IsEmpty())); | 3196 FXJSE_Value_SetInteger(args.GetReturnValue(), (!valueStr.IsEmpty())); |
| 3211 } else if (FXJSE_Value_IsNumber(argOne.get()) || | 3197 } else if (FXJSE_Value_IsNumber(argOne.get()) || |
| 3212 FXJSE_Value_IsBoolean(argOne.get())) { | 3198 FXJSE_Value_IsBoolean(argOne.get())) { |
| 3213 FXJSE_Value_SetInteger(args.GetReturnValue(), TRUE); | 3199 FXJSE_Value_SetInteger(args.GetReturnValue(), TRUE); |
| 3214 } else { | 3200 } else { |
| 3215 FXJSE_Value_SetInteger(args.GetReturnValue(), FALSE); | 3201 FXJSE_Value_SetInteger(args.GetReturnValue(), FALSE); |
| 3216 } | 3202 } |
| 3217 } else { | 3203 } else { |
| 3218 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 3204 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3219 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"HasValue"); | 3205 L"HasValue"); |
| 3220 } | 3206 } |
| 3221 } | 3207 } |
| 3222 | 3208 |
| 3223 // static | 3209 // static |
| 3224 void CXFA_FM2JSContext::Oneof(CFXJSE_Value* pThis, | 3210 void CXFA_FM2JSContext::Oneof(CFXJSE_Value* pThis, |
| 3225 const CFX_ByteStringC& szFuncName, | 3211 const CFX_ByteStringC& szFuncName, |
| 3226 CFXJSE_Arguments& args) { | 3212 CFXJSE_Arguments& args) { |
| 3227 if (args.GetLength() > 1) { | 3213 if (args.GetLength() > 1) { |
| 3228 FX_BOOL bFlags = FALSE; | 3214 FX_BOOL bFlags = FALSE; |
| 3229 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 3215 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 3230 CFXJSE_Value** parametersValue = nullptr; | 3216 CFXJSE_Value** parametersValue = nullptr; |
| 3231 int32_t iCount = 0; | 3217 int32_t iCount = 0; |
| 3232 unfoldArgs(pThis, args, parametersValue, iCount, 1); | 3218 unfoldArgs(pThis, args, parametersValue, iCount, 1); |
| 3233 for (int32_t i = 0; i < iCount; i++) { | 3219 for (int32_t i = 0; i < iCount; i++) { |
| 3234 if (simpleValueCompare(pThis, argOne.get(), parametersValue[i])) { | 3220 if (simpleValueCompare(pThis, argOne.get(), parametersValue[i])) { |
| 3235 bFlags = TRUE; | 3221 bFlags = TRUE; |
| 3236 break; | 3222 break; |
| 3237 } | 3223 } |
| 3238 } | 3224 } |
| 3239 FXJSE_Value_SetInteger(args.GetReturnValue(), bFlags); | 3225 FXJSE_Value_SetInteger(args.GetReturnValue(), bFlags); |
| 3240 for (int32_t i = 0; i < iCount; i++) { | 3226 for (int32_t i = 0; i < iCount; i++) { |
| 3241 delete parametersValue[i]; | 3227 delete parametersValue[i]; |
| 3242 } | 3228 } |
| 3243 FX_Free(parametersValue); | 3229 FX_Free(parametersValue); |
| 3244 } else { | 3230 } else { |
| 3245 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 3231 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3246 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Oneof"); | 3232 L"Oneof"); |
| 3247 } | 3233 } |
| 3248 } | 3234 } |
| 3249 | 3235 |
| 3250 // static | 3236 // static |
| 3251 void CXFA_FM2JSContext::Within(CFXJSE_Value* pThis, | 3237 void CXFA_FM2JSContext::Within(CFXJSE_Value* pThis, |
| 3252 const CFX_ByteStringC& szFuncName, | 3238 const CFX_ByteStringC& szFuncName, |
| 3253 CFXJSE_Arguments& args) { | 3239 CFXJSE_Arguments& args) { |
| 3254 if (args.GetLength() == 3) { | 3240 if (args.GetLength() == 3) { |
| 3255 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 3241 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 3256 if (FXJSE_Value_IsNull(argOne.get())) { | 3242 if (FXJSE_Value_IsNull(argOne.get())) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3272 ValueToUTF8String(argOne.get(), oneString); | 3258 ValueToUTF8String(argOne.get(), oneString); |
| 3273 ValueToUTF8String(argLow.get(), lowString); | 3259 ValueToUTF8String(argLow.get(), lowString); |
| 3274 ValueToUTF8String(argHeight.get(), heightString); | 3260 ValueToUTF8String(argHeight.get(), heightString); |
| 3275 FXJSE_Value_SetInteger( | 3261 FXJSE_Value_SetInteger( |
| 3276 args.GetReturnValue(), | 3262 args.GetReturnValue(), |
| 3277 ((oneString.Compare(lowString.AsStringC()) >= 0) && | 3263 ((oneString.Compare(lowString.AsStringC()) >= 0) && |
| 3278 (oneString.Compare(heightString.AsStringC()) <= 0))); | 3264 (oneString.Compare(heightString.AsStringC()) <= 0))); |
| 3279 } | 3265 } |
| 3280 } | 3266 } |
| 3281 } else { | 3267 } else { |
| 3282 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 3268 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3283 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Within"); | 3269 L"Within"); |
| 3284 } | 3270 } |
| 3285 } | 3271 } |
| 3286 | 3272 |
| 3287 // static | 3273 // static |
| 3288 void CXFA_FM2JSContext::If(CFXJSE_Value* pThis, | 3274 void CXFA_FM2JSContext::If(CFXJSE_Value* pThis, |
| 3289 const CFX_ByteStringC& szFuncName, | 3275 const CFX_ByteStringC& szFuncName, |
| 3290 CFXJSE_Arguments& args) { | 3276 CFXJSE_Arguments& args) { |
| 3291 if (args.GetLength() == 3) { | 3277 if (args.GetLength() == 3) { |
| 3292 std::unique_ptr<CFXJSE_Value> argCondition = GetSimpleValue(pThis, args, 0); | 3278 std::unique_ptr<CFXJSE_Value> argCondition = GetSimpleValue(pThis, args, 0); |
| 3293 std::unique_ptr<CFXJSE_Value> argFirstValue = | 3279 std::unique_ptr<CFXJSE_Value> argFirstValue = |
| 3294 GetSimpleValue(pThis, args, 1); | 3280 GetSimpleValue(pThis, args, 1); |
| 3295 std::unique_ptr<CFXJSE_Value> argSecondValue = | 3281 std::unique_ptr<CFXJSE_Value> argSecondValue = |
| 3296 GetSimpleValue(pThis, args, 2); | 3282 GetSimpleValue(pThis, args, 2); |
| 3297 FX_BOOL bCondition = FXJSE_Value_ToBoolean(argCondition.get()); | 3283 FX_BOOL bCondition = FXJSE_Value_ToBoolean(argCondition.get()); |
| 3298 FXJSE_Value_Set(args.GetReturnValue(), | 3284 FXJSE_Value_Set(args.GetReturnValue(), |
| 3299 bCondition ? argFirstValue.get() : argSecondValue.get()); | 3285 bCondition ? argFirstValue.get() : argSecondValue.get()); |
| 3300 } else { | 3286 } else { |
| 3301 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 3287 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3302 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"If"); | 3288 L"If"); |
| 3303 } | 3289 } |
| 3304 } | 3290 } |
| 3305 | 3291 |
| 3306 // static | 3292 // static |
| 3307 void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis, | 3293 void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis, |
| 3308 const CFX_ByteStringC& szFuncName, | 3294 const CFX_ByteStringC& szFuncName, |
| 3309 CFXJSE_Arguments& args) { | 3295 CFXJSE_Arguments& args) { |
| 3310 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); | 3296 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); |
| 3311 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 3297 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 3312 if (args.GetLength() == 1) { | 3298 if (args.GetLength() == 1) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3327 std::unique_ptr<CFXJSE_Value> returnValue(new CFXJSE_Value(pIsolate)); | 3313 std::unique_ptr<CFXJSE_Value> returnValue(new CFXJSE_Value(pIsolate)); |
| 3328 javaScript = wsJavaScriptBuf.AsStringC(); | 3314 javaScript = wsJavaScriptBuf.AsStringC(); |
| 3329 FXJSE_ExecuteScript( | 3315 FXJSE_ExecuteScript( |
| 3330 pTempContext, | 3316 pTempContext, |
| 3331 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(), | 3317 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(), |
| 3332 returnValue.get()); | 3318 returnValue.get()); |
| 3333 FXJSE_Value_Set(args.GetReturnValue(), returnValue.get()); | 3319 FXJSE_Value_Set(args.GetReturnValue(), returnValue.get()); |
| 3334 FXJSE_Context_Release(pTempContext); | 3320 FXJSE_Context_Release(pTempContext); |
| 3335 } | 3321 } |
| 3336 } else { | 3322 } else { |
| 3337 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3323 pContext->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Eval"); |
| 3338 L"Eval"); | |
| 3339 } | 3324 } |
| 3340 } | 3325 } |
| 3341 | 3326 |
| 3342 // static | 3327 // static |
| 3343 void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis, | 3328 void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis, |
| 3344 const CFX_ByteStringC& szFuncName, | 3329 const CFX_ByteStringC& szFuncName, |
| 3345 CFXJSE_Arguments& args) { | 3330 CFXJSE_Arguments& args) { |
| 3346 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); | 3331 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); |
| 3347 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 3332 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 3348 if (args.GetLength() == 1) { | 3333 if (args.GetLength() == 1) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3363 #ifndef NDEBUG | 3348 #ifndef NDEBUG |
| 3364 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 3349 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 3365 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get()); | 3350 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get()); |
| 3366 ASSERT(FXJSE_Value_ToInteger(lengthValue.get()) >= 3); | 3351 ASSERT(FXJSE_Value_ToInteger(lengthValue.get()) >= 3); |
| 3367 #endif | 3352 #endif |
| 3368 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 3353 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 3369 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 3354 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 3370 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 1, propertyValue.get()); | 3355 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 1, propertyValue.get()); |
| 3371 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, jsObjectValue.get()); | 3356 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, jsObjectValue.get()); |
| 3372 if (FXJSE_Value_IsNull(jsObjectValue.get())) { | 3357 if (FXJSE_Value_IsNull(jsObjectValue.get())) { |
| 3373 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 3358 pContext->Throw(XFA_IDS_ARGUMENT_MISMATCH); |
| 3374 } else if (FXJSE_Value_IsNull(propertyValue.get()) && | 3359 } else if (FXJSE_Value_IsNull(propertyValue.get()) && |
| 3375 (!FXJSE_Value_IsNull(jsObjectValue.get()))) { | 3360 (!FXJSE_Value_IsNull(jsObjectValue.get()))) { |
| 3376 CFXJSE_Value* rgValues[3]; | 3361 CFXJSE_Value* rgValues[3]; |
| 3377 for (int32_t i = 0; i < 3; i++) | 3362 for (int32_t i = 0; i < 3; i++) |
| 3378 rgValues[i] = new CFXJSE_Value(pIsolate); | 3363 rgValues[i] = new CFXJSE_Value(pIsolate); |
| 3379 | 3364 |
| 3380 FXJSE_Value_SetInteger(rgValues[0], 3); | 3365 FXJSE_Value_SetInteger(rgValues[0], 3); |
| 3381 FXJSE_Value_SetNull(rgValues[1]); | 3366 FXJSE_Value_SetNull(rgValues[1]); |
| 3382 FXJSE_Value_Set(rgValues[2], jsObjectValue.get()); | 3367 FXJSE_Value_Set(rgValues[2], jsObjectValue.get()); |
| 3383 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); | 3368 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); |
| 3384 for (int32_t i = 0; i < 3; i++) | 3369 for (int32_t i = 0; i < 3; i++) |
| 3385 delete rgValues[i]; | 3370 delete rgValues[i]; |
| 3386 | 3371 |
| 3387 } else { | 3372 } else { |
| 3388 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 3373 pContext->Throw(XFA_IDS_ARGUMENT_MISMATCH); |
| 3389 } | 3374 } |
| 3390 } else if (FXJSE_Value_IsObject(argOne.get())) { | 3375 } else if (FXJSE_Value_IsObject(argOne.get())) { |
| 3391 CFXJSE_Value* rgValues[3]; | 3376 CFXJSE_Value* rgValues[3]; |
| 3392 for (int32_t i = 0; i < 3; i++) | 3377 for (int32_t i = 0; i < 3; i++) |
| 3393 rgValues[i] = new CFXJSE_Value(pIsolate); | 3378 rgValues[i] = new CFXJSE_Value(pIsolate); |
| 3394 | 3379 |
| 3395 FXJSE_Value_SetInteger(rgValues[0], 3); | 3380 FXJSE_Value_SetInteger(rgValues[0], 3); |
| 3396 FXJSE_Value_SetNull(rgValues[1]); | 3381 FXJSE_Value_SetNull(rgValues[1]); |
| 3397 FXJSE_Value_Set(rgValues[2], argOne.get()); | 3382 FXJSE_Value_Set(rgValues[2], argOne.get()); |
| 3398 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); | 3383 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); |
| 3399 | 3384 |
| 3400 for (int32_t i = 0; i < 3; i++) | 3385 for (int32_t i = 0; i < 3; i++) |
| 3401 delete rgValues[i]; | 3386 delete rgValues[i]; |
| 3402 } else if (FXJSE_Value_IsBoolean(argOne.get()) || | 3387 } else if (FXJSE_Value_IsBoolean(argOne.get()) || |
| 3403 FXJSE_Value_IsUTF8String(argOne.get()) || | 3388 FXJSE_Value_IsUTF8String(argOne.get()) || |
| 3404 FXJSE_Value_IsNumber(argOne.get())) { | 3389 FXJSE_Value_IsNumber(argOne.get())) { |
| 3405 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); | 3390 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); |
| 3406 } else { | 3391 } else { |
| 3407 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 3392 pContext->Throw(XFA_IDS_ARGUMENT_MISMATCH); |
| 3408 } | 3393 } |
| 3409 } else { | 3394 } else { |
| 3410 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3395 pContext->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Ref"); |
| 3411 L"Ref"); | |
| 3412 } | 3396 } |
| 3413 } | 3397 } |
| 3414 | 3398 |
| 3415 // static | 3399 // static |
| 3416 void CXFA_FM2JSContext::UnitType(CFXJSE_Value* pThis, | 3400 void CXFA_FM2JSContext::UnitType(CFXJSE_Value* pThis, |
| 3417 const CFX_ByteStringC& szFuncName, | 3401 const CFX_ByteStringC& szFuncName, |
| 3418 CFXJSE_Arguments& args) { | 3402 CFXJSE_Arguments& args) { |
| 3419 if (args.GetLength() == 1) { | 3403 if (args.GetLength() == 1) { |
| 3420 std::unique_ptr<CFXJSE_Value> unitspanValue = | 3404 std::unique_ptr<CFXJSE_Value> unitspanValue = |
| 3421 GetSimpleValue(pThis, args, 0); | 3405 GetSimpleValue(pThis, args, 0); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3516 break; | 3500 break; |
| 3517 case VALUETYPE_ISMP: | 3501 case VALUETYPE_ISMP: |
| 3518 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "mp"); | 3502 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "mp"); |
| 3519 break; | 3503 break; |
| 3520 default: | 3504 default: |
| 3521 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "in"); | 3505 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "in"); |
| 3522 break; | 3506 break; |
| 3523 } | 3507 } |
| 3524 } | 3508 } |
| 3525 } else { | 3509 } else { |
| 3526 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 3510 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3527 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"UnitType"); | 3511 L"UnitType"); |
| 3528 } | 3512 } |
| 3529 } | 3513 } |
| 3530 | 3514 |
| 3531 // static | 3515 // static |
| 3532 void CXFA_FM2JSContext::UnitValue(CFXJSE_Value* pThis, | 3516 void CXFA_FM2JSContext::UnitValue(CFXJSE_Value* pThis, |
| 3533 const CFX_ByteStringC& szFuncName, | 3517 const CFX_ByteStringC& szFuncName, |
| 3534 CFXJSE_Arguments& args) { | 3518 CFXJSE_Arguments& args) { |
| 3535 int32_t argc = args.GetLength(); | 3519 int32_t argc = args.GetLength(); |
| 3536 if ((argc == 1) || (argc == 2)) { | 3520 if ((argc == 1) || (argc == 2)) { |
| 3537 std::unique_ptr<CFXJSE_Value> unitspanValue = | 3521 std::unique_ptr<CFXJSE_Value> unitspanValue = |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3672 } else { | 3656 } else { |
| 3673 dResult = dFirstNumber / 72000; | 3657 dResult = dFirstNumber / 72000; |
| 3674 } | 3658 } |
| 3675 } | 3659 } |
| 3676 FXJSE_Value_SetDouble(args.GetReturnValue(), dResult); | 3660 FXJSE_Value_SetDouble(args.GetReturnValue(), dResult); |
| 3677 } else { | 3661 } else { |
| 3678 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 3662 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
| 3679 } | 3663 } |
| 3680 } | 3664 } |
| 3681 } else { | 3665 } else { |
| 3682 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 3666 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3683 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"UnitValue"); | 3667 L"UnitValue"); |
| 3684 } | 3668 } |
| 3685 } | 3669 } |
| 3686 | 3670 |
| 3687 // static | 3671 // static |
| 3688 void CXFA_FM2JSContext::At(CFXJSE_Value* pThis, | 3672 void CXFA_FM2JSContext::At(CFXJSE_Value* pThis, |
| 3689 const CFX_ByteStringC& szFuncName, | 3673 const CFX_ByteStringC& szFuncName, |
| 3690 CFXJSE_Arguments& args) { | 3674 CFXJSE_Arguments& args) { |
| 3691 if (args.GetLength() == 2) { | 3675 if (args.GetLength() == 2) { |
| 3692 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 3676 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 3693 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | 3677 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
| 3694 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get())) { | 3678 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get())) { |
| 3695 FXJSE_Value_SetNull(args.GetReturnValue()); | 3679 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3696 } else { | 3680 } else { |
| 3697 CFX_ByteString stringTwo; | 3681 CFX_ByteString stringTwo; |
| 3698 ValueToUTF8String(argTwo.get(), stringTwo); | 3682 ValueToUTF8String(argTwo.get(), stringTwo); |
| 3699 if (stringTwo.IsEmpty()) { | 3683 if (stringTwo.IsEmpty()) { |
| 3700 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); | 3684 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); |
| 3701 } else { | 3685 } else { |
| 3702 CFX_ByteString stringOne; | 3686 CFX_ByteString stringOne; |
| 3703 ValueToUTF8String(argOne.get(), stringOne); | 3687 ValueToUTF8String(argOne.get(), stringOne); |
| 3704 FX_STRSIZE iPosition = stringOne.Find(stringTwo.AsStringC()); | 3688 FX_STRSIZE iPosition = stringOne.Find(stringTwo.AsStringC()); |
| 3705 FXJSE_Value_SetInteger(args.GetReturnValue(), iPosition + 1); | 3689 FXJSE_Value_SetInteger(args.GetReturnValue(), iPosition + 1); |
| 3706 } | 3690 } |
| 3707 } | 3691 } |
| 3708 } else { | 3692 } else { |
| 3709 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 3693 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3710 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"At"); | 3694 L"At"); |
| 3711 } | 3695 } |
| 3712 } | 3696 } |
| 3713 | 3697 |
| 3714 // static | 3698 // static |
| 3715 void CXFA_FM2JSContext::Concat(CFXJSE_Value* pThis, | 3699 void CXFA_FM2JSContext::Concat(CFXJSE_Value* pThis, |
| 3716 const CFX_ByteStringC& szFuncName, | 3700 const CFX_ByteStringC& szFuncName, |
| 3717 CFXJSE_Arguments& args) { | 3701 CFXJSE_Arguments& args) { |
| 3718 int32_t argc = args.GetLength(); | 3702 int32_t argc = args.GetLength(); |
| 3719 if (argc >= 1) { | 3703 if (argc >= 1) { |
| 3720 CFX_ByteString resultString; | 3704 CFX_ByteString resultString; |
| 3721 FX_BOOL bAllNull = TRUE; | 3705 FX_BOOL bAllNull = TRUE; |
| 3722 | 3706 |
| 3723 for (int32_t i = 0; i < argc; i++) { | 3707 for (int32_t i = 0; i < argc; i++) { |
| 3724 std::unique_ptr<CFXJSE_Value> value = GetSimpleValue(pThis, args, i); | 3708 std::unique_ptr<CFXJSE_Value> value = GetSimpleValue(pThis, args, i); |
| 3725 if (!ValueIsNull(pThis, value.get())) { | 3709 if (!ValueIsNull(pThis, value.get())) { |
| 3726 CFX_ByteString valueStr; | 3710 CFX_ByteString valueStr; |
| 3727 ValueToUTF8String(value.get(), valueStr); | 3711 ValueToUTF8String(value.get(), valueStr); |
| 3728 resultString += valueStr; | 3712 resultString += valueStr; |
| 3729 bAllNull = FALSE; | 3713 bAllNull = FALSE; |
| 3730 } | 3714 } |
| 3731 } | 3715 } |
| 3732 | 3716 |
| 3733 if (bAllNull) { | 3717 if (bAllNull) { |
| 3734 FXJSE_Value_SetNull(args.GetReturnValue()); | 3718 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3735 } else { | 3719 } else { |
| 3736 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 3720 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 3737 resultString.AsStringC()); | 3721 resultString.AsStringC()); |
| 3738 } | 3722 } |
| 3739 } else { | 3723 } else { |
| 3740 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 3724 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3741 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Concat"); | 3725 L"Concat"); |
| 3742 } | 3726 } |
| 3743 } | 3727 } |
| 3744 | 3728 |
| 3745 // static | 3729 // static |
| 3746 void CXFA_FM2JSContext::Decode(CFXJSE_Value* pThis, | 3730 void CXFA_FM2JSContext::Decode(CFXJSE_Value* pThis, |
| 3747 const CFX_ByteStringC& szFuncName, | 3731 const CFX_ByteStringC& szFuncName, |
| 3748 CFXJSE_Arguments& args) { | 3732 CFXJSE_Arguments& args) { |
| 3749 int32_t argc = args.GetLength(); | 3733 int32_t argc = args.GetLength(); |
| 3750 if (argc == 1) { | 3734 if (argc == 1) { |
| 3751 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 3735 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3772 if (identifyString.EqualNoCase("html")) { | 3756 if (identifyString.EqualNoCase("html")) { |
| 3773 DecodeHTML(toDecodeString.AsStringC(), resultBuf); | 3757 DecodeHTML(toDecodeString.AsStringC(), resultBuf); |
| 3774 } else if (identifyString.EqualNoCase("xml")) { | 3758 } else if (identifyString.EqualNoCase("xml")) { |
| 3775 DecodeXML(toDecodeString.AsStringC(), resultBuf); | 3759 DecodeXML(toDecodeString.AsStringC(), resultBuf); |
| 3776 } else { | 3760 } else { |
| 3777 DecodeURL(toDecodeString.AsStringC(), resultBuf); | 3761 DecodeURL(toDecodeString.AsStringC(), resultBuf); |
| 3778 } | 3762 } |
| 3779 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); | 3763 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); |
| 3780 } | 3764 } |
| 3781 } else { | 3765 } else { |
| 3782 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 3766 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3783 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Decode"); | 3767 L"Decode"); |
| 3784 } | 3768 } |
| 3785 } | 3769 } |
| 3786 | 3770 |
| 3787 // static | 3771 // static |
| 3788 void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString, | 3772 void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString, |
| 3789 CFX_ByteTextBuf& szResultString) { | 3773 CFX_ByteTextBuf& szResultString) { |
| 3790 CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString); | 3774 CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString); |
| 3791 const FX_WCHAR* pData = wsURLString.c_str(); | 3775 const FX_WCHAR* pData = wsURLString.c_str(); |
| 3792 int32_t iLen = wsURLString.GetLength(); | 3776 int32_t iLen = wsURLString.GetLength(); |
| 3793 int32_t i = 0; | 3777 int32_t i = 0; |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4046 if (identifyString.EqualNoCase("html")) { | 4030 if (identifyString.EqualNoCase("html")) { |
| 4047 EncodeHTML(toEncodeString.AsStringC(), resultBuf); | 4031 EncodeHTML(toEncodeString.AsStringC(), resultBuf); |
| 4048 } else if (identifyString.EqualNoCase("xml")) { | 4032 } else if (identifyString.EqualNoCase("xml")) { |
| 4049 EncodeXML(toEncodeString.AsStringC(), resultBuf); | 4033 EncodeXML(toEncodeString.AsStringC(), resultBuf); |
| 4050 } else { | 4034 } else { |
| 4051 EncodeURL(toEncodeString.AsStringC(), resultBuf); | 4035 EncodeURL(toEncodeString.AsStringC(), resultBuf); |
| 4052 } | 4036 } |
| 4053 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); | 4037 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); |
| 4054 } | 4038 } |
| 4055 } else { | 4039 } else { |
| 4056 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 4040 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4057 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Encode"); | 4041 L"Encode"); |
| 4058 } | 4042 } |
| 4059 } | 4043 } |
| 4060 | 4044 |
| 4061 // static | 4045 // static |
| 4062 void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString, | 4046 void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString, |
| 4063 CFX_ByteTextBuf& szResultBuf) { | 4047 CFX_ByteTextBuf& szResultBuf) { |
| 4064 CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString); | 4048 CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString); |
| 4065 CFX_WideTextBuf wsResultBuf; | 4049 CFX_WideTextBuf wsResultBuf; |
| 4066 FX_WCHAR ch = 0; | 4050 FX_WCHAR ch = 0; |
| 4067 int32_t iLength = wsURLString.GetLength(); | 4051 int32_t iLength = wsURLString.GetLength(); |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4422 CFX_WideString wsRet; | 4406 CFX_WideString wsRet; |
| 4423 if (localeValue.FormatPatterns(wsRet, wsPattern, pLocale, | 4407 if (localeValue.FormatPatterns(wsRet, wsPattern, pLocale, |
| 4424 XFA_VALUEPICTURE_Display)) { | 4408 XFA_VALUEPICTURE_Display)) { |
| 4425 FXJSE_Value_SetUTF8String( | 4409 FXJSE_Value_SetUTF8String( |
| 4426 args.GetReturnValue(), | 4410 args.GetReturnValue(), |
| 4427 FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()).AsStringC()); | 4411 FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()).AsStringC()); |
| 4428 } else { | 4412 } else { |
| 4429 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 4413 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
| 4430 } | 4414 } |
| 4431 } else { | 4415 } else { |
| 4432 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4416 pContext->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Format"); |
| 4433 L"Format"); | |
| 4434 } | 4417 } |
| 4435 } | 4418 } |
| 4436 | 4419 |
| 4437 // static | 4420 // static |
| 4438 void CXFA_FM2JSContext::Left(CFXJSE_Value* pThis, | 4421 void CXFA_FM2JSContext::Left(CFXJSE_Value* pThis, |
| 4439 const CFX_ByteStringC& szFuncName, | 4422 const CFX_ByteStringC& szFuncName, |
| 4440 CFXJSE_Arguments& args) { | 4423 CFXJSE_Arguments& args) { |
| 4441 if (args.GetLength() == 2) { | 4424 if (args.GetLength() == 2) { |
| 4442 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4425 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 4443 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | 4426 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
| 4444 FX_BOOL argIsNull = FALSE; | 4427 FX_BOOL argIsNull = FALSE; |
| 4445 if ((ValueIsNull(pThis, argOne.get())) || | 4428 if ((ValueIsNull(pThis, argOne.get())) || |
| 4446 (ValueIsNull(pThis, argTwo.get()))) { | 4429 (ValueIsNull(pThis, argTwo.get()))) { |
| 4447 argIsNull = TRUE; | 4430 argIsNull = TRUE; |
| 4448 } | 4431 } |
| 4449 if (argIsNull) { | 4432 if (argIsNull) { |
| 4450 FXJSE_Value_SetNull(args.GetReturnValue()); | 4433 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4451 } else { | 4434 } else { |
| 4452 CFX_ByteString sourceString; | 4435 CFX_ByteString sourceString; |
| 4453 ValueToUTF8String(argOne.get(), sourceString); | 4436 ValueToUTF8String(argOne.get(), sourceString); |
| 4454 int32_t count = ValueToInteger(pThis, argTwo.get()); | 4437 int32_t count = ValueToInteger(pThis, argTwo.get()); |
| 4455 if (count < 0) { | 4438 if (count < 0) { |
| 4456 count = 0; | 4439 count = 0; |
| 4457 } | 4440 } |
| 4458 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 4441 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 4459 sourceString.Left(count).AsStringC()); | 4442 sourceString.Left(count).AsStringC()); |
| 4460 } | 4443 } |
| 4461 } else { | 4444 } else { |
| 4462 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 4445 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4463 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Left"); | 4446 L"Left"); |
| 4464 } | 4447 } |
| 4465 } | 4448 } |
| 4466 | 4449 |
| 4467 // static | 4450 // static |
| 4468 void CXFA_FM2JSContext::Len(CFXJSE_Value* pThis, | 4451 void CXFA_FM2JSContext::Len(CFXJSE_Value* pThis, |
| 4469 const CFX_ByteStringC& szFuncName, | 4452 const CFX_ByteStringC& szFuncName, |
| 4470 CFXJSE_Arguments& args) { | 4453 CFXJSE_Arguments& args) { |
| 4471 if (args.GetLength() == 1) { | 4454 if (args.GetLength() == 1) { |
| 4472 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4455 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 4473 if (ValueIsNull(pThis, argOne.get())) { | 4456 if (ValueIsNull(pThis, argOne.get())) { |
| 4474 FXJSE_Value_SetNull(args.GetReturnValue()); | 4457 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4475 } else { | 4458 } else { |
| 4476 CFX_ByteString sourceString; | 4459 CFX_ByteString sourceString; |
| 4477 ValueToUTF8String(argOne.get(), sourceString); | 4460 ValueToUTF8String(argOne.get(), sourceString); |
| 4478 FXJSE_Value_SetInteger(args.GetReturnValue(), sourceString.GetLength()); | 4461 FXJSE_Value_SetInteger(args.GetReturnValue(), sourceString.GetLength()); |
| 4479 } | 4462 } |
| 4480 } else { | 4463 } else { |
| 4481 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 4464 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4482 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Len"); | 4465 L"Len"); |
| 4483 } | 4466 } |
| 4484 } | 4467 } |
| 4485 | 4468 |
| 4486 // static | 4469 // static |
| 4487 void CXFA_FM2JSContext::Lower(CFXJSE_Value* pThis, | 4470 void CXFA_FM2JSContext::Lower(CFXJSE_Value* pThis, |
| 4488 const CFX_ByteStringC& szFuncName, | 4471 const CFX_ByteStringC& szFuncName, |
| 4489 CFXJSE_Arguments& args) { | 4472 CFXJSE_Arguments& args) { |
| 4490 int32_t argc = args.GetLength(); | 4473 int32_t argc = args.GetLength(); |
| 4491 if ((argc > 0) && (argc < 3)) { | 4474 if ((argc > 0) && (argc < 3)) { |
| 4492 CFX_ByteString argString; | 4475 CFX_ByteString argString; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 4514 lowStringBuf.AppendChar(ch); | 4497 lowStringBuf.AppendChar(ch); |
| 4515 ++i; | 4498 ++i; |
| 4516 } | 4499 } |
| 4517 lowStringBuf.AppendChar(0); | 4500 lowStringBuf.AppendChar(0); |
| 4518 FXJSE_Value_SetUTF8String( | 4501 FXJSE_Value_SetUTF8String( |
| 4519 args.GetReturnValue(), | 4502 args.GetReturnValue(), |
| 4520 FX_UTF8Encode(lowStringBuf.GetBuffer(), lowStringBuf.GetLength()) | 4503 FX_UTF8Encode(lowStringBuf.GetBuffer(), lowStringBuf.GetLength()) |
| 4521 .AsStringC()); | 4504 .AsStringC()); |
| 4522 } | 4505 } |
| 4523 } else { | 4506 } else { |
| 4524 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 4507 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4525 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Lower"); | 4508 L"Lower"); |
| 4526 } | 4509 } |
| 4527 } | 4510 } |
| 4528 | 4511 |
| 4529 // static | 4512 // static |
| 4530 void CXFA_FM2JSContext::Ltrim(CFXJSE_Value* pThis, | 4513 void CXFA_FM2JSContext::Ltrim(CFXJSE_Value* pThis, |
| 4531 const CFX_ByteStringC& szFuncName, | 4514 const CFX_ByteStringC& szFuncName, |
| 4532 CFXJSE_Arguments& args) { | 4515 CFXJSE_Arguments& args) { |
| 4533 if (args.GetLength() == 1) { | 4516 if (args.GetLength() == 1) { |
| 4534 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4517 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 4535 if (ValueIsNull(pThis, argOne.get())) { | 4518 if (ValueIsNull(pThis, argOne.get())) { |
| 4536 FXJSE_Value_SetNull(args.GetReturnValue()); | 4519 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4537 } else { | 4520 } else { |
| 4538 CFX_ByteString sourceString; | 4521 CFX_ByteString sourceString; |
| 4539 ValueToUTF8String(argOne.get(), sourceString); | 4522 ValueToUTF8String(argOne.get(), sourceString); |
| 4540 sourceString.TrimLeft(); | 4523 sourceString.TrimLeft(); |
| 4541 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 4524 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 4542 sourceString.AsStringC()); | 4525 sourceString.AsStringC()); |
| 4543 } | 4526 } |
| 4544 } else { | 4527 } else { |
| 4545 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 4528 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4546 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Ltrim"); | 4529 L"Ltrim"); |
| 4547 } | 4530 } |
| 4548 } | 4531 } |
| 4549 | 4532 |
| 4550 // static | 4533 // static |
| 4551 void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis, | 4534 void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis, |
| 4552 const CFX_ByteStringC& szFuncName, | 4535 const CFX_ByteStringC& szFuncName, |
| 4553 CFXJSE_Arguments& args) { | 4536 CFXJSE_Arguments& args) { |
| 4554 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); | 4537 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); |
| 4555 if (args.GetLength() == 2) { | 4538 if (args.GetLength() == 2) { |
| 4556 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4539 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4675 szParsedValue.AsStringC()); | 4658 szParsedValue.AsStringC()); |
| 4676 } else { | 4659 } else { |
| 4677 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 4660 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
| 4678 } | 4661 } |
| 4679 } | 4662 } |
| 4680 } break; | 4663 } break; |
| 4681 } | 4664 } |
| 4682 } | 4665 } |
| 4683 } | 4666 } |
| 4684 } else { | 4667 } else { |
| 4685 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4668 pContext->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Parse"); |
| 4686 L"Parse"); | |
| 4687 } | 4669 } |
| 4688 } | 4670 } |
| 4689 | 4671 |
| 4690 // static | 4672 // static |
| 4691 void CXFA_FM2JSContext::Replace(CFXJSE_Value* pThis, | 4673 void CXFA_FM2JSContext::Replace(CFXJSE_Value* pThis, |
| 4692 const CFX_ByteStringC& szFuncName, | 4674 const CFX_ByteStringC& szFuncName, |
| 4693 CFXJSE_Arguments& args) { | 4675 CFXJSE_Arguments& args) { |
| 4694 int32_t argc = args.GetLength(); | 4676 int32_t argc = args.GetLength(); |
| 4695 if ((argc == 2) || (argc == 3)) { | 4677 if ((argc == 2) || (argc == 3)) { |
| 4696 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4678 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4735 } else { | 4717 } else { |
| 4736 resultString.AppendChar(ch); | 4718 resultString.AppendChar(ch); |
| 4737 } | 4719 } |
| 4738 } else { | 4720 } else { |
| 4739 resultString.AppendChar(ch); | 4721 resultString.AppendChar(ch); |
| 4740 } | 4722 } |
| 4741 } | 4723 } |
| 4742 resultString.AppendChar(0); | 4724 resultString.AppendChar(0); |
| 4743 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); | 4725 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); |
| 4744 } else { | 4726 } else { |
| 4745 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 4727 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4746 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Replace"); | 4728 L"Replace"); |
| 4747 } | 4729 } |
| 4748 } | 4730 } |
| 4749 | 4731 |
| 4750 // static | 4732 // static |
| 4751 void CXFA_FM2JSContext::Right(CFXJSE_Value* pThis, | 4733 void CXFA_FM2JSContext::Right(CFXJSE_Value* pThis, |
| 4752 const CFX_ByteStringC& szFuncName, | 4734 const CFX_ByteStringC& szFuncName, |
| 4753 CFXJSE_Arguments& args) { | 4735 CFXJSE_Arguments& args) { |
| 4754 if (args.GetLength() == 2) { | 4736 if (args.GetLength() == 2) { |
| 4755 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4737 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 4756 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | 4738 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
| 4757 FX_BOOL argIsNull = FALSE; | 4739 FX_BOOL argIsNull = FALSE; |
| 4758 if ((ValueIsNull(pThis, argOne.get())) || | 4740 if ((ValueIsNull(pThis, argOne.get())) || |
| 4759 (ValueIsNull(pThis, argTwo.get()))) { | 4741 (ValueIsNull(pThis, argTwo.get()))) { |
| 4760 argIsNull = TRUE; | 4742 argIsNull = TRUE; |
| 4761 } | 4743 } |
| 4762 if (argIsNull) { | 4744 if (argIsNull) { |
| 4763 FXJSE_Value_SetNull(args.GetReturnValue()); | 4745 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4764 } else { | 4746 } else { |
| 4765 CFX_ByteString sourceString; | 4747 CFX_ByteString sourceString; |
| 4766 ValueToUTF8String(argOne.get(), sourceString); | 4748 ValueToUTF8String(argOne.get(), sourceString); |
| 4767 int32_t count = ValueToInteger(pThis, argTwo.get()); | 4749 int32_t count = ValueToInteger(pThis, argTwo.get()); |
| 4768 if (count < 0) { | 4750 if (count < 0) { |
| 4769 count = 0; | 4751 count = 0; |
| 4770 } | 4752 } |
| 4771 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 4753 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 4772 sourceString.Right(count).AsStringC()); | 4754 sourceString.Right(count).AsStringC()); |
| 4773 } | 4755 } |
| 4774 } else { | 4756 } else { |
| 4775 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 4757 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4776 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Right"); | 4758 L"Right"); |
| 4777 } | 4759 } |
| 4778 } | 4760 } |
| 4779 | 4761 |
| 4780 // static | 4762 // static |
| 4781 void CXFA_FM2JSContext::Rtrim(CFXJSE_Value* pThis, | 4763 void CXFA_FM2JSContext::Rtrim(CFXJSE_Value* pThis, |
| 4782 const CFX_ByteStringC& szFuncName, | 4764 const CFX_ByteStringC& szFuncName, |
| 4783 CFXJSE_Arguments& args) { | 4765 CFXJSE_Arguments& args) { |
| 4784 if (args.GetLength() == 1) { | 4766 if (args.GetLength() == 1) { |
| 4785 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4767 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 4786 if (ValueIsNull(pThis, argOne.get())) { | 4768 if (ValueIsNull(pThis, argOne.get())) { |
| 4787 FXJSE_Value_SetNull(args.GetReturnValue()); | 4769 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4788 } else { | 4770 } else { |
| 4789 CFX_ByteString sourceString; | 4771 CFX_ByteString sourceString; |
| 4790 ValueToUTF8String(argOne.get(), sourceString); | 4772 ValueToUTF8String(argOne.get(), sourceString); |
| 4791 sourceString.TrimRight(); | 4773 sourceString.TrimRight(); |
| 4792 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 4774 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 4793 sourceString.AsStringC()); | 4775 sourceString.AsStringC()); |
| 4794 } | 4776 } |
| 4795 } else { | 4777 } else { |
| 4796 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 4778 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4797 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Rtrim"); | 4779 L"Rtrim"); |
| 4798 } | 4780 } |
| 4799 } | 4781 } |
| 4800 | 4782 |
| 4801 // static | 4783 // static |
| 4802 void CXFA_FM2JSContext::Space(CFXJSE_Value* pThis, | 4784 void CXFA_FM2JSContext::Space(CFXJSE_Value* pThis, |
| 4803 const CFX_ByteStringC& szFuncName, | 4785 const CFX_ByteStringC& szFuncName, |
| 4804 CFXJSE_Arguments& args) { | 4786 CFXJSE_Arguments& args) { |
| 4805 if (args.GetLength() == 1) { | 4787 if (args.GetLength() == 1) { |
| 4806 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4788 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 4807 if (FXJSE_Value_IsNull(argOne.get())) { | 4789 if (FXJSE_Value_IsNull(argOne.get())) { |
| 4808 FXJSE_Value_SetNull(args.GetReturnValue()); | 4790 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4809 } else { | 4791 } else { |
| 4810 int32_t count = 0; | 4792 int32_t count = 0; |
| 4811 count = ValueToInteger(pThis, argOne.get()); | 4793 count = ValueToInteger(pThis, argOne.get()); |
| 4812 count = (count < 0) ? 0 : count; | 4794 count = (count < 0) ? 0 : count; |
| 4813 CFX_ByteTextBuf spaceString; | 4795 CFX_ByteTextBuf spaceString; |
| 4814 int32_t index = 0; | 4796 int32_t index = 0; |
| 4815 while (index < count) { | 4797 while (index < count) { |
| 4816 spaceString.AppendByte(' '); | 4798 spaceString.AppendByte(' '); |
| 4817 index++; | 4799 index++; |
| 4818 } | 4800 } |
| 4819 spaceString.AppendByte(0); | 4801 spaceString.AppendByte(0); |
| 4820 FXJSE_Value_SetUTF8String(args.GetReturnValue(), spaceString.AsStringC()); | 4802 FXJSE_Value_SetUTF8String(args.GetReturnValue(), spaceString.AsStringC()); |
| 4821 } | 4803 } |
| 4822 } else { | 4804 } else { |
| 4823 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 4805 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4824 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Space"); | 4806 L"Space"); |
| 4825 } | 4807 } |
| 4826 } | 4808 } |
| 4827 | 4809 |
| 4828 // static | 4810 // static |
| 4829 void CXFA_FM2JSContext::Str(CFXJSE_Value* pThis, | 4811 void CXFA_FM2JSContext::Str(CFXJSE_Value* pThis, |
| 4830 const CFX_ByteStringC& szFuncName, | 4812 const CFX_ByteStringC& szFuncName, |
| 4831 CFXJSE_Arguments& args) { | 4813 CFXJSE_Arguments& args) { |
| 4832 int32_t argc = args.GetLength(); | 4814 int32_t argc = args.GetLength(); |
| 4833 if ((argc > 0) && (argc < 4)) { | 4815 if ((argc > 0) && (argc < 4)) { |
| 4834 FX_BOOL bFlags = FALSE; | 4816 FX_BOOL bFlags = FALSE; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4931 ++i; | 4913 ++i; |
| 4932 } | 4914 } |
| 4933 resultBuf.AppendChar(0); | 4915 resultBuf.AppendChar(0); |
| 4934 } | 4916 } |
| 4935 } | 4917 } |
| 4936 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); | 4918 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); |
| 4937 } else { | 4919 } else { |
| 4938 FXJSE_Value_SetNull(args.GetReturnValue()); | 4920 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4939 } | 4921 } |
| 4940 } else { | 4922 } else { |
| 4941 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 4923 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4942 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Str"); | 4924 L"Str"); |
| 4943 } | 4925 } |
| 4944 } | 4926 } |
| 4945 | 4927 |
| 4946 // static | 4928 // static |
| 4947 void CXFA_FM2JSContext::Stuff(CFXJSE_Value* pThis, | 4929 void CXFA_FM2JSContext::Stuff(CFXJSE_Value* pThis, |
| 4948 const CFX_ByteStringC& szFuncName, | 4930 const CFX_ByteStringC& szFuncName, |
| 4949 CFXJSE_Arguments& args) { | 4931 CFXJSE_Arguments& args) { |
| 4950 int32_t argc = args.GetLength(); | 4932 int32_t argc = args.GetLength(); |
| 4951 if ((argc == 3) || (argc == 4)) { | 4933 if ((argc == 3) || (argc == 4)) { |
| 4952 CFX_ByteString sourceString; | 4934 CFX_ByteString sourceString; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4988 } | 4970 } |
| 4989 resultString << insertString.AsStringC(); | 4971 resultString << insertString.AsStringC(); |
| 4990 i = iStart + iDelete; | 4972 i = iStart + iDelete; |
| 4991 while (i < iLength) { | 4973 while (i < iLength) { |
| 4992 resultString.AppendChar(sourceString.GetAt(i)); | 4974 resultString.AppendChar(sourceString.GetAt(i)); |
| 4993 ++i; | 4975 ++i; |
| 4994 } | 4976 } |
| 4995 resultString.AppendChar(0); | 4977 resultString.AppendChar(0); |
| 4996 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); | 4978 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); |
| 4997 } else { | 4979 } else { |
| 4998 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 4980 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4999 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Stuff"); | 4981 L"Stuff"); |
| 5000 } | 4982 } |
| 5001 } | 4983 } |
| 5002 | 4984 |
| 5003 // static | 4985 // static |
| 5004 void CXFA_FM2JSContext::Substr(CFXJSE_Value* pThis, | 4986 void CXFA_FM2JSContext::Substr(CFXJSE_Value* pThis, |
| 5005 const CFX_ByteStringC& szFuncName, | 4987 const CFX_ByteStringC& szFuncName, |
| 5006 CFXJSE_Arguments& args) { | 4988 CFXJSE_Arguments& args) { |
| 5007 if (args.GetLength() == 3) { | 4989 if (args.GetLength() == 3) { |
| 5008 std::unique_ptr<CFXJSE_Value> stringValue = GetSimpleValue(pThis, args, 0); | 4990 std::unique_ptr<CFXJSE_Value> stringValue = GetSimpleValue(pThis, args, 0); |
| 5009 std::unique_ptr<CFXJSE_Value> startValue = GetSimpleValue(pThis, args, 1); | 4991 std::unique_ptr<CFXJSE_Value> startValue = GetSimpleValue(pThis, args, 1); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 5031 } | 5013 } |
| 5032 if (iCount <= 0) { | 5014 if (iCount <= 0) { |
| 5033 iCount = 0; | 5015 iCount = 0; |
| 5034 } | 5016 } |
| 5035 iStart -= 1; | 5017 iStart -= 1; |
| 5036 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 5018 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 5037 szSourceStr.Mid(iStart, iCount).AsStringC()); | 5019 szSourceStr.Mid(iStart, iCount).AsStringC()); |
| 5038 } | 5020 } |
| 5039 } | 5021 } |
| 5040 } else { | 5022 } else { |
| 5041 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 5023 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5042 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Substr"); | 5024 L"Substr"); |
| 5043 } | 5025 } |
| 5044 } | 5026 } |
| 5045 | 5027 |
| 5046 // static | 5028 // static |
| 5047 void CXFA_FM2JSContext::Uuid(CFXJSE_Value* pThis, | 5029 void CXFA_FM2JSContext::Uuid(CFXJSE_Value* pThis, |
| 5048 const CFX_ByteStringC& szFuncName, | 5030 const CFX_ByteStringC& szFuncName, |
| 5049 CFXJSE_Arguments& args) { | 5031 CFXJSE_Arguments& args) { |
| 5050 int32_t argc = args.GetLength(); | 5032 int32_t argc = args.GetLength(); |
| 5051 if ((argc == 0) || (argc == 1)) { | 5033 if ((argc == 0) || (argc == 1)) { |
| 5052 int32_t iNum = 0; | 5034 int32_t iNum = 0; |
| 5053 if (argc == 1) { | 5035 if (argc == 1) { |
| 5054 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 5036 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 5055 iNum = (int32_t)ValueToFloat(pThis, argOne.get()); | 5037 iNum = (int32_t)ValueToFloat(pThis, argOne.get()); |
| 5056 } | 5038 } |
| 5057 FX_GUID guid; | 5039 FX_GUID guid; |
| 5058 FX_GUID_CreateV4(&guid); | 5040 FX_GUID_CreateV4(&guid); |
| 5059 CFX_ByteString bsUId; | 5041 CFX_ByteString bsUId; |
| 5060 FX_GUID_ToString(&guid, bsUId, iNum); | 5042 FX_GUID_ToString(&guid, bsUId, iNum); |
| 5061 FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsUId.AsStringC()); | 5043 FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsUId.AsStringC()); |
| 5062 } else { | 5044 } else { |
| 5063 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 5045 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5064 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Uuid"); | 5046 L"Uuid"); |
| 5065 } | 5047 } |
| 5066 } | 5048 } |
| 5067 | 5049 |
| 5068 // static | 5050 // static |
| 5069 void CXFA_FM2JSContext::Upper(CFXJSE_Value* pThis, | 5051 void CXFA_FM2JSContext::Upper(CFXJSE_Value* pThis, |
| 5070 const CFX_ByteStringC& szFuncName, | 5052 const CFX_ByteStringC& szFuncName, |
| 5071 CFXJSE_Arguments& args) { | 5053 CFXJSE_Arguments& args) { |
| 5072 int32_t argc = args.GetLength(); | 5054 int32_t argc = args.GetLength(); |
| 5073 if ((argc > 0) && (argc < 3)) { | 5055 if ((argc > 0) && (argc < 3)) { |
| 5074 CFX_ByteString argString; | 5056 CFX_ByteString argString; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 5096 upperStringBuf.AppendChar(ch); | 5078 upperStringBuf.AppendChar(ch); |
| 5097 ++i; | 5079 ++i; |
| 5098 } | 5080 } |
| 5099 upperStringBuf.AppendChar(0); | 5081 upperStringBuf.AppendChar(0); |
| 5100 FXJSE_Value_SetUTF8String( | 5082 FXJSE_Value_SetUTF8String( |
| 5101 args.GetReturnValue(), | 5083 args.GetReturnValue(), |
| 5102 FX_UTF8Encode(upperStringBuf.GetBuffer(), upperStringBuf.GetLength()) | 5084 FX_UTF8Encode(upperStringBuf.GetBuffer(), upperStringBuf.GetLength()) |
| 5103 .AsStringC()); | 5085 .AsStringC()); |
| 5104 } | 5086 } |
| 5105 } else { | 5087 } else { |
| 5106 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 5088 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5107 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Upper"); | 5089 L"Upper"); |
| 5108 } | 5090 } |
| 5109 } | 5091 } |
| 5110 | 5092 |
| 5111 // static | 5093 // static |
| 5112 void CXFA_FM2JSContext::WordNum(CFXJSE_Value* pThis, | 5094 void CXFA_FM2JSContext::WordNum(CFXJSE_Value* pThis, |
| 5113 const CFX_ByteStringC& szFuncName, | 5095 const CFX_ByteStringC& szFuncName, |
| 5114 CFXJSE_Arguments& args) { | 5096 CFXJSE_Arguments& args) { |
| 5115 int32_t argc = args.GetLength(); | 5097 int32_t argc = args.GetLength(); |
| 5116 if ((argc > 0) && (argc < 4)) { | 5098 if ((argc > 0) && (argc < 4)) { |
| 5117 FX_BOOL bFlags = FALSE; | 5099 FX_BOOL bFlags = FALSE; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5149 CFX_ByteTextBuf resultBuf; | 5131 CFX_ByteTextBuf resultBuf; |
| 5150 CFX_ByteString numberString; | 5132 CFX_ByteString numberString; |
| 5151 numberString.Format("%.2f", fNumber); | 5133 numberString.Format("%.2f", fNumber); |
| 5152 WordUS(numberString.AsStringC(), iIdentifier, resultBuf); | 5134 WordUS(numberString.AsStringC(), iIdentifier, resultBuf); |
| 5153 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); | 5135 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); |
| 5154 } | 5136 } |
| 5155 } else { | 5137 } else { |
| 5156 FXJSE_Value_SetNull(args.GetReturnValue()); | 5138 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5157 } | 5139 } |
| 5158 } else { | 5140 } else { |
| 5159 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 5141 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5160 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"WordNum"); | 5142 L"WordNum"); |
| 5161 } | 5143 } |
| 5162 } | 5144 } |
| 5163 | 5145 |
| 5164 // static | 5146 // static |
| 5165 void CXFA_FM2JSContext::TrillionUS(const CFX_ByteStringC& szData, | 5147 void CXFA_FM2JSContext::TrillionUS(const CFX_ByteStringC& szData, |
| 5166 CFX_ByteTextBuf& strBuf) { | 5148 CFX_ByteTextBuf& strBuf) { |
| 5167 CFX_ByteStringC pUnits[] = {"zero", "one", "two", "three", "four", | 5149 CFX_ByteStringC pUnits[] = {"zero", "one", "two", "three", "four", |
| 5168 "five", "six", "seven", "eight", "nine"}; | 5150 "five", "six", "seven", "eight", "nine"}; |
| 5169 CFX_ByteStringC pCapUnits[] = {"Zero", "One", "Two", "Three", "Four", | 5151 CFX_ByteStringC pCapUnits[] = {"Zero", "One", "Two", "Three", "Four", |
| 5170 "Five", "Six", "Seven", "Eight", "Nine"}; | 5152 "Five", "Six", "Seven", "Eight", "Nine"}; |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5383 if (pFile) { | 5365 if (pFile) { |
| 5384 int32_t size = pFile->GetSize(); | 5366 int32_t size = pFile->GetSize(); |
| 5385 uint8_t* pData = FX_Alloc(uint8_t, size); | 5367 uint8_t* pData = FX_Alloc(uint8_t, size); |
| 5386 pFile->ReadBlock(pData, size); | 5368 pFile->ReadBlock(pData, size); |
| 5387 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 5369 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 5388 CFX_ByteStringC(pData, size)); | 5370 CFX_ByteStringC(pData, size)); |
| 5389 FX_Free(pData); | 5371 FX_Free(pData); |
| 5390 pFile->Release(); | 5372 pFile->Release(); |
| 5391 } | 5373 } |
| 5392 } else { | 5374 } else { |
| 5393 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5375 pContext->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Get"); |
| 5394 L"Get"); | |
| 5395 } | 5376 } |
| 5396 } | 5377 } |
| 5397 | 5378 |
| 5398 // static | 5379 // static |
| 5399 void CXFA_FM2JSContext::Post(CFXJSE_Value* pThis, | 5380 void CXFA_FM2JSContext::Post(CFXJSE_Value* pThis, |
| 5400 const CFX_ByteStringC& szFuncName, | 5381 const CFX_ByteStringC& szFuncName, |
| 5401 CFXJSE_Arguments& args) { | 5382 CFXJSE_Arguments& args) { |
| 5402 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); | 5383 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); |
| 5403 int32_t argc = args.GetLength(); | 5384 int32_t argc = args.GetLength(); |
| 5404 if ((argc >= 2) && (argc <= 5)) { | 5385 if ((argc >= 2) && (argc <= 5)) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5438 CFX_WideString::FromUTF8(bsData.AsStringC()), | 5419 CFX_WideString::FromUTF8(bsData.AsStringC()), |
| 5439 CFX_WideString::FromUTF8(bsContentType.AsStringC()), | 5420 CFX_WideString::FromUTF8(bsContentType.AsStringC()), |
| 5440 CFX_WideString::FromUTF8(bsEncode.AsStringC()), | 5421 CFX_WideString::FromUTF8(bsEncode.AsStringC()), |
| 5441 CFX_WideString::FromUTF8(bsHeader.AsStringC()), decodedResponse); | 5422 CFX_WideString::FromUTF8(bsHeader.AsStringC()), decodedResponse); |
| 5442 if (bFlags) { | 5423 if (bFlags) { |
| 5443 FXJSE_Value_SetUTF8String( | 5424 FXJSE_Value_SetUTF8String( |
| 5444 args.GetReturnValue(), | 5425 args.GetReturnValue(), |
| 5445 FX_UTF8Encode(decodedResponse.c_str(), decodedResponse.GetLength()) | 5426 FX_UTF8Encode(decodedResponse.c_str(), decodedResponse.GetLength()) |
| 5446 .AsStringC()); | 5427 .AsStringC()); |
| 5447 } else { | 5428 } else { |
| 5448 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); | 5429 pContext->Throw(XFA_IDS_SERVER_DENY); |
| 5449 } | 5430 } |
| 5450 } else { | 5431 } else { |
| 5451 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5432 pContext->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Post"); |
| 5452 L"Post"); | |
| 5453 } | 5433 } |
| 5454 } | 5434 } |
| 5455 | 5435 |
| 5456 // static | 5436 // static |
| 5457 void CXFA_FM2JSContext::Put(CFXJSE_Value* pThis, | 5437 void CXFA_FM2JSContext::Put(CFXJSE_Value* pThis, |
| 5458 const CFX_ByteStringC& szFuncName, | 5438 const CFX_ByteStringC& szFuncName, |
| 5459 CFXJSE_Arguments& args) { | 5439 CFXJSE_Arguments& args) { |
| 5460 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); | 5440 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); |
| 5461 int32_t argc = args.GetLength(); | 5441 int32_t argc = args.GetLength(); |
| 5462 if ((argc == 2) || (argc == 3)) { | 5442 if ((argc == 2) || (argc == 3)) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 5480 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); | 5460 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); |
| 5481 ValueToUTF8String(argThree.get(), bsEncode); | 5461 ValueToUTF8String(argThree.get(), bsEncode); |
| 5482 } | 5462 } |
| 5483 FX_BOOL bFlags = pAppProvider->PutRequestURL( | 5463 FX_BOOL bFlags = pAppProvider->PutRequestURL( |
| 5484 CFX_WideString::FromUTF8(bsURL.AsStringC()), | 5464 CFX_WideString::FromUTF8(bsURL.AsStringC()), |
| 5485 CFX_WideString::FromUTF8(bsData.AsStringC()), | 5465 CFX_WideString::FromUTF8(bsData.AsStringC()), |
| 5486 CFX_WideString::FromUTF8(bsEncode.AsStringC())); | 5466 CFX_WideString::FromUTF8(bsEncode.AsStringC())); |
| 5487 if (bFlags) { | 5467 if (bFlags) { |
| 5488 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 5468 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
| 5489 } else { | 5469 } else { |
| 5490 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); | 5470 pContext->Throw(XFA_IDS_SERVER_DENY); |
| 5491 } | 5471 } |
| 5492 } else { | 5472 } else { |
| 5493 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5473 pContext->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Put"); |
| 5494 L"Put"); | |
| 5495 } | 5474 } |
| 5496 } | 5475 } |
| 5497 | 5476 |
| 5498 // static | 5477 // static |
| 5499 void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis, | 5478 void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis, |
| 5500 const CFX_ByteStringC& szFuncName, | 5479 const CFX_ByteStringC& szFuncName, |
| 5501 CFXJSE_Arguments& args) { | 5480 CFXJSE_Arguments& args) { |
| 5502 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); | 5481 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); |
| 5503 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 5482 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 5504 if (args.GetLength() == 2) { | 5483 if (args.GetLength() == 2) { |
| 5505 std::unique_ptr<CFXJSE_Value> lValue = args.GetValue(0); | 5484 std::unique_ptr<CFXJSE_Value> lValue = args.GetValue(0); |
| 5506 std::unique_ptr<CFXJSE_Value> rValue = GetSimpleValue(pThis, args, 1); | 5485 std::unique_ptr<CFXJSE_Value> rValue = GetSimpleValue(pThis, args, 1); |
| 5507 FX_BOOL bSetStatus = TRUE; | 5486 FX_BOOL bSetStatus = TRUE; |
| 5508 if (FXJSE_Value_IsArray(lValue.get())) { | 5487 if (FXJSE_Value_IsArray(lValue.get())) { |
| 5509 std::unique_ptr<CFXJSE_Value> leftLengthValue(new CFXJSE_Value(pIsolate)); | 5488 std::unique_ptr<CFXJSE_Value> leftLengthValue(new CFXJSE_Value(pIsolate)); |
| 5510 FXJSE_Value_GetObjectProp(lValue.get(), "length", leftLengthValue.get()); | 5489 FXJSE_Value_GetObjectProp(lValue.get(), "length", leftLengthValue.get()); |
| 5511 int32_t iLeftLength = FXJSE_Value_ToInteger(leftLengthValue.get()); | 5490 int32_t iLeftLength = FXJSE_Value_ToInteger(leftLengthValue.get()); |
| 5512 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 5491 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 5513 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 5492 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 5514 FXJSE_Value_GetObjectPropByIdx(lValue.get(), 1, propertyValue.get()); | 5493 FXJSE_Value_GetObjectPropByIdx(lValue.get(), 1, propertyValue.get()); |
| 5515 if (FXJSE_Value_IsNull(propertyValue.get())) { | 5494 if (FXJSE_Value_IsNull(propertyValue.get())) { |
| 5516 for (int32_t i = 2; i < iLeftLength; i++) { | 5495 for (int32_t i = 2; i < iLeftLength; i++) { |
| 5517 FXJSE_Value_GetObjectPropByIdx(lValue.get(), i, jsObjectValue.get()); | 5496 FXJSE_Value_GetObjectPropByIdx(lValue.get(), i, jsObjectValue.get()); |
| 5518 bSetStatus = SetObjectDefaultValue(jsObjectValue.get(), rValue.get()); | 5497 bSetStatus = SetObjectDefaultValue(jsObjectValue.get(), rValue.get()); |
| 5519 if (!bSetStatus) { | 5498 if (!bSetStatus) { |
| 5520 pContext->ThrowScriptErrorMessage(XFA_IDS_NOT_DEFAUL_VALUE); | 5499 pContext->Throw(XFA_IDS_NOT_DEFAUL_VALUE); |
| 5521 break; | 5500 break; |
| 5522 } | 5501 } |
| 5523 } | 5502 } |
| 5524 } else { | 5503 } else { |
| 5525 CFX_ByteString propertyStr; | 5504 CFX_ByteString propertyStr; |
| 5526 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); | 5505 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); |
| 5527 for (int32_t i = 2; i < iLeftLength; i++) { | 5506 for (int32_t i = 2; i < iLeftLength; i++) { |
| 5528 FXJSE_Value_GetObjectPropByIdx(lValue.get(), i, jsObjectValue.get()); | 5507 FXJSE_Value_GetObjectPropByIdx(lValue.get(), i, jsObjectValue.get()); |
| 5529 FXJSE_Value_SetObjectProp(jsObjectValue.get(), | 5508 FXJSE_Value_SetObjectProp(jsObjectValue.get(), |
| 5530 propertyStr.AsStringC(), rValue.get()); | 5509 propertyStr.AsStringC(), rValue.get()); |
| 5531 } | 5510 } |
| 5532 } | 5511 } |
| 5533 } else if (FXJSE_Value_IsObject(lValue.get())) { | 5512 } else if (FXJSE_Value_IsObject(lValue.get())) { |
| 5534 bSetStatus = SetObjectDefaultValue(lValue.get(), rValue.get()); | 5513 bSetStatus = SetObjectDefaultValue(lValue.get(), rValue.get()); |
| 5535 if (!bSetStatus) { | 5514 if (!bSetStatus) { |
| 5536 pContext->ThrowScriptErrorMessage(XFA_IDS_NOT_DEFAUL_VALUE); | 5515 pContext->Throw(XFA_IDS_NOT_DEFAUL_VALUE); |
| 5537 } | 5516 } |
| 5538 } | 5517 } |
| 5539 FXJSE_Value_Set(args.GetReturnValue(), rValue.get()); | 5518 FXJSE_Value_Set(args.GetReturnValue(), rValue.get()); |
| 5540 } else { | 5519 } else { |
| 5541 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5520 pContext->Throw(XFA_IDS_COMPILER_ERROR); |
| 5542 } | 5521 } |
| 5543 } | 5522 } |
| 5544 | 5523 |
| 5545 // static | 5524 // static |
| 5546 void CXFA_FM2JSContext::logical_or_operator(CFXJSE_Value* pThis, | 5525 void CXFA_FM2JSContext::logical_or_operator(CFXJSE_Value* pThis, |
| 5547 const CFX_ByteStringC& szFuncName, | 5526 const CFX_ByteStringC& szFuncName, |
| 5548 CFXJSE_Arguments& args) { | 5527 CFXJSE_Arguments& args) { |
| 5549 if (args.GetLength() == 2) { | 5528 if (args.GetLength() == 2) { |
| 5550 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5529 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5551 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5530 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5552 if (FXJSE_Value_IsNull(argFirst.get()) && | 5531 if (FXJSE_Value_IsNull(argFirst.get()) && |
| 5553 FXJSE_Value_IsNull(argSecond.get())) { | 5532 FXJSE_Value_IsNull(argSecond.get())) { |
| 5554 FXJSE_Value_SetNull(args.GetReturnValue()); | 5533 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5555 } else { | 5534 } else { |
| 5556 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); | 5535 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); |
| 5557 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); | 5536 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); |
| 5558 FXJSE_Value_SetInteger(args.GetReturnValue(), (first || second) ? 1 : 0); | 5537 FXJSE_Value_SetInteger(args.GetReturnValue(), (first || second) ? 1 : 0); |
| 5559 } | 5538 } |
| 5560 } else { | 5539 } else { |
| 5561 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 5540 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_COMPILER_ERROR); |
| 5562 XFA_IDS_COMPILER_ERROR); | |
| 5563 } | 5541 } |
| 5564 } | 5542 } |
| 5565 | 5543 |
| 5566 // static | 5544 // static |
| 5567 void CXFA_FM2JSContext::logical_and_operator(CFXJSE_Value* pThis, | 5545 void CXFA_FM2JSContext::logical_and_operator(CFXJSE_Value* pThis, |
| 5568 const CFX_ByteStringC& szFuncName, | 5546 const CFX_ByteStringC& szFuncName, |
| 5569 CFXJSE_Arguments& args) { | 5547 CFXJSE_Arguments& args) { |
| 5570 if (args.GetLength() == 2) { | 5548 if (args.GetLength() == 2) { |
| 5571 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5549 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5572 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5550 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5573 if (FXJSE_Value_IsNull(argFirst.get()) && | 5551 if (FXJSE_Value_IsNull(argFirst.get()) && |
| 5574 FXJSE_Value_IsNull(argSecond.get())) { | 5552 FXJSE_Value_IsNull(argSecond.get())) { |
| 5575 FXJSE_Value_SetNull(args.GetReturnValue()); | 5553 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5576 } else { | 5554 } else { |
| 5577 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); | 5555 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); |
| 5578 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); | 5556 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); |
| 5579 FXJSE_Value_SetInteger(args.GetReturnValue(), (first && second) ? 1 : 0); | 5557 FXJSE_Value_SetInteger(args.GetReturnValue(), (first && second) ? 1 : 0); |
| 5580 } | 5558 } |
| 5581 } else { | 5559 } else { |
| 5582 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 5560 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_COMPILER_ERROR); |
| 5583 XFA_IDS_COMPILER_ERROR); | |
| 5584 } | 5561 } |
| 5585 } | 5562 } |
| 5586 | 5563 |
| 5587 // static | 5564 // static |
| 5588 void CXFA_FM2JSContext::equality_operator(CFXJSE_Value* pThis, | 5565 void CXFA_FM2JSContext::equality_operator(CFXJSE_Value* pThis, |
| 5589 const CFX_ByteStringC& szFuncName, | 5566 const CFX_ByteStringC& szFuncName, |
| 5590 CFXJSE_Arguments& args) { | 5567 CFXJSE_Arguments& args) { |
| 5591 if (args.GetLength() == 2) { | 5568 if (args.GetLength() == 2) { |
| 5592 if (fm_ref_equal(pThis, args)) { | 5569 if (fm_ref_equal(pThis, args)) { |
| 5593 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); | 5570 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 5610 FXJSE_Value_SetInteger(args.GetReturnValue(), | 5587 FXJSE_Value_SetInteger(args.GetReturnValue(), |
| 5611 firstOutput == secondOutput); | 5588 firstOutput == secondOutput); |
| 5612 } else { | 5589 } else { |
| 5613 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5590 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5614 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5591 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5615 FXJSE_Value_SetInteger(args.GetReturnValue(), | 5592 FXJSE_Value_SetInteger(args.GetReturnValue(), |
| 5616 (first == second) ? 1 : 0); | 5593 (first == second) ? 1 : 0); |
| 5617 } | 5594 } |
| 5618 } | 5595 } |
| 5619 } else { | 5596 } else { |
| 5620 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 5597 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_COMPILER_ERROR); |
| 5621 XFA_IDS_COMPILER_ERROR); | |
| 5622 } | 5598 } |
| 5623 } | 5599 } |
| 5624 | 5600 |
| 5625 // static | 5601 // static |
| 5626 void CXFA_FM2JSContext::notequality_operator(CFXJSE_Value* pThis, | 5602 void CXFA_FM2JSContext::notequality_operator(CFXJSE_Value* pThis, |
| 5627 const CFX_ByteStringC& szFuncName, | 5603 const CFX_ByteStringC& szFuncName, |
| 5628 CFXJSE_Arguments& args) { | 5604 CFXJSE_Arguments& args) { |
| 5629 if (args.GetLength() == 2) { | 5605 if (args.GetLength() == 2) { |
| 5630 if (fm_ref_equal(pThis, args)) { | 5606 if (fm_ref_equal(pThis, args)) { |
| 5631 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 5607 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 5647 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); | 5623 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); |
| 5648 FXJSE_Value_SetInteger(args.GetReturnValue(), | 5624 FXJSE_Value_SetInteger(args.GetReturnValue(), |
| 5649 firstOutput != secondOutput); | 5625 firstOutput != secondOutput); |
| 5650 } else { | 5626 } else { |
| 5651 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5627 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5652 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5628 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5653 FXJSE_Value_SetInteger(args.GetReturnValue(), first != second); | 5629 FXJSE_Value_SetInteger(args.GetReturnValue(), first != second); |
| 5654 } | 5630 } |
| 5655 } | 5631 } |
| 5656 } else { | 5632 } else { |
| 5657 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 5633 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_COMPILER_ERROR); |
| 5658 XFA_IDS_COMPILER_ERROR); | |
| 5659 } | 5634 } |
| 5660 } | 5635 } |
| 5661 | 5636 |
| 5662 // static | 5637 // static |
| 5663 FX_BOOL CXFA_FM2JSContext::fm_ref_equal(CFXJSE_Value* pThis, | 5638 FX_BOOL CXFA_FM2JSContext::fm_ref_equal(CFXJSE_Value* pThis, |
| 5664 CFXJSE_Arguments& args) { | 5639 CFXJSE_Arguments& args) { |
| 5665 FX_BOOL bRet = FALSE; | 5640 FX_BOOL bRet = FALSE; |
| 5666 v8::Isolate* pIsolate = pThis->ToJSContext(nullptr)->GetScriptRuntime(); | 5641 v8::Isolate* pIsolate = pThis->ToJSContext(nullptr)->GetScriptRuntime(); |
| 5667 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0); | 5642 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0); |
| 5668 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1); | 5643 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5706 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); | 5681 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); |
| 5707 FXJSE_Value_SetInteger( | 5682 FXJSE_Value_SetInteger( |
| 5708 args.GetReturnValue(), | 5683 args.GetReturnValue(), |
| 5709 firstOutput.Compare(secondOutput.AsStringC()) == -1); | 5684 firstOutput.Compare(secondOutput.AsStringC()) == -1); |
| 5710 } else { | 5685 } else { |
| 5711 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5686 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5712 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5687 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5713 FXJSE_Value_SetInteger(args.GetReturnValue(), (first < second) ? 1 : 0); | 5688 FXJSE_Value_SetInteger(args.GetReturnValue(), (first < second) ? 1 : 0); |
| 5714 } | 5689 } |
| 5715 } else { | 5690 } else { |
| 5716 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 5691 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_COMPILER_ERROR); |
| 5717 XFA_IDS_COMPILER_ERROR); | |
| 5718 } | 5692 } |
| 5719 } | 5693 } |
| 5720 | 5694 |
| 5721 // static | 5695 // static |
| 5722 void CXFA_FM2JSContext::lessequal_operator(CFXJSE_Value* pThis, | 5696 void CXFA_FM2JSContext::lessequal_operator(CFXJSE_Value* pThis, |
| 5723 const CFX_ByteStringC& szFuncName, | 5697 const CFX_ByteStringC& szFuncName, |
| 5724 CFXJSE_Arguments& args) { | 5698 CFXJSE_Arguments& args) { |
| 5725 if (args.GetLength() == 2) { | 5699 if (args.GetLength() == 2) { |
| 5726 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5700 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5727 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5701 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 5740 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); | 5714 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); |
| 5741 FXJSE_Value_SetInteger( | 5715 FXJSE_Value_SetInteger( |
| 5742 args.GetReturnValue(), | 5716 args.GetReturnValue(), |
| 5743 firstOutput.Compare(secondOutput.AsStringC()) != 1); | 5717 firstOutput.Compare(secondOutput.AsStringC()) != 1); |
| 5744 } else { | 5718 } else { |
| 5745 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5719 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5746 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5720 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5747 FXJSE_Value_SetInteger(args.GetReturnValue(), (first <= second) ? 1 : 0); | 5721 FXJSE_Value_SetInteger(args.GetReturnValue(), (first <= second) ? 1 : 0); |
| 5748 } | 5722 } |
| 5749 } else { | 5723 } else { |
| 5750 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 5724 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_COMPILER_ERROR); |
| 5751 XFA_IDS_COMPILER_ERROR); | |
| 5752 } | 5725 } |
| 5753 } | 5726 } |
| 5754 | 5727 |
| 5755 // static | 5728 // static |
| 5756 void CXFA_FM2JSContext::greater_operator(CFXJSE_Value* pThis, | 5729 void CXFA_FM2JSContext::greater_operator(CFXJSE_Value* pThis, |
| 5757 const CFX_ByteStringC& szFuncName, | 5730 const CFX_ByteStringC& szFuncName, |
| 5758 CFXJSE_Arguments& args) { | 5731 CFXJSE_Arguments& args) { |
| 5759 if (args.GetLength() == 2) { | 5732 if (args.GetLength() == 2) { |
| 5760 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5733 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5761 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5734 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5762 if (FXJSE_Value_IsNull(argFirst.get()) || | 5735 if (FXJSE_Value_IsNull(argFirst.get()) || |
| 5763 FXJSE_Value_IsNull(argSecond.get())) { | 5736 FXJSE_Value_IsNull(argSecond.get())) { |
| 5764 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 5737 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
| 5765 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) && | 5738 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) && |
| 5766 FXJSE_Value_IsUTF8String(argSecond.get())) { | 5739 FXJSE_Value_IsUTF8String(argSecond.get())) { |
| 5767 CFX_ByteString firstOutput; | 5740 CFX_ByteString firstOutput; |
| 5768 CFX_ByteString secondOutput; | 5741 CFX_ByteString secondOutput; |
| 5769 FXJSE_Value_ToUTF8String(argFirst.get(), firstOutput); | 5742 FXJSE_Value_ToUTF8String(argFirst.get(), firstOutput); |
| 5770 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); | 5743 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); |
| 5771 FXJSE_Value_SetInteger( | 5744 FXJSE_Value_SetInteger( |
| 5772 args.GetReturnValue(), | 5745 args.GetReturnValue(), |
| 5773 firstOutput.Compare(secondOutput.AsStringC()) == 1); | 5746 firstOutput.Compare(secondOutput.AsStringC()) == 1); |
| 5774 } else { | 5747 } else { |
| 5775 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5748 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5776 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5749 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5777 FXJSE_Value_SetInteger(args.GetReturnValue(), (first > second) ? 1 : 0); | 5750 FXJSE_Value_SetInteger(args.GetReturnValue(), (first > second) ? 1 : 0); |
| 5778 } | 5751 } |
| 5779 } else { | 5752 } else { |
| 5780 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 5753 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_COMPILER_ERROR); |
| 5781 XFA_IDS_COMPILER_ERROR); | |
| 5782 } | 5754 } |
| 5783 } | 5755 } |
| 5784 | 5756 |
| 5785 // static | 5757 // static |
| 5786 void CXFA_FM2JSContext::greaterequal_operator(CFXJSE_Value* pThis, | 5758 void CXFA_FM2JSContext::greaterequal_operator(CFXJSE_Value* pThis, |
| 5787 const CFX_ByteStringC& szFuncName, | 5759 const CFX_ByteStringC& szFuncName, |
| 5788 CFXJSE_Arguments& args) { | 5760 CFXJSE_Arguments& args) { |
| 5789 if (args.GetLength() == 2) { | 5761 if (args.GetLength() == 2) { |
| 5790 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5762 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5791 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5763 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 5804 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); | 5776 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); |
| 5805 FXJSE_Value_SetInteger( | 5777 FXJSE_Value_SetInteger( |
| 5806 args.GetReturnValue(), | 5778 args.GetReturnValue(), |
| 5807 firstOutput.Compare(secondOutput.AsStringC()) != -1); | 5779 firstOutput.Compare(secondOutput.AsStringC()) != -1); |
| 5808 } else { | 5780 } else { |
| 5809 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5781 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5810 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5782 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5811 FXJSE_Value_SetInteger(args.GetReturnValue(), (first >= second) ? 1 : 0); | 5783 FXJSE_Value_SetInteger(args.GetReturnValue(), (first >= second) ? 1 : 0); |
| 5812 } | 5784 } |
| 5813 } else { | 5785 } else { |
| 5814 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 5786 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_COMPILER_ERROR); |
| 5815 XFA_IDS_COMPILER_ERROR); | |
| 5816 } | 5787 } |
| 5817 } | 5788 } |
| 5818 | 5789 |
| 5819 // static | 5790 // static |
| 5820 void CXFA_FM2JSContext::plus_operator(CFXJSE_Value* pThis, | 5791 void CXFA_FM2JSContext::plus_operator(CFXJSE_Value* pThis, |
| 5821 const CFX_ByteStringC& szFuncName, | 5792 const CFX_ByteStringC& szFuncName, |
| 5822 CFXJSE_Arguments& args) { | 5793 CFXJSE_Arguments& args) { |
| 5823 if (args.GetLength() == 2) { | 5794 if (args.GetLength() == 2) { |
| 5824 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0); | 5795 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0); |
| 5825 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1); | 5796 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1); |
| 5826 if (ValueIsNull(pThis, argFirst.get()) && | 5797 if (ValueIsNull(pThis, argFirst.get()) && |
| 5827 ValueIsNull(pThis, argSecond.get())) { | 5798 ValueIsNull(pThis, argSecond.get())) { |
| 5828 FXJSE_Value_SetNull(args.GetReturnValue()); | 5799 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5829 } else { | 5800 } else { |
| 5830 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5801 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5831 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5802 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5832 FXJSE_Value_SetDouble(args.GetReturnValue(), first + second); | 5803 FXJSE_Value_SetDouble(args.GetReturnValue(), first + second); |
| 5833 } | 5804 } |
| 5834 } else { | 5805 } else { |
| 5835 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 5806 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_COMPILER_ERROR); |
| 5836 XFA_IDS_COMPILER_ERROR); | |
| 5837 } | 5807 } |
| 5838 } | 5808 } |
| 5839 | 5809 |
| 5840 // static | 5810 // static |
| 5841 void CXFA_FM2JSContext::minus_operator(CFXJSE_Value* pThis, | 5811 void CXFA_FM2JSContext::minus_operator(CFXJSE_Value* pThis, |
| 5842 const CFX_ByteStringC& szFuncName, | 5812 const CFX_ByteStringC& szFuncName, |
| 5843 CFXJSE_Arguments& args) { | 5813 CFXJSE_Arguments& args) { |
| 5844 if (args.GetLength() == 2) { | 5814 if (args.GetLength() == 2) { |
| 5845 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5815 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5846 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5816 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5847 if (FXJSE_Value_IsNull(argFirst.get()) && | 5817 if (FXJSE_Value_IsNull(argFirst.get()) && |
| 5848 FXJSE_Value_IsNull(argSecond.get())) { | 5818 FXJSE_Value_IsNull(argSecond.get())) { |
| 5849 FXJSE_Value_SetNull(args.GetReturnValue()); | 5819 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5850 } else { | 5820 } else { |
| 5851 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5821 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5852 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5822 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5853 FXJSE_Value_SetDouble(args.GetReturnValue(), first - second); | 5823 FXJSE_Value_SetDouble(args.GetReturnValue(), first - second); |
| 5854 } | 5824 } |
| 5855 } else { | 5825 } else { |
| 5856 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 5826 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_COMPILER_ERROR); |
| 5857 XFA_IDS_COMPILER_ERROR); | |
| 5858 } | 5827 } |
| 5859 } | 5828 } |
| 5860 | 5829 |
| 5861 // static | 5830 // static |
| 5862 void CXFA_FM2JSContext::multiple_operator(CFXJSE_Value* pThis, | 5831 void CXFA_FM2JSContext::multiple_operator(CFXJSE_Value* pThis, |
| 5863 const CFX_ByteStringC& szFuncName, | 5832 const CFX_ByteStringC& szFuncName, |
| 5864 CFXJSE_Arguments& args) { | 5833 CFXJSE_Arguments& args) { |
| 5865 if (args.GetLength() == 2) { | 5834 if (args.GetLength() == 2) { |
| 5866 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5835 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5867 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5836 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5868 if (FXJSE_Value_IsNull(argFirst.get()) && | 5837 if (FXJSE_Value_IsNull(argFirst.get()) && |
| 5869 FXJSE_Value_IsNull(argSecond.get())) { | 5838 FXJSE_Value_IsNull(argSecond.get())) { |
| 5870 FXJSE_Value_SetNull(args.GetReturnValue()); | 5839 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5871 } else { | 5840 } else { |
| 5872 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5841 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5873 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5842 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5874 FXJSE_Value_SetDouble(args.GetReturnValue(), first * second); | 5843 FXJSE_Value_SetDouble(args.GetReturnValue(), first * second); |
| 5875 } | 5844 } |
| 5876 } else { | 5845 } else { |
| 5877 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 5846 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_COMPILER_ERROR); |
| 5878 XFA_IDS_COMPILER_ERROR); | |
| 5879 } | 5847 } |
| 5880 } | 5848 } |
| 5881 | 5849 |
| 5882 // static | 5850 // static |
| 5883 void CXFA_FM2JSContext::divide_operator(CFXJSE_Value* pThis, | 5851 void CXFA_FM2JSContext::divide_operator(CFXJSE_Value* pThis, |
| 5884 const CFX_ByteStringC& szFuncName, | 5852 const CFX_ByteStringC& szFuncName, |
| 5885 CFXJSE_Arguments& args) { | 5853 CFXJSE_Arguments& args) { |
| 5886 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); | 5854 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); |
| 5887 if (args.GetLength() == 2) { | 5855 if (args.GetLength() == 2) { |
| 5888 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5856 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5889 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5857 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5890 if (FXJSE_Value_IsNull(argFirst.get()) && | 5858 if (FXJSE_Value_IsNull(argFirst.get()) && |
| 5891 FXJSE_Value_IsNull(argSecond.get())) { | 5859 FXJSE_Value_IsNull(argSecond.get())) { |
| 5892 FXJSE_Value_SetNull(args.GetReturnValue()); | 5860 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5893 } else { | 5861 } else { |
| 5894 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5862 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5895 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5863 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5896 if (second == 0.0) { | 5864 if (second == 0.0) { |
| 5897 pContext->ThrowScriptErrorMessage(XFA_IDS_DIVIDE_ZERO); | 5865 pContext->Throw(XFA_IDS_DIVIDE_ZERO); |
| 5898 } else { | 5866 } else { |
| 5899 FXJSE_Value_SetDouble(args.GetReturnValue(), first / second); | 5867 FXJSE_Value_SetDouble(args.GetReturnValue(), first / second); |
| 5900 } | 5868 } |
| 5901 } | 5869 } |
| 5902 } else { | 5870 } else { |
| 5903 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5871 pContext->Throw(XFA_IDS_COMPILER_ERROR); |
| 5904 } | 5872 } |
| 5905 } | 5873 } |
| 5906 | 5874 |
| 5907 // static | 5875 // static |
| 5908 void CXFA_FM2JSContext::positive_operator(CFXJSE_Value* pThis, | 5876 void CXFA_FM2JSContext::positive_operator(CFXJSE_Value* pThis, |
| 5909 const CFX_ByteStringC& szFuncName, | 5877 const CFX_ByteStringC& szFuncName, |
| 5910 CFXJSE_Arguments& args) { | 5878 CFXJSE_Arguments& args) { |
| 5911 if (args.GetLength() == 1) { | 5879 if (args.GetLength() == 1) { |
| 5912 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 5880 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 5913 if (FXJSE_Value_IsNull(argOne.get())) { | 5881 if (FXJSE_Value_IsNull(argOne.get())) { |
| 5914 FXJSE_Value_SetNull(args.GetReturnValue()); | 5882 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5915 } else { | 5883 } else { |
| 5916 FXJSE_Value_SetDouble(args.GetReturnValue(), | 5884 FXJSE_Value_SetDouble(args.GetReturnValue(), |
| 5917 0.0 + ValueToDouble(pThis, argOne.get())); | 5885 0.0 + ValueToDouble(pThis, argOne.get())); |
| 5918 } | 5886 } |
| 5919 } else { | 5887 } else { |
| 5920 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 5888 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_COMPILER_ERROR); |
| 5921 XFA_IDS_COMPILER_ERROR); | |
| 5922 } | 5889 } |
| 5923 } | 5890 } |
| 5924 | 5891 |
| 5925 // static | 5892 // static |
| 5926 void CXFA_FM2JSContext::negative_operator(CFXJSE_Value* pThis, | 5893 void CXFA_FM2JSContext::negative_operator(CFXJSE_Value* pThis, |
| 5927 const CFX_ByteStringC& szFuncName, | 5894 const CFX_ByteStringC& szFuncName, |
| 5928 CFXJSE_Arguments& args) { | 5895 CFXJSE_Arguments& args) { |
| 5929 if (args.GetLength() == 1) { | 5896 if (args.GetLength() == 1) { |
| 5930 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 5897 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 5931 if (FXJSE_Value_IsNull(argOne.get())) { | 5898 if (FXJSE_Value_IsNull(argOne.get())) { |
| 5932 FXJSE_Value_SetNull(args.GetReturnValue()); | 5899 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5933 } else { | 5900 } else { |
| 5934 FXJSE_Value_SetDouble(args.GetReturnValue(), | 5901 FXJSE_Value_SetDouble(args.GetReturnValue(), |
| 5935 0.0 - ValueToDouble(pThis, argOne.get())); | 5902 0.0 - ValueToDouble(pThis, argOne.get())); |
| 5936 } | 5903 } |
| 5937 } else { | 5904 } else { |
| 5938 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 5905 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_COMPILER_ERROR); |
| 5939 XFA_IDS_COMPILER_ERROR); | |
| 5940 } | 5906 } |
| 5941 } | 5907 } |
| 5942 | 5908 |
| 5943 // static | 5909 // static |
| 5944 void CXFA_FM2JSContext::logical_not_operator(CFXJSE_Value* pThis, | 5910 void CXFA_FM2JSContext::logical_not_operator(CFXJSE_Value* pThis, |
| 5945 const CFX_ByteStringC& szFuncName, | 5911 const CFX_ByteStringC& szFuncName, |
| 5946 CFXJSE_Arguments& args) { | 5912 CFXJSE_Arguments& args) { |
| 5947 if (args.GetLength() == 1) { | 5913 if (args.GetLength() == 1) { |
| 5948 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 5914 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 5949 if (FXJSE_Value_IsNull(argOne.get())) { | 5915 if (FXJSE_Value_IsNull(argOne.get())) { |
| 5950 FXJSE_Value_SetNull(args.GetReturnValue()); | 5916 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5951 } else { | 5917 } else { |
| 5952 FX_DOUBLE first = ValueToDouble(pThis, argOne.get()); | 5918 FX_DOUBLE first = ValueToDouble(pThis, argOne.get()); |
| 5953 FXJSE_Value_SetInteger(args.GetReturnValue(), (first == 0.0) ? 1 : 0); | 5919 FXJSE_Value_SetInteger(args.GetReturnValue(), (first == 0.0) ? 1 : 0); |
| 5954 } | 5920 } |
| 5955 } else { | 5921 } else { |
| 5956 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 5922 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_COMPILER_ERROR); |
| 5957 XFA_IDS_COMPILER_ERROR); | |
| 5958 } | 5923 } |
| 5959 } | 5924 } |
| 5960 | 5925 |
| 5961 // static | 5926 // static |
| 5962 void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis, | 5927 void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis, |
| 5963 const CFX_ByteStringC& szFuncName, | 5928 const CFX_ByteStringC& szFuncName, |
| 5964 CFXJSE_Arguments& args) { | 5929 CFXJSE_Arguments& args) { |
| 5965 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); | 5930 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); |
| 5966 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 5931 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 5967 int32_t argc = args.GetLength(); | 5932 int32_t argc = args.GetLength(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6026 FXJSE_Value_SetArray(args.GetReturnValue(), (iCounter + 2), rgValues); | 5991 FXJSE_Value_SetArray(args.GetReturnValue(), (iCounter + 2), rgValues); |
| 6027 for (int32_t i = 0; i < (iCounter + 2); i++) | 5992 for (int32_t i = 0; i < (iCounter + 2); i++) |
| 6028 delete rgValues[i]; | 5993 delete rgValues[i]; |
| 6029 | 5994 |
| 6030 FX_Free(rgValues); | 5995 FX_Free(rgValues); |
| 6031 } else { | 5996 } else { |
| 6032 CFX_WideString wsPropertyName = | 5997 CFX_WideString wsPropertyName = |
| 6033 CFX_WideString::FromUTF8(szName.AsStringC()); | 5998 CFX_WideString::FromUTF8(szName.AsStringC()); |
| 6034 CFX_WideString wsSomExpression = | 5999 CFX_WideString wsSomExpression = |
| 6035 CFX_WideString::FromUTF8(szSomExp.AsStringC()); | 6000 CFX_WideString::FromUTF8(szSomExp.AsStringC()); |
| 6036 pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, | 6001 pContext->Throw(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, |
| 6037 wsPropertyName.c_str(), | 6002 wsPropertyName.c_str(), wsSomExpression.c_str()); |
| 6038 wsSomExpression.c_str()); | |
| 6039 } | 6003 } |
| 6040 for (int32_t i = 0; i < iLength - 2; i++) { | 6004 for (int32_t i = 0; i < iLength - 2; i++) { |
| 6041 for (int32_t j = 0; j < iSizes[i]; j++) | 6005 for (int32_t j = 0; j < iSizes[i]; j++) |
| 6042 delete hResolveValues[i][j]; | 6006 delete hResolveValues[i][j]; |
| 6043 | 6007 |
| 6044 if (iSizes[i] > 0) { | 6008 if (iSizes[i] > 0) { |
| 6045 FX_Free(hResolveValues[i]); | 6009 FX_Free(hResolveValues[i]); |
| 6046 } | 6010 } |
| 6047 } | 6011 } |
| 6048 FX_Free(hResolveValues); | 6012 FX_Free(hResolveValues); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6089 FX_Free(rgValues); | 6053 FX_Free(rgValues); |
| 6090 for (int32_t i = 0; i < iSize; i++) | 6054 for (int32_t i = 0; i < iSize; i++) |
| 6091 delete hResolveValues[i]; | 6055 delete hResolveValues[i]; |
| 6092 | 6056 |
| 6093 FX_Free(hResolveValues); | 6057 FX_Free(hResolveValues); |
| 6094 } else { | 6058 } else { |
| 6095 CFX_WideString wsPropertyName = | 6059 CFX_WideString wsPropertyName = |
| 6096 CFX_WideString::FromUTF8(szName.AsStringC()); | 6060 CFX_WideString::FromUTF8(szName.AsStringC()); |
| 6097 CFX_WideString wsSomExpression = | 6061 CFX_WideString wsSomExpression = |
| 6098 CFX_WideString::FromUTF8(szSomExp.AsStringC()); | 6062 CFX_WideString::FromUTF8(szSomExp.AsStringC()); |
| 6099 pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, | 6063 pContext->Throw(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, |
| 6100 wsPropertyName.c_str(), | 6064 wsPropertyName.c_str(), wsSomExpression.c_str()); |
| 6101 wsSomExpression.c_str()); | |
| 6102 } | 6065 } |
| 6103 } | 6066 } |
| 6104 } else { | 6067 } else { |
| 6105 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6068 pContext->Throw(XFA_IDS_COMPILER_ERROR); |
| 6106 } | 6069 } |
| 6107 } | 6070 } |
| 6108 | 6071 |
| 6109 // static | 6072 // static |
| 6110 void CXFA_FM2JSContext::dotdot_accessor(CFXJSE_Value* pThis, | 6073 void CXFA_FM2JSContext::dotdot_accessor(CFXJSE_Value* pThis, |
| 6111 const CFX_ByteStringC& szFuncName, | 6074 const CFX_ByteStringC& szFuncName, |
| 6112 CFXJSE_Arguments& args) { | 6075 CFXJSE_Arguments& args) { |
| 6113 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); | 6076 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); |
| 6114 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6077 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6115 int32_t argc = args.GetLength(); | 6078 int32_t argc = args.GetLength(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6171 FXJSE_Value_SetArray(args.GetReturnValue(), (iCounter + 2), rgValues); | 6134 FXJSE_Value_SetArray(args.GetReturnValue(), (iCounter + 2), rgValues); |
| 6172 for (int32_t i = 0; i < (iCounter + 2); i++) | 6135 for (int32_t i = 0; i < (iCounter + 2); i++) |
| 6173 delete rgValues[i]; | 6136 delete rgValues[i]; |
| 6174 | 6137 |
| 6175 FX_Free(rgValues); | 6138 FX_Free(rgValues); |
| 6176 } else { | 6139 } else { |
| 6177 CFX_WideString wsPropertyName = | 6140 CFX_WideString wsPropertyName = |
| 6178 CFX_WideString::FromUTF8(szName.AsStringC()); | 6141 CFX_WideString::FromUTF8(szName.AsStringC()); |
| 6179 CFX_WideString wsSomExpression = | 6142 CFX_WideString wsSomExpression = |
| 6180 CFX_WideString::FromUTF8(szSomExp.AsStringC()); | 6143 CFX_WideString::FromUTF8(szSomExp.AsStringC()); |
| 6181 pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, | 6144 pContext->Throw(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, |
| 6182 wsPropertyName.c_str(), | 6145 wsPropertyName.c_str(), wsSomExpression.c_str()); |
| 6183 wsSomExpression.c_str()); | |
| 6184 } | 6146 } |
| 6185 for (int32_t i = 0; i < iLength - 2; i++) { | 6147 for (int32_t i = 0; i < iLength - 2; i++) { |
| 6186 for (int32_t j = 0; j < iSizes[i]; j++) | 6148 for (int32_t j = 0; j < iSizes[i]; j++) |
| 6187 delete hResolveValues[i][j]; | 6149 delete hResolveValues[i][j]; |
| 6188 | 6150 |
| 6189 FX_Free(hResolveValues[i]); | 6151 FX_Free(hResolveValues[i]); |
| 6190 } | 6152 } |
| 6191 FX_Free(hResolveValues); | 6153 FX_Free(hResolveValues); |
| 6192 FX_Free(iSizes); | 6154 FX_Free(iSizes); |
| 6193 } else { | 6155 } else { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6232 FX_Free(rgValues); | 6194 FX_Free(rgValues); |
| 6233 for (int32_t i = 0; i < iSize; i++) | 6195 for (int32_t i = 0; i < iSize; i++) |
| 6234 delete hResolveValues[i]; | 6196 delete hResolveValues[i]; |
| 6235 | 6197 |
| 6236 FX_Free(hResolveValues); | 6198 FX_Free(hResolveValues); |
| 6237 } else { | 6199 } else { |
| 6238 CFX_WideString wsPropertyName = | 6200 CFX_WideString wsPropertyName = |
| 6239 CFX_WideString::FromUTF8(szName.AsStringC()); | 6201 CFX_WideString::FromUTF8(szName.AsStringC()); |
| 6240 CFX_WideString wsSomExpression = | 6202 CFX_WideString wsSomExpression = |
| 6241 CFX_WideString::FromUTF8(szSomExp.AsStringC()); | 6203 CFX_WideString::FromUTF8(szSomExp.AsStringC()); |
| 6242 pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, | 6204 pContext->Throw(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, |
| 6243 wsPropertyName.c_str(), | 6205 wsPropertyName.c_str(), wsSomExpression.c_str()); |
| 6244 wsSomExpression.c_str()); | |
| 6245 } | 6206 } |
| 6246 } | 6207 } |
| 6247 } else { | 6208 } else { |
| 6248 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6209 pContext->Throw(XFA_IDS_COMPILER_ERROR); |
| 6249 } | 6210 } |
| 6250 } | 6211 } |
| 6251 | 6212 |
| 6252 // static | 6213 // static |
| 6253 void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis, | 6214 void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis, |
| 6254 const CFX_ByteStringC& szFuncName, | 6215 const CFX_ByteStringC& szFuncName, |
| 6255 CFXJSE_Arguments& args) { | 6216 CFXJSE_Arguments& args) { |
| 6256 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); | 6217 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); |
| 6257 if (args.GetLength() == 1) { | 6218 if (args.GetLength() == 1) { |
| 6258 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 6219 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 6259 CFX_ByteString argString; | 6220 CFX_ByteString argString; |
| 6260 ValueToUTF8String(argOne.get(), argString); | 6221 ValueToUTF8String(argOne.get(), argString); |
| 6261 if (argString.IsEmpty()) { | 6222 if (argString.IsEmpty()) { |
| 6262 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 6223 pContext->Throw(XFA_IDS_ARGUMENT_MISMATCH); |
| 6263 } else { | 6224 } else { |
| 6264 CFX_WideString scriptString = | 6225 CFX_WideString scriptString = |
| 6265 CFX_WideString::FromUTF8(argString.AsStringC()); | 6226 CFX_WideString::FromUTF8(argString.AsStringC()); |
| 6266 CFX_WideTextBuf wsJavaScriptBuf; | 6227 CFX_WideTextBuf wsJavaScriptBuf; |
| 6267 CFX_WideString wsError; | 6228 CFX_WideString wsError; |
| 6268 CXFA_FM2JSContext::Translate(scriptString.AsStringC(), wsJavaScriptBuf, | 6229 CXFA_FM2JSContext::Translate(scriptString.AsStringC(), wsJavaScriptBuf, |
| 6269 wsError); | 6230 wsError); |
| 6270 if (wsError.IsEmpty()) { | 6231 if (wsError.IsEmpty()) { |
| 6271 CFX_WideString javaScript = wsJavaScriptBuf.MakeString(); | 6232 CFX_WideString javaScript = wsJavaScriptBuf.MakeString(); |
| 6272 FXJSE_Value_SetUTF8String( | 6233 FXJSE_Value_SetUTF8String( |
| 6273 args.GetReturnValue(), | 6234 args.GetReturnValue(), |
| 6274 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()) | 6235 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()) |
| 6275 .AsStringC()); | 6236 .AsStringC()); |
| 6276 } else { | 6237 } else { |
| 6277 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6238 pContext->Throw(XFA_IDS_COMPILER_ERROR); |
| 6278 } | 6239 } |
| 6279 } | 6240 } |
| 6280 } else { | 6241 } else { |
| 6281 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 6242 pContext->Throw(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Eval"); |
| 6282 L"Eval"); | |
| 6283 } | 6243 } |
| 6284 } | 6244 } |
| 6285 | 6245 |
| 6286 // static | 6246 // static |
| 6287 void CXFA_FM2JSContext::is_fm_object(CFXJSE_Value* pThis, | 6247 void CXFA_FM2JSContext::is_fm_object(CFXJSE_Value* pThis, |
| 6288 const CFX_ByteStringC& szFuncName, | 6248 const CFX_ByteStringC& szFuncName, |
| 6289 CFXJSE_Arguments& args) { | 6249 CFXJSE_Arguments& args) { |
| 6290 if (args.GetLength() == 1) { | 6250 if (args.GetLength() == 1) { |
| 6291 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 6251 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 6292 FXJSE_Value_SetBoolean(args.GetReturnValue(), | 6252 FXJSE_Value_SetBoolean(args.GetReturnValue(), |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6329 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); | 6289 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); |
| 6330 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), | 6290 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), |
| 6331 args.GetReturnValue()); | 6291 args.GetReturnValue()); |
| 6332 } | 6292 } |
| 6333 } else if (FXJSE_Value_IsObject(argOne.get())) { | 6293 } else if (FXJSE_Value_IsObject(argOne.get())) { |
| 6334 GetObjectDefaultValue(argOne.get(), args.GetReturnValue()); | 6294 GetObjectDefaultValue(argOne.get(), args.GetReturnValue()); |
| 6335 } else { | 6295 } else { |
| 6336 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); | 6296 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); |
| 6337 } | 6297 } |
| 6338 } else { | 6298 } else { |
| 6339 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6299 pContext->Throw(XFA_IDS_COMPILER_ERROR); |
| 6340 } | 6300 } |
| 6341 } | 6301 } |
| 6342 | 6302 |
| 6343 // static | 6303 // static |
| 6344 void CXFA_FM2JSContext::get_fm_jsobj(CFXJSE_Value* pThis, | 6304 void CXFA_FM2JSContext::get_fm_jsobj(CFXJSE_Value* pThis, |
| 6345 const CFX_ByteStringC& szFuncName, | 6305 const CFX_ByteStringC& szFuncName, |
| 6346 CFXJSE_Arguments& args) { | 6306 CFXJSE_Arguments& args) { |
| 6347 if (args.GetLength() == 1) { | 6307 if (args.GetLength() == 1) { |
| 6348 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 6308 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 6349 if (FXJSE_Value_IsArray(argOne.get())) { | 6309 if (FXJSE_Value_IsArray(argOne.get())) { |
| 6350 #ifndef NDEBUG | 6310 #ifndef NDEBUG |
| 6351 v8::Isolate* pIsolate = pThis->ToJSContext(nullptr)->GetScriptRuntime(); | 6311 v8::Isolate* pIsolate = pThis->ToJSContext(nullptr)->GetScriptRuntime(); |
| 6352 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 6312 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 6353 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get()); | 6313 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get()); |
| 6354 ASSERT(FXJSE_Value_ToInteger(lengthValue.get()) >= 3); | 6314 ASSERT(FXJSE_Value_ToInteger(lengthValue.get()) >= 3); |
| 6355 #endif | 6315 #endif |
| 6356 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, args.GetReturnValue()); | 6316 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, args.GetReturnValue()); |
| 6357 } else { | 6317 } else { |
| 6358 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); | 6318 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); |
| 6359 } | 6319 } |
| 6360 } else { | 6320 } else { |
| 6361 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage( | 6321 pThis->ToJSContext(nullptr)->Throw(XFA_IDS_COMPILER_ERROR); |
| 6362 XFA_IDS_COMPILER_ERROR); | |
| 6363 } | 6322 } |
| 6364 } | 6323 } |
| 6365 | 6324 |
| 6366 // static | 6325 // static |
| 6367 void CXFA_FM2JSContext::fm_var_filter(CFXJSE_Value* pThis, | 6326 void CXFA_FM2JSContext::fm_var_filter(CFXJSE_Value* pThis, |
| 6368 const CFX_ByteStringC& szFuncName, | 6327 const CFX_ByteStringC& szFuncName, |
| 6369 CFXJSE_Arguments& args) { | 6328 CFXJSE_Arguments& args) { |
| 6370 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); | 6329 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr); |
| 6371 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6330 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6372 if (args.GetLength() == 1) { | 6331 if (args.GetLength() == 1) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 6390 FXJSE_Value_SetNull(rgValues[2]); | 6349 FXJSE_Value_SetNull(rgValues[2]); |
| 6391 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); | 6350 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); |
| 6392 for (int32_t i = 0; i < 3; i++) | 6351 for (int32_t i = 0; i < 3; i++) |
| 6393 delete rgValues[i]; | 6352 delete rgValues[i]; |
| 6394 } else if (iFlags == 3) { | 6353 } else if (iFlags == 3) { |
| 6395 std::unique_ptr<CFXJSE_Value> objectValue(new CFXJSE_Value(pIsolate)); | 6354 std::unique_ptr<CFXJSE_Value> objectValue(new CFXJSE_Value(pIsolate)); |
| 6396 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, objectValue.get()); | 6355 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, objectValue.get()); |
| 6397 if (!FXJSE_Value_IsNull(objectValue.get())) { | 6356 if (!FXJSE_Value_IsNull(objectValue.get())) { |
| 6398 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); | 6357 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); |
| 6399 } else { | 6358 } else { |
| 6400 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6359 pContext->Throw(XFA_IDS_COMPILER_ERROR); |
| 6401 } | 6360 } |
| 6402 } else { | 6361 } else { |
| 6403 std::unique_ptr<CFXJSE_Value> simpleValue = | 6362 std::unique_ptr<CFXJSE_Value> simpleValue = |
| 6404 GetSimpleValue(pThis, args, 0); | 6363 GetSimpleValue(pThis, args, 0); |
| 6405 FXJSE_Value_Set(args.GetReturnValue(), simpleValue.get()); | 6364 FXJSE_Value_Set(args.GetReturnValue(), simpleValue.get()); |
| 6406 } | 6365 } |
| 6407 } else { | 6366 } else { |
| 6408 std::unique_ptr<CFXJSE_Value> simpleValue = | 6367 std::unique_ptr<CFXJSE_Value> simpleValue = |
| 6409 GetSimpleValue(pThis, args, 0); | 6368 GetSimpleValue(pThis, args, 0); |
| 6410 FXJSE_Value_Set(args.GetReturnValue(), simpleValue.get()); | 6369 FXJSE_Value_Set(args.GetReturnValue(), simpleValue.get()); |
| 6411 } | 6370 } |
| 6412 } else { | 6371 } else { |
| 6413 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6372 pContext->Throw(XFA_IDS_COMPILER_ERROR); |
| 6414 } | 6373 } |
| 6415 } | 6374 } |
| 6416 | 6375 |
| 6417 // static | 6376 // static |
| 6418 void CXFA_FM2JSContext::concat_fm_object(CFXJSE_Value* pThis, | 6377 void CXFA_FM2JSContext::concat_fm_object(CFXJSE_Value* pThis, |
| 6419 const CFX_ByteStringC& szFuncName, | 6378 const CFX_ByteStringC& szFuncName, |
| 6420 CFXJSE_Arguments& args) { | 6379 CFXJSE_Arguments& args) { |
| 6421 v8::Isolate* pIsolate = pThis->ToJSContext(nullptr)->GetScriptRuntime(); | 6380 v8::Isolate* pIsolate = pThis->ToJSContext(nullptr)->GetScriptRuntime(); |
| 6422 uint32_t iLength = 0; | 6381 uint32_t iLength = 0; |
| 6423 int32_t argc = args.GetLength(); | 6382 int32_t argc = args.GetLength(); |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6978 FXJSE_Value_SetNull(m_pValue.get()); | 6937 FXJSE_Value_SetNull(m_pValue.get()); |
| 6979 FXJSE_Value_SetObject(m_pValue.get(), this, m_pFMClass); | 6938 FXJSE_Value_SetObject(m_pValue.get(), this, m_pFMClass); |
| 6980 } | 6939 } |
| 6981 | 6940 |
| 6982 CXFA_FM2JSContext::~CXFA_FM2JSContext() {} | 6941 CXFA_FM2JSContext::~CXFA_FM2JSContext() {} |
| 6983 | 6942 |
| 6984 void CXFA_FM2JSContext::GlobalPropertyGetter(CFXJSE_Value* pValue) { | 6943 void CXFA_FM2JSContext::GlobalPropertyGetter(CFXJSE_Value* pValue) { |
| 6985 FXJSE_Value_Set(pValue, m_pValue.get()); | 6944 FXJSE_Value_Set(pValue, m_pValue.get()); |
| 6986 } | 6945 } |
| 6987 | 6946 |
| 6988 void CXFA_FM2JSContext::ThrowScriptErrorMessage(int32_t iStringID, ...) { | 6947 void CXFA_FM2JSContext::Throw(int32_t iStringID, ...) { |
| 6989 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); | 6948 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); |
| 6990 ASSERT(pAppProvider); | 6949 ASSERT(pAppProvider); |
| 6991 CFX_WideString wsFormat; | 6950 CFX_WideString wsFormat; |
| 6992 pAppProvider->LoadString(iStringID, wsFormat); | 6951 pAppProvider->LoadString(iStringID, wsFormat); |
| 6993 CFX_WideString wsMessage; | 6952 CFX_WideString wsMessage; |
| 6994 va_list arg_ptr; | 6953 va_list arg_ptr; |
| 6995 va_start(arg_ptr, iStringID); | 6954 va_start(arg_ptr, iStringID); |
| 6996 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); | 6955 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); |
| 6997 va_end(arg_ptr); | 6956 va_end(arg_ptr); |
| 6998 FXJSE_ThrowMessage( | 6957 FXJSE_ThrowMessage( |
| 6999 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); | 6958 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); |
| 7000 } | 6959 } |
| OLD | NEW |