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

Side by Side Diff: xfa/fxfa/fm2js/xfa_fm2jscontext.cpp

Issue 2029043002: Change ThrowScriptErrorMessage() to ThrowException(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@value_toobject_cleanup
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/fm2js/xfa_fm2jscontext.h ('k') | xfa/fxfa/parser/xfa_object.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 CXFA_FM2JSContext* pContext = 504 CXFA_FM2JSContext* pContext =
505 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 505 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
506 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 506 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Abs");
507 L"Abs");
508 return; 507 return;
509 } 508 }
510 509
511 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 510 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
512 if (ValueIsNull(pThis, argOne.get())) { 511 if (ValueIsNull(pThis, argOne.get())) {
513 FXJSE_Value_SetNull(args.GetReturnValue()); 512 FXJSE_Value_SetNull(args.GetReturnValue());
514 return; 513 return;
515 } 514 }
516 515
517 FX_DOUBLE dValue = ValueToDouble(pThis, argOne.get()); 516 FX_DOUBLE dValue = ValueToDouble(pThis, argOne.get());
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum / uCount); 596 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum / uCount);
598 } 597 }
599 598
600 // static 599 // static
601 void CXFA_FM2JSContext::Ceil(CFXJSE_Value* pThis, 600 void CXFA_FM2JSContext::Ceil(CFXJSE_Value* pThis,
602 const CFX_ByteStringC& szFuncName, 601 const CFX_ByteStringC& szFuncName,
603 CFXJSE_Arguments& args) { 602 CFXJSE_Arguments& args) {
604 if (args.GetLength() != 1) { 603 if (args.GetLength() != 1) {
605 CXFA_FM2JSContext* pContext = 604 CXFA_FM2JSContext* pContext =
606 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 605 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
607 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 606 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Ceil");
608 L"Ceil");
609 return; 607 return;
610 } 608 }
611 609
612 std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, args, 0); 610 std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, args, 0);
613 if (ValueIsNull(pThis, argValue.get())) { 611 if (ValueIsNull(pThis, argValue.get())) {
614 FXJSE_Value_SetNull(args.GetReturnValue()); 612 FXJSE_Value_SetNull(args.GetReturnValue());
615 return; 613 return;
616 } 614 }
617 615
618 FXJSE_Value_SetFloat(args.GetReturnValue(), 616 FXJSE_Value_SetFloat(args.GetReturnValue(),
(...skipping 12 matching lines...) Expand all
631 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); 629 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i);
632 if (FXJSE_Value_IsNull(argValue.get())) 630 if (FXJSE_Value_IsNull(argValue.get()))
633 continue; 631 continue;
634 632
635 if (FXJSE_Value_IsArray(argValue.get())) { 633 if (FXJSE_Value_IsArray(argValue.get())) {
636 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 634 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
637 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); 635 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get());
638 636
639 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); 637 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get());
640 if (iLength <= 2) { 638 if (iLength <= 2) {
641 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); 639 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
642 return; 640 return;
643 } 641 }
644 642
645 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 643 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
646 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 644 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
647 std::unique_ptr<CFXJSE_Value> newPropertyValue( 645 std::unique_ptr<CFXJSE_Value> newPropertyValue(
648 new CFXJSE_Value(pIsolate)); 646 new CFXJSE_Value(pIsolate));
649 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); 647 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get());
650 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); 648 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get());
651 if (FXJSE_Value_IsNull(propertyValue.get())) { 649 if (FXJSE_Value_IsNull(propertyValue.get())) {
(...skipping 29 matching lines...) Expand all
681 FXJSE_Value_SetInteger(args.GetReturnValue(), iCount); 679 FXJSE_Value_SetInteger(args.GetReturnValue(), iCount);
682 } 680 }
683 681
684 // static 682 // static
685 void CXFA_FM2JSContext::Floor(CFXJSE_Value* pThis, 683 void CXFA_FM2JSContext::Floor(CFXJSE_Value* pThis,
686 const CFX_ByteStringC& szFuncName, 684 const CFX_ByteStringC& szFuncName,
687 CFXJSE_Arguments& args) { 685 CFXJSE_Arguments& args) {
688 if (args.GetLength() != 1) { 686 if (args.GetLength() != 1) {
689 CXFA_FM2JSContext* pContext = 687 CXFA_FM2JSContext* pContext =
690 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 688 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
691 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 689 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Floor");
692 L"Floor");
693 return; 690 return;
694 } 691 }
695 692
696 std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, args, 0); 693 std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, args, 0);
697 if (ValueIsNull(pThis, argValue.get())) { 694 if (ValueIsNull(pThis, argValue.get())) {
698 FXJSE_Value_SetNull(args.GetReturnValue()); 695 FXJSE_Value_SetNull(args.GetReturnValue());
699 return; 696 return;
700 } 697 }
701 698
702 FXJSE_Value_SetFloat(args.GetReturnValue(), 699 FXJSE_Value_SetFloat(args.GetReturnValue(),
(...skipping 12 matching lines...) Expand all
715 for (int32_t i = 0; i < args.GetLength(); i++) { 712 for (int32_t i = 0; i < args.GetLength(); i++) {
716 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); 713 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i);
717 if (FXJSE_Value_IsNull(argValue.get())) 714 if (FXJSE_Value_IsNull(argValue.get()))
718 continue; 715 continue;
719 716
720 if (FXJSE_Value_IsArray(argValue.get())) { 717 if (FXJSE_Value_IsArray(argValue.get())) {
721 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 718 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
722 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); 719 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get());
723 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); 720 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get());
724 if (iLength <= 2) { 721 if (iLength <= 2) {
725 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); 722 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
726 return; 723 return;
727 } 724 }
728 725
729 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 726 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
730 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 727 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
731 std::unique_ptr<CFXJSE_Value> newPropertyValue( 728 std::unique_ptr<CFXJSE_Value> newPropertyValue(
732 new CFXJSE_Value(pIsolate)); 729 new CFXJSE_Value(pIsolate));
733 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); 730 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get());
734 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); 731 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get());
735 if (FXJSE_Value_IsNull(propertyValue.get())) { 732 if (FXJSE_Value_IsNull(propertyValue.get())) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 for (int32_t i = 0; i < args.GetLength(); i++) { 794 for (int32_t i = 0; i < args.GetLength(); i++) {
798 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); 795 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i);
799 if (FXJSE_Value_IsNull(argValue.get())) 796 if (FXJSE_Value_IsNull(argValue.get()))
800 continue; 797 continue;
801 798
802 if (FXJSE_Value_IsArray(argValue.get())) { 799 if (FXJSE_Value_IsArray(argValue.get())) {
803 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 800 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
804 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); 801 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get());
805 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); 802 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get());
806 if (iLength <= 2) { 803 if (iLength <= 2) {
807 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); 804 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
808 return; 805 return;
809 } 806 }
810 807
811 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 808 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
812 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 809 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
813 std::unique_ptr<CFXJSE_Value> newPropertyValue( 810 std::unique_ptr<CFXJSE_Value> newPropertyValue(
814 new CFXJSE_Value(pIsolate)); 811 new CFXJSE_Value(pIsolate));
815 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); 812 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get());
816 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); 813 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get());
817 if (FXJSE_Value_IsNull(propertyValue.get())) { 814 if (FXJSE_Value_IsNull(propertyValue.get())) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 FXJSE_Value_SetDouble(args.GetReturnValue(), dMinValue); 864 FXJSE_Value_SetDouble(args.GetReturnValue(), dMinValue);
868 } 865 }
869 866
870 // static 867 // static
871 void CXFA_FM2JSContext::Mod(CFXJSE_Value* pThis, 868 void CXFA_FM2JSContext::Mod(CFXJSE_Value* pThis,
872 const CFX_ByteStringC& szFuncName, 869 const CFX_ByteStringC& szFuncName,
873 CFXJSE_Arguments& args) { 870 CFXJSE_Arguments& args) {
874 CXFA_FM2JSContext* pContext = 871 CXFA_FM2JSContext* pContext =
875 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 872 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
876 if (args.GetLength() != 2) { 873 if (args.GetLength() != 2) {
877 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 874 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Mod");
878 L"Mod");
879 return; 875 return;
880 } 876 }
881 877
882 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 878 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
883 std::unique_ptr<CFXJSE_Value> argTwo = args.GetValue(1); 879 std::unique_ptr<CFXJSE_Value> argTwo = args.GetValue(1);
884 if (FXJSE_Value_IsNull(argOne.get()) || FXJSE_Value_IsNull(argTwo.get())) { 880 if (FXJSE_Value_IsNull(argOne.get()) || FXJSE_Value_IsNull(argTwo.get())) {
885 FXJSE_Value_SetNull(args.GetReturnValue()); 881 FXJSE_Value_SetNull(args.GetReturnValue());
886 return; 882 return;
887 } 883 }
888 884
889 bool argOneResult; 885 bool argOneResult;
890 FX_DOUBLE dDividend = ExtractDouble(pThis, argOne.get(), &argOneResult); 886 FX_DOUBLE dDividend = ExtractDouble(pThis, argOne.get(), &argOneResult);
891 bool argTwoResult; 887 bool argTwoResult;
892 FX_DOUBLE dDivisor = ExtractDouble(pThis, argTwo.get(), &argTwoResult); 888 FX_DOUBLE dDivisor = ExtractDouble(pThis, argTwo.get(), &argTwoResult);
893 if (!argOneResult || !argTwoResult) { 889 if (!argOneResult || !argTwoResult) {
894 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); 890 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
895 return; 891 return;
896 } 892 }
897 893
898 if (dDivisor == 0.0) { 894 if (dDivisor == 0.0) {
899 pContext->ThrowScriptErrorMessage(XFA_IDS_DIVIDE_ZERO); 895 pContext->ThrowException(XFA_IDS_DIVIDE_ZERO);
900 return; 896 return;
901 } 897 }
902 898
903 FXJSE_Value_SetDouble(args.GetReturnValue(), 899 FXJSE_Value_SetDouble(args.GetReturnValue(),
904 dDividend - dDivisor * (int32_t)(dDividend / dDivisor)); 900 dDividend - dDivisor * (int32_t)(dDividend / dDivisor));
905 } 901 }
906 902
907 // static 903 // static
908 void CXFA_FM2JSContext::Round(CFXJSE_Value* pThis, 904 void CXFA_FM2JSContext::Round(CFXJSE_Value* pThis,
909 const CFX_ByteStringC& szFuncName, 905 const CFX_ByteStringC& szFuncName,
910 CFXJSE_Arguments& args) { 906 CFXJSE_Arguments& args) {
911 CXFA_FM2JSContext* pContext = 907 CXFA_FM2JSContext* pContext =
912 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 908 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
913 int32_t argc = args.GetLength(); 909 int32_t argc = args.GetLength();
914 if (argc != 1 && argc != 2) { 910 if (argc != 1 && argc != 2) {
915 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 911 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Round");
916 L"Round");
917 return; 912 return;
918 } 913 }
919 914
920 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 915 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
921 if (FXJSE_Value_IsNull(argOne.get())) { 916 if (FXJSE_Value_IsNull(argOne.get())) {
922 FXJSE_Value_SetNull(args.GetReturnValue()); 917 FXJSE_Value_SetNull(args.GetReturnValue());
923 return; 918 return;
924 } 919 }
925 920
926 bool dValueRet; 921 bool dValueRet;
927 FX_DOUBLE dValue = ExtractDouble(pThis, argOne.get(), &dValueRet); 922 FX_DOUBLE dValue = ExtractDouble(pThis, argOne.get(), &dValueRet);
928 if (!dValueRet) { 923 if (!dValueRet) {
929 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); 924 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
930 return; 925 return;
931 } 926 }
932 927
933 uint8_t uPrecision = 0; 928 uint8_t uPrecision = 0;
934 if (argc == 2) { 929 if (argc == 2) {
935 std::unique_ptr<CFXJSE_Value> argTwo = args.GetValue(1); 930 std::unique_ptr<CFXJSE_Value> argTwo = args.GetValue(1);
936 if (FXJSE_Value_IsNull(argTwo.get())) { 931 if (FXJSE_Value_IsNull(argTwo.get())) {
937 FXJSE_Value_SetNull(args.GetReturnValue()); 932 FXJSE_Value_SetNull(args.GetReturnValue());
938 return; 933 return;
939 } 934 }
940 935
941 bool dPrecisionRet; 936 bool dPrecisionRet;
942 FX_DOUBLE dPrecision = ExtractDouble(pThis, argTwo.get(), &dPrecisionRet); 937 FX_DOUBLE dPrecision = ExtractDouble(pThis, argTwo.get(), &dPrecisionRet);
943 if (!dPrecisionRet) { 938 if (!dPrecisionRet) {
944 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); 939 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
945 return; 940 return;
946 } 941 }
947 942
948 uPrecision = 943 uPrecision =
949 static_cast<uint8_t>(std::min(std::max(dPrecision, 0.0), 12.0)); 944 static_cast<uint8_t>(std::min(std::max(dPrecision, 0.0), 12.0));
950 } 945 }
951 946
952 CFX_Decimal decimalValue((FX_FLOAT)dValue, uPrecision); 947 CFX_Decimal decimalValue((FX_FLOAT)dValue, uPrecision);
953 CFX_WideString wsValue = decimalValue; 948 CFX_WideString wsValue = decimalValue;
954 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 949 FXJSE_Value_SetUTF8String(args.GetReturnValue(),
(...skipping 18 matching lines...) Expand all
973 for (int32_t i = 0; i < argc; i++) { 968 for (int32_t i = 0; i < argc; i++) {
974 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); 969 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i);
975 if (FXJSE_Value_IsNull(argValue.get())) 970 if (FXJSE_Value_IsNull(argValue.get()))
976 continue; 971 continue;
977 972
978 if (FXJSE_Value_IsArray(argValue.get())) { 973 if (FXJSE_Value_IsArray(argValue.get())) {
979 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 974 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
980 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); 975 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get());
981 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); 976 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get());
982 if (iLength <= 2) { 977 if (iLength <= 2) {
983 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); 978 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
984 return; 979 return;
985 } 980 }
986 981
987 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 982 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
988 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); 983 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get());
989 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 984 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
990 std::unique_ptr<CFXJSE_Value> newPropertyValue( 985 std::unique_ptr<CFXJSE_Value> newPropertyValue(
991 new CFXJSE_Value(pIsolate)); 986 new CFXJSE_Value(pIsolate));
992 if (FXJSE_Value_IsNull(propertyValue.get())) { 987 if (FXJSE_Value_IsNull(propertyValue.get())) {
993 for (int32_t j = 2; j < iLength; j++) { 988 for (int32_t j = 2; j < iLength; j++) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum); 1033 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum);
1039 } 1034 }
1040 1035
1041 // static 1036 // static
1042 void CXFA_FM2JSContext::Date(CFXJSE_Value* pThis, 1037 void CXFA_FM2JSContext::Date(CFXJSE_Value* pThis,
1043 const CFX_ByteStringC& szFuncName, 1038 const CFX_ByteStringC& szFuncName,
1044 CFXJSE_Arguments& args) { 1039 CFXJSE_Arguments& args) {
1045 if (args.GetLength() != 0) { 1040 if (args.GetLength() != 0) {
1046 CXFA_FM2JSContext* pContext = 1041 CXFA_FM2JSContext* pContext =
1047 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1042 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
1048 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 1043 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Date");
1049 L"Date");
1050 return; 1044 return;
1051 } 1045 }
1052 1046
1053 time_t currentTime; 1047 time_t currentTime;
1054 time(&currentTime); 1048 time(&currentTime);
1055 struct tm* pTmStruct = gmtime(&currentTime); 1049 struct tm* pTmStruct = gmtime(&currentTime);
1056 1050
1057 CFX_ByteString bufferYear; 1051 CFX_ByteString bufferYear;
1058 CFX_ByteString bufferMon; 1052 CFX_ByteString bufferMon;
1059 CFX_ByteString bufferDay; 1053 CFX_ByteString bufferDay;
1060 bufferYear.Format("%d", pTmStruct->tm_year + 1900); 1054 bufferYear.Format("%d", pTmStruct->tm_year + 1900);
1061 bufferMon.Format("%02d", pTmStruct->tm_mon + 1); 1055 bufferMon.Format("%02d", pTmStruct->tm_mon + 1);
1062 bufferDay.Format("%02d", pTmStruct->tm_mday); 1056 bufferDay.Format("%02d", pTmStruct->tm_mday);
1063 1057
1064 CFX_ByteString bufferCurrent = bufferYear + bufferMon + bufferDay; 1058 CFX_ByteString bufferCurrent = bufferYear + bufferMon + bufferDay;
1065 FXJSE_Value_SetInteger(args.GetReturnValue(), 1059 FXJSE_Value_SetInteger(args.GetReturnValue(),
1066 DateString2Num(bufferCurrent.AsStringC())); 1060 DateString2Num(bufferCurrent.AsStringC()));
1067 } 1061 }
1068 1062
1069 // static 1063 // static
1070 void CXFA_FM2JSContext::Date2Num(CFXJSE_Value* pThis, 1064 void CXFA_FM2JSContext::Date2Num(CFXJSE_Value* pThis,
1071 const CFX_ByteStringC& szFuncName, 1065 const CFX_ByteStringC& szFuncName,
1072 CFXJSE_Arguments& args) { 1066 CFXJSE_Arguments& args) {
1073 int32_t argc = args.GetLength(); 1067 int32_t argc = args.GetLength();
1074 if (argc <= 0 || argc >= 4) { 1068 if (argc <= 0 || argc >= 4) {
1075 CXFA_FM2JSContext* pContext = 1069 CXFA_FM2JSContext* pContext =
1076 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1070 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
1077 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 1071 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Date2Num");
1078 L"Date2Num");
1079 return; 1072 return;
1080 } 1073 }
1081 1074
1082 std::unique_ptr<CFXJSE_Value> dateValue = GetSimpleValue(pThis, args, 0); 1075 std::unique_ptr<CFXJSE_Value> dateValue = GetSimpleValue(pThis, args, 0);
1083 if (ValueIsNull(pThis, dateValue.get())) { 1076 if (ValueIsNull(pThis, dateValue.get())) {
1084 FXJSE_Value_SetNull(args.GetReturnValue()); 1077 FXJSE_Value_SetNull(args.GetReturnValue());
1085 return; 1078 return;
1086 } 1079 }
1087 1080
1088 CFX_ByteString dateString; 1081 CFX_ByteString dateString;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 } 1113 }
1121 1114
1122 // static 1115 // static
1123 void CXFA_FM2JSContext::DateFmt(CFXJSE_Value* pThis, 1116 void CXFA_FM2JSContext::DateFmt(CFXJSE_Value* pThis,
1124 const CFX_ByteStringC& szFuncName, 1117 const CFX_ByteStringC& szFuncName,
1125 CFXJSE_Arguments& args) { 1118 CFXJSE_Arguments& args) {
1126 int32_t argc = args.GetLength(); 1119 int32_t argc = args.GetLength();
1127 if (argc >= 3) { 1120 if (argc >= 3) {
1128 CXFA_FM2JSContext* pContext = 1121 CXFA_FM2JSContext* pContext =
1129 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1122 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
1130 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 1123 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Date2Num");
1131 L"Date2Num");
1132 return; 1124 return;
1133 } 1125 }
1134 1126
1135 int32_t iStyle = 0; 1127 int32_t iStyle = 0;
1136 if (argc > 0) { 1128 if (argc > 0) {
1137 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0); 1129 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0);
1138 if (FXJSE_Value_IsNull(argStyle.get())) { 1130 if (FXJSE_Value_IsNull(argStyle.get())) {
1139 FXJSE_Value_SetNull(args.GetReturnValue()); 1131 FXJSE_Value_SetNull(args.GetReturnValue());
1140 return; 1132 return;
1141 } 1133 }
(...skipping 18 matching lines...) Expand all
1160 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); 1152 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC());
1161 } 1153 }
1162 1154
1163 // static 1155 // static
1164 void CXFA_FM2JSContext::IsoDate2Num(CFXJSE_Value* pThis, 1156 void CXFA_FM2JSContext::IsoDate2Num(CFXJSE_Value* pThis,
1165 const CFX_ByteStringC& szFuncName, 1157 const CFX_ByteStringC& szFuncName,
1166 CFXJSE_Arguments& args) { 1158 CFXJSE_Arguments& args) {
1167 if (args.GetLength() != 1) { 1159 if (args.GetLength() != 1) {
1168 CXFA_FM2JSContext* pContext = 1160 CXFA_FM2JSContext* pContext =
1169 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1161 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
1170 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 1162 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
1171 L"IsoDate2Num"); 1163 L"IsoDate2Num");
1172 return; 1164 return;
1173 } 1165 }
1174 1166
1175 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 1167 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
1176 if (FXJSE_Value_IsNull(argOne.get())) { 1168 if (FXJSE_Value_IsNull(argOne.get())) {
1177 FXJSE_Value_SetNull(args.GetReturnValue()); 1169 FXJSE_Value_SetNull(args.GetReturnValue());
1178 return; 1170 return;
1179 } 1171 }
1180 1172
1181 CFX_ByteString szArgString; 1173 CFX_ByteString szArgString;
1182 ValueToUTF8String(argOne.get(), szArgString); 1174 ValueToUTF8String(argOne.get(), szArgString);
1183 FXJSE_Value_SetInteger(args.GetReturnValue(), 1175 FXJSE_Value_SetInteger(args.GetReturnValue(),
1184 DateString2Num(szArgString.AsStringC())); 1176 DateString2Num(szArgString.AsStringC()));
1185 } 1177 }
1186 1178
1187 // static 1179 // static
1188 void CXFA_FM2JSContext::IsoTime2Num(CFXJSE_Value* pThis, 1180 void CXFA_FM2JSContext::IsoTime2Num(CFXJSE_Value* pThis,
1189 const CFX_ByteStringC& szFuncName, 1181 const CFX_ByteStringC& szFuncName,
1190 CFXJSE_Arguments& args) { 1182 CFXJSE_Arguments& args) {
1191 CXFA_FM2JSContext* pContext = 1183 CXFA_FM2JSContext* pContext =
1192 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1184 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
1193 if (args.GetLength() != 1) { 1185 if (args.GetLength() != 1) {
1194 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 1186 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
1195 L"IsoTime2Num"); 1187 L"IsoTime2Num");
1196 return; 1188 return;
1197 } 1189 }
1198 1190
1199 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 1191 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
1200 if (ValueIsNull(pThis, argOne.get())) { 1192 if (ValueIsNull(pThis, argOne.get())) {
1201 FXJSE_Value_SetNull(args.GetReturnValue()); 1193 FXJSE_Value_SetNull(args.GetReturnValue());
1202 return; 1194 return;
1203 } 1195 }
1204 1196
1205 CXFA_Document* pDoc = pContext->GetDocument(); 1197 CXFA_Document* pDoc = pContext->GetDocument();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 if (formatStr.IsEmpty()) { 1269 if (formatStr.IsEmpty()) {
1278 formatStr = ""; 1270 formatStr = "";
1279 } 1271 }
1280 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); 1272 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC());
1281 } else { 1273 } else {
1282 FXJSE_Value_SetNull(args.GetReturnValue()); 1274 FXJSE_Value_SetNull(args.GetReturnValue());
1283 } 1275 }
1284 } else { 1276 } else {
1285 CXFA_FM2JSContext* pContext = 1277 CXFA_FM2JSContext* pContext =
1286 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1278 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
1287 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 1279 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
1288 L"LocalDateFmt"); 1280 L"LocalDateFmt");
1289 } 1281 }
1290 } 1282 }
1291 1283
1292 // static 1284 // static
1293 void CXFA_FM2JSContext::LocalTimeFmt(CFXJSE_Value* pThis, 1285 void CXFA_FM2JSContext::LocalTimeFmt(CFXJSE_Value* pThis,
1294 const CFX_ByteStringC& szFuncName, 1286 const CFX_ByteStringC& szFuncName,
1295 CFXJSE_Arguments& args) { 1287 CFXJSE_Arguments& args) {
1296 int32_t argc = args.GetLength(); 1288 int32_t argc = args.GetLength();
1297 if (argc < 3) { 1289 if (argc < 3) {
1298 FX_BOOL bFlags = FALSE; 1290 FX_BOOL bFlags = FALSE;
(...skipping 23 matching lines...) Expand all
1322 if (formatStr.IsEmpty()) { 1314 if (formatStr.IsEmpty()) {
1323 formatStr = ""; 1315 formatStr = "";
1324 } 1316 }
1325 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); 1317 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC());
1326 } else { 1318 } else {
1327 FXJSE_Value_SetNull(args.GetReturnValue()); 1319 FXJSE_Value_SetNull(args.GetReturnValue());
1328 } 1320 }
1329 } else { 1321 } else {
1330 CXFA_FM2JSContext* pContext = 1322 CXFA_FM2JSContext* pContext =
1331 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1323 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
1332 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 1324 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
1333 L"LocalTimeFmt"); 1325 L"LocalTimeFmt");
1334 } 1326 }
1335 } 1327 }
1336 1328
1337 // static 1329 // static
1338 void CXFA_FM2JSContext::Num2Date(CFXJSE_Value* pThis, 1330 void CXFA_FM2JSContext::Num2Date(CFXJSE_Value* pThis,
1339 const CFX_ByteStringC& szFuncName, 1331 const CFX_ByteStringC& szFuncName,
1340 CFXJSE_Arguments& args) { 1332 CFXJSE_Arguments& args) {
1341 int32_t argc = args.GetLength(); 1333 int32_t argc = args.GetLength();
1342 if ((argc > 0) && (argc < 4)) { 1334 if ((argc > 0) && (argc < 4)) {
1343 FX_BOOL bFlags = FALSE; 1335 FX_BOOL bFlags = FALSE;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1471 szLocalDateString = ""; 1463 szLocalDateString = "";
1472 } 1464 }
1473 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 1465 FXJSE_Value_SetUTF8String(args.GetReturnValue(),
1474 szLocalDateString.AsStringC()); 1466 szLocalDateString.AsStringC());
1475 } else { 1467 } else {
1476 FXJSE_Value_SetNull(args.GetReturnValue()); 1468 FXJSE_Value_SetNull(args.GetReturnValue());
1477 } 1469 }
1478 } else { 1470 } else {
1479 CXFA_FM2JSContext* pContext = 1471 CXFA_FM2JSContext* pContext =
1480 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1472 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
1481 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 1473 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2Date");
1482 L"Num2Date");
1483 } 1474 }
1484 } 1475 }
1485 1476
1486 // static 1477 // static
1487 void CXFA_FM2JSContext::Num2GMTime(CFXJSE_Value* pThis, 1478 void CXFA_FM2JSContext::Num2GMTime(CFXJSE_Value* pThis,
1488 const CFX_ByteStringC& szFuncName, 1479 const CFX_ByteStringC& szFuncName,
1489 CFXJSE_Arguments& args) { 1480 CFXJSE_Arguments& args) {
1490 int32_t argc = args.GetLength(); 1481 int32_t argc = args.GetLength();
1491 if ((argc > 0) && (argc < 4)) { 1482 if ((argc > 0) && (argc < 4)) {
1492 FX_BOOL bFlags = FALSE; 1483 FX_BOOL bFlags = FALSE;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 szGMTTimeString = ""; 1518 szGMTTimeString = "";
1528 } 1519 }
1529 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 1520 FXJSE_Value_SetUTF8String(args.GetReturnValue(),
1530 szGMTTimeString.AsStringC()); 1521 szGMTTimeString.AsStringC());
1531 } else { 1522 } else {
1532 FXJSE_Value_SetNull(args.GetReturnValue()); 1523 FXJSE_Value_SetNull(args.GetReturnValue());
1533 } 1524 }
1534 } else { 1525 } else {
1535 CXFA_FM2JSContext* pContext = 1526 CXFA_FM2JSContext* pContext =
1536 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1527 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
1537 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 1528 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2GMTime");
1538 L"Num2GMTime");
1539 } 1529 }
1540 } 1530 }
1541 1531
1542 // static 1532 // static
1543 void CXFA_FM2JSContext::Num2Time(CFXJSE_Value* pThis, 1533 void CXFA_FM2JSContext::Num2Time(CFXJSE_Value* pThis,
1544 const CFX_ByteStringC& szFuncName, 1534 const CFX_ByteStringC& szFuncName,
1545 CFXJSE_Arguments& args) { 1535 CFXJSE_Arguments& args) {
1546 int32_t argc = args.GetLength(); 1536 int32_t argc = args.GetLength();
1547 if ((argc > 0) && (argc < 4)) { 1537 if ((argc > 0) && (argc < 4)) {
1548 FX_BOOL bFlags = FALSE; 1538 FX_BOOL bFlags = FALSE;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 szLocalTimeString = ""; 1573 szLocalTimeString = "";
1584 } 1574 }
1585 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 1575 FXJSE_Value_SetUTF8String(args.GetReturnValue(),
1586 szLocalTimeString.AsStringC()); 1576 szLocalTimeString.AsStringC());
1587 } else { 1577 } else {
1588 FXJSE_Value_SetNull(args.GetReturnValue()); 1578 FXJSE_Value_SetNull(args.GetReturnValue());
1589 } 1579 }
1590 } else { 1580 } else {
1591 CXFA_FM2JSContext* pContext = 1581 CXFA_FM2JSContext* pContext =
1592 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1582 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
1593 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 1583 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2Time");
1594 L"Num2Time");
1595 } 1584 }
1596 } 1585 }
1597 1586
1598 // static 1587 // static
1599 void CXFA_FM2JSContext::Time(CFXJSE_Value* pThis, 1588 void CXFA_FM2JSContext::Time(CFXJSE_Value* pThis,
1600 const CFX_ByteStringC& szFuncName, 1589 const CFX_ByteStringC& szFuncName,
1601 CFXJSE_Arguments& args) { 1590 CFXJSE_Arguments& args) {
1602 if (args.GetLength() == 0) { 1591 if (args.GetLength() == 0) {
1603 time_t now; 1592 time_t now;
1604 time(&now); 1593 time(&now);
1605 struct tm* pGmt = gmtime(&now); 1594 struct tm* pGmt = gmtime(&now);
1606 int32_t iGMHour = pGmt->tm_hour; 1595 int32_t iGMHour = pGmt->tm_hour;
1607 int32_t iGMMin = pGmt->tm_min; 1596 int32_t iGMMin = pGmt->tm_min;
1608 int32_t iGMSec = pGmt->tm_sec; 1597 int32_t iGMSec = pGmt->tm_sec;
1609 FXJSE_Value_SetInteger(args.GetReturnValue(), 1598 FXJSE_Value_SetInteger(args.GetReturnValue(),
1610 ((iGMHour * 3600 + iGMMin * 60 + iGMSec) * 1000)); 1599 ((iGMHour * 3600 + iGMMin * 60 + iGMSec) * 1000));
1611 } else { 1600 } else {
1612 CXFA_FM2JSContext* pContext = 1601 CXFA_FM2JSContext* pContext =
1613 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1602 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
1614 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 1603 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Time");
1615 L"Time");
1616 } 1604 }
1617 } 1605 }
1618 1606
1619 // static 1607 // static
1620 void CXFA_FM2JSContext::Time2Num(CFXJSE_Value* pThis, 1608 void CXFA_FM2JSContext::Time2Num(CFXJSE_Value* pThis,
1621 const CFX_ByteStringC& szFuncName, 1609 const CFX_ByteStringC& szFuncName,
1622 CFXJSE_Arguments& args) { 1610 CFXJSE_Arguments& args) {
1623 int32_t argc = args.GetLength(); 1611 int32_t argc = args.GetLength();
1624 if ((argc > 0) && (argc < 4)) { 1612 if ((argc > 0) && (argc < 4)) {
1625 FX_BOOL bFlags = FALSE; 1613 FX_BOOL bFlags = FALSE;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 FXJSE_Value_SetInteger(args.GetReturnValue(), iResult); 1690 FXJSE_Value_SetInteger(args.GetReturnValue(), iResult);
1703 } else { 1691 } else {
1704 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); 1692 FXJSE_Value_SetInteger(args.GetReturnValue(), 0);
1705 } 1693 }
1706 } else { 1694 } else {
1707 FXJSE_Value_SetNull(args.GetReturnValue()); 1695 FXJSE_Value_SetNull(args.GetReturnValue());
1708 } 1696 }
1709 } else { 1697 } else {
1710 CXFA_FM2JSContext* pContext = 1698 CXFA_FM2JSContext* pContext =
1711 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1699 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
1712 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 1700 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Time2Num");
1713 L"Time2Num");
1714 } 1701 }
1715 } 1702 }
1716 1703
1717 // static 1704 // static
1718 void CXFA_FM2JSContext::TimeFmt(CFXJSE_Value* pThis, 1705 void CXFA_FM2JSContext::TimeFmt(CFXJSE_Value* pThis,
1719 const CFX_ByteStringC& szFuncName, 1706 const CFX_ByteStringC& szFuncName,
1720 CFXJSE_Arguments& args) { 1707 CFXJSE_Arguments& args) {
1721 int32_t argc = args.GetLength(); 1708 int32_t argc = args.GetLength();
1722 if (argc < 3) { 1709 if (argc < 3) {
1723 FX_BOOL bFlags = FALSE; 1710 FX_BOOL bFlags = FALSE;
(...skipping 23 matching lines...) Expand all
1747 if (formatStr.IsEmpty()) { 1734 if (formatStr.IsEmpty()) {
1748 formatStr = ""; 1735 formatStr = "";
1749 } 1736 }
1750 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); 1737 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC());
1751 } else { 1738 } else {
1752 FXJSE_Value_SetNull(args.GetReturnValue()); 1739 FXJSE_Value_SetNull(args.GetReturnValue());
1753 } 1740 }
1754 } else { 1741 } else {
1755 CXFA_FM2JSContext* pContext = 1742 CXFA_FM2JSContext* pContext =
1756 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1743 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
1757 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 1744 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"TimeFmt");
1758 L"TimeFmt");
1759 } 1745 }
1760 } 1746 }
1761 1747
1762 // static 1748 // static
1763 FX_BOOL CXFA_FM2JSContext::IsIsoDateFormat(const FX_CHAR* pData, 1749 FX_BOOL CXFA_FM2JSContext::IsIsoDateFormat(const FX_CHAR* pData,
1764 int32_t iLength, 1750 int32_t iLength,
1765 int32_t& iStyle, 1751 int32_t& iStyle,
1766 int32_t& iYear, 1752 int32_t& iYear,
1767 int32_t& iMonth, 1753 int32_t& iMonth,
1768 int32_t& iDay) { 1754 int32_t& iDay) {
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
2563 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || 2549 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) ||
2564 ValueIsNull(pThis, argThree.get())); 2550 ValueIsNull(pThis, argThree.get()));
2565 if (bFlags) { 2551 if (bFlags) {
2566 FXJSE_Value_SetNull(args.GetReturnValue()); 2552 FXJSE_Value_SetNull(args.GetReturnValue());
2567 } else { 2553 } else {
2568 nPrincipal = ValueToDouble(pThis, argOne.get()); 2554 nPrincipal = ValueToDouble(pThis, argOne.get());
2569 nPayment = ValueToDouble(pThis, argTwo.get()); 2555 nPayment = ValueToDouble(pThis, argTwo.get());
2570 nPeriods = ValueToDouble(pThis, argThree.get()); 2556 nPeriods = ValueToDouble(pThis, argThree.get());
2571 bFlags = ((nPrincipal <= 0) || (nPayment <= 0) || (nPeriods <= 0)); 2557 bFlags = ((nPrincipal <= 0) || (nPayment <= 0) || (nPeriods <= 0));
2572 if (bFlags) { 2558 if (bFlags) {
2573 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); 2559 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
2574 } else { 2560 } else {
2575 FX_DOUBLE r = 2561 FX_DOUBLE r =
2576 2 * (nPeriods * nPayment - nPrincipal) / (nPeriods * nPrincipal); 2562 2 * (nPeriods * nPayment - nPrincipal) / (nPeriods * nPrincipal);
2577 FX_DOUBLE nTemp = 1; 2563 FX_DOUBLE nTemp = 1;
2578 for (int32_t i = 0; i < nPeriods; ++i) { 2564 for (int32_t i = 0; i < nPeriods; ++i) {
2579 nTemp *= (1 + r); 2565 nTemp *= (1 + r);
2580 } 2566 }
2581 FX_DOUBLE nRet = r * nTemp / (nTemp - 1) - nPayment / nPrincipal; 2567 FX_DOUBLE nRet = r * nTemp / (nTemp - 1) - nPayment / nPrincipal;
2582 while (fabs(nRet) > kFinancialPrecision && !bFlags) { 2568 while (fabs(nRet) > kFinancialPrecision && !bFlags) {
2583 FX_DOUBLE nDerivative = 0; 2569 FX_DOUBLE nDerivative = 0;
(...skipping 14 matching lines...) Expand all
2598 } 2584 }
2599 if (bFlags) { 2585 if (bFlags) {
2600 FXJSE_Value_SetNull(args.GetReturnValue()); 2586 FXJSE_Value_SetNull(args.GetReturnValue());
2601 } else { 2587 } else {
2602 r = r * 12; 2588 r = r * 12;
2603 FXJSE_Value_SetDouble(args.GetReturnValue(), r); 2589 FXJSE_Value_SetDouble(args.GetReturnValue(), r);
2604 } 2590 }
2605 } 2591 }
2606 } 2592 }
2607 } else { 2593 } else {
2608 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 2594 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Apr");
2609 L"Apr");
2610 } 2595 }
2611 } 2596 }
2612 2597
2613 // static 2598 // static
2614 void CXFA_FM2JSContext::CTerm(CFXJSE_Value* pThis, 2599 void CXFA_FM2JSContext::CTerm(CFXJSE_Value* pThis,
2615 const CFX_ByteStringC& szFuncName, 2600 const CFX_ByteStringC& szFuncName,
2616 CFXJSE_Arguments& args) { 2601 CFXJSE_Arguments& args) {
2617 CXFA_FM2JSContext* pContext = 2602 CXFA_FM2JSContext* pContext =
2618 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 2603 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
2619 if (args.GetLength() == 3) { 2604 if (args.GetLength() == 3) {
2620 FX_BOOL bFlags = FALSE; 2605 FX_BOOL bFlags = FALSE;
2621 FX_FLOAT nRate = 0; 2606 FX_FLOAT nRate = 0;
2622 FX_FLOAT nFutureValue = 0; 2607 FX_FLOAT nFutureValue = 0;
2623 FX_FLOAT nInitAmount = 0; 2608 FX_FLOAT nInitAmount = 0;
2624 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2609 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
2625 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 2610 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
2626 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 2611 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
2627 bFlags = 2612 bFlags =
2628 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || 2613 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) ||
2629 ValueIsNull(pThis, argThree.get())); 2614 ValueIsNull(pThis, argThree.get()));
2630 if (bFlags) { 2615 if (bFlags) {
2631 FXJSE_Value_SetNull(args.GetReturnValue()); 2616 FXJSE_Value_SetNull(args.GetReturnValue());
2632 } else { 2617 } else {
2633 nRate = ValueToFloat(pThis, argOne.get()); 2618 nRate = ValueToFloat(pThis, argOne.get());
2634 nFutureValue = ValueToFloat(pThis, argTwo.get()); 2619 nFutureValue = ValueToFloat(pThis, argTwo.get());
2635 nInitAmount = ValueToFloat(pThis, argThree.get()); 2620 nInitAmount = ValueToFloat(pThis, argThree.get());
2636 bFlags = ((nRate <= 0) || (nFutureValue <= 0) || (nInitAmount <= 0)); 2621 bFlags = ((nRate <= 0) || (nFutureValue <= 0) || (nInitAmount <= 0));
2637 if (bFlags) { 2622 if (bFlags) {
2638 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); 2623 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
2639 } else { 2624 } else {
2640 FXJSE_Value_SetFloat(args.GetReturnValue(), 2625 FXJSE_Value_SetFloat(args.GetReturnValue(),
2641 FXSYS_log((FX_FLOAT)(nFutureValue / nInitAmount)) / 2626 FXSYS_log((FX_FLOAT)(nFutureValue / nInitAmount)) /
2642 FXSYS_log((FX_FLOAT)(1 + nRate))); 2627 FXSYS_log((FX_FLOAT)(1 + nRate)));
2643 } 2628 }
2644 } 2629 }
2645 } else { 2630 } else {
2646 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 2631 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"CTerm");
2647 L"CTerm");
2648 } 2632 }
2649 } 2633 }
2650 2634
2651 // static 2635 // static
2652 void CXFA_FM2JSContext::FV(CFXJSE_Value* pThis, 2636 void CXFA_FM2JSContext::FV(CFXJSE_Value* pThis,
2653 const CFX_ByteStringC& szFuncName, 2637 const CFX_ByteStringC& szFuncName,
2654 CFXJSE_Arguments& args) { 2638 CFXJSE_Arguments& args) {
2655 CXFA_FM2JSContext* pContext = 2639 CXFA_FM2JSContext* pContext =
2656 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 2640 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
2657 if (args.GetLength() == 3) { 2641 if (args.GetLength() == 3) {
2658 FX_BOOL bFlags = FALSE; 2642 FX_BOOL bFlags = FALSE;
2659 FX_DOUBLE nAmount = 0; 2643 FX_DOUBLE nAmount = 0;
2660 FX_DOUBLE nRate = 0; 2644 FX_DOUBLE nRate = 0;
2661 FX_DOUBLE nPeriod = 0; 2645 FX_DOUBLE nPeriod = 0;
2662 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2646 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
2663 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 2647 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
2664 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 2648 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
2665 bFlags = 2649 bFlags =
2666 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || 2650 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) ||
2667 ValueIsNull(pThis, argThree.get())); 2651 ValueIsNull(pThis, argThree.get()));
2668 if (bFlags) { 2652 if (bFlags) {
2669 FXJSE_Value_SetNull(args.GetReturnValue()); 2653 FXJSE_Value_SetNull(args.GetReturnValue());
2670 } else { 2654 } else {
2671 nAmount = ValueToDouble(pThis, argOne.get()); 2655 nAmount = ValueToDouble(pThis, argOne.get());
2672 nRate = ValueToDouble(pThis, argTwo.get()); 2656 nRate = ValueToDouble(pThis, argTwo.get());
2673 nPeriod = ValueToDouble(pThis, argThree.get()); 2657 nPeriod = ValueToDouble(pThis, argThree.get());
2674 bFlags = ((nRate < 0) || (nPeriod <= 0) || (nAmount <= 0)); 2658 bFlags = ((nRate < 0) || (nPeriod <= 0) || (nAmount <= 0));
2675 if (bFlags) { 2659 if (bFlags) {
2676 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); 2660 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
2677 } else { 2661 } else {
2678 FX_DOUBLE dResult = 0; 2662 FX_DOUBLE dResult = 0;
2679 if (!nRate) { 2663 if (!nRate) {
2680 dResult = nAmount * nPeriod; 2664 dResult = nAmount * nPeriod;
2681 } else { 2665 } else {
2682 FX_DOUBLE nTemp = 1; 2666 FX_DOUBLE nTemp = 1;
2683 for (int i = 0; i < nPeriod; ++i) { 2667 for (int i = 0; i < nPeriod; ++i) {
2684 nTemp *= 1 + nRate; 2668 nTemp *= 1 + nRate;
2685 } 2669 }
2686 dResult = nAmount * (nTemp - 1) / nRate; 2670 dResult = nAmount * (nTemp - 1) / nRate;
2687 } 2671 }
2688 FXJSE_Value_SetDouble(args.GetReturnValue(), dResult); 2672 FXJSE_Value_SetDouble(args.GetReturnValue(), dResult);
2689 } 2673 }
2690 } 2674 }
2691 } else { 2675 } else {
2692 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 2676 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"FV");
2693 L"FV");
2694 } 2677 }
2695 } 2678 }
2696 2679
2697 // static 2680 // static
2698 void CXFA_FM2JSContext::IPmt(CFXJSE_Value* pThis, 2681 void CXFA_FM2JSContext::IPmt(CFXJSE_Value* pThis,
2699 const CFX_ByteStringC& szFuncName, 2682 const CFX_ByteStringC& szFuncName,
2700 CFXJSE_Arguments& args) { 2683 CFXJSE_Arguments& args) {
2701 CXFA_FM2JSContext* pContext = 2684 CXFA_FM2JSContext* pContext =
2702 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 2685 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
2703 if (args.GetLength() == 5) { 2686 if (args.GetLength() == 5) {
(...skipping 17 matching lines...) Expand all
2721 FXJSE_Value_SetNull(args.GetReturnValue()); 2704 FXJSE_Value_SetNull(args.GetReturnValue());
2722 } else { 2705 } else {
2723 nPrincpalAmount = ValueToFloat(pThis, argOne.get()); 2706 nPrincpalAmount = ValueToFloat(pThis, argOne.get());
2724 nRate = ValueToFloat(pThis, argTwo.get()); 2707 nRate = ValueToFloat(pThis, argTwo.get());
2725 nPayment = ValueToFloat(pThis, argThree.get()); 2708 nPayment = ValueToFloat(pThis, argThree.get());
2726 nFirstMonth = ValueToFloat(pThis, argFour.get()); 2709 nFirstMonth = ValueToFloat(pThis, argFour.get());
2727 nNumberOfMonths = ValueToFloat(pThis, argFive.get()); 2710 nNumberOfMonths = ValueToFloat(pThis, argFive.get());
2728 bFlags = ((nPrincpalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) || 2711 bFlags = ((nPrincpalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) ||
2729 (nFirstMonth < 0) || (nNumberOfMonths < 0)); 2712 (nFirstMonth < 0) || (nNumberOfMonths < 0));
2730 if (bFlags) { 2713 if (bFlags) {
2731 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); 2714 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
2732 } else { 2715 } else {
2733 FX_FLOAT fResult = 0; 2716 FX_FLOAT fResult = 0;
2734 FX_FLOAT nRateOfMonth = nRate / 12; 2717 FX_FLOAT nRateOfMonth = nRate / 12;
2735 int32_t iNums = 2718 int32_t iNums =
2736 (int32_t)((FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount)) - 2719 (int32_t)((FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount)) -
2737 FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount - 2720 FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount -
2738 nRateOfMonth))) / 2721 nRateOfMonth))) /
2739 FXSYS_log10((FX_FLOAT)(1 + nRateOfMonth))); 2722 FXSYS_log10((FX_FLOAT)(1 + nRateOfMonth)));
2740 int32_t iEnd = (int32_t)(nFirstMonth + nNumberOfMonths - 1); 2723 int32_t iEnd = (int32_t)(nFirstMonth + nNumberOfMonths - 1);
2741 if (iEnd > iNums) { 2724 if (iEnd > iNums) {
(...skipping 12 matching lines...) Expand all
2754 for (; i < iEnd; ++i) { 2737 for (; i < iEnd; ++i) {
2755 nSum += nPrincpalAmount * nRateOfMonth; 2738 nSum += nPrincpalAmount * nRateOfMonth;
2756 nPrincpalAmount -= nPayment - nPrincpalAmount * nRateOfMonth; 2739 nPrincpalAmount -= nPayment - nPrincpalAmount * nRateOfMonth;
2757 } 2740 }
2758 fResult = nSum; 2741 fResult = nSum;
2759 } 2742 }
2760 FXJSE_Value_SetFloat(args.GetReturnValue(), fResult); 2743 FXJSE_Value_SetFloat(args.GetReturnValue(), fResult);
2761 } 2744 }
2762 } 2745 }
2763 } else { 2746 } else {
2764 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 2747 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"IPmt");
2765 L"IPmt");
2766 } 2748 }
2767 } 2749 }
2768 2750
2769 // static 2751 // static
2770 void CXFA_FM2JSContext::NPV(CFXJSE_Value* pThis, 2752 void CXFA_FM2JSContext::NPV(CFXJSE_Value* pThis,
2771 const CFX_ByteStringC& szFuncName, 2753 const CFX_ByteStringC& szFuncName,
2772 CFXJSE_Arguments& args) { 2754 CFXJSE_Arguments& args) {
2773 CXFA_FM2JSContext* pContext = 2755 CXFA_FM2JSContext* pContext =
2774 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 2756 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
2775 int32_t argc = args.GetLength(); 2757 int32_t argc = args.GetLength();
2776 if (argc > 2) { 2758 if (argc > 2) {
2777 FX_BOOL bFlags = FALSE; 2759 FX_BOOL bFlags = FALSE;
2778 std::vector<std::unique_ptr<CFXJSE_Value>> argValues; 2760 std::vector<std::unique_ptr<CFXJSE_Value>> argValues;
2779 for (int32_t i = 0; i < argc; i++) { 2761 for (int32_t i = 0; i < argc; i++) {
2780 argValues.push_back(GetSimpleValue(pThis, args, i)); 2762 argValues.push_back(GetSimpleValue(pThis, args, i));
2781 if (ValueIsNull(pThis, argValues[i].get())) { 2763 if (ValueIsNull(pThis, argValues[i].get())) {
2782 bFlags = TRUE; 2764 bFlags = TRUE;
2783 } 2765 }
2784 } 2766 }
2785 if (!bFlags && argc > 0) { 2767 if (!bFlags && argc > 0) {
2786 FX_DOUBLE nRate = 0; 2768 FX_DOUBLE nRate = 0;
2787 nRate = ValueToDouble(pThis, argValues[0].get()); 2769 nRate = ValueToDouble(pThis, argValues[0].get());
2788 if (nRate <= 0) { 2770 if (nRate <= 0) {
2789 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); 2771 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
2790 } else { 2772 } else {
2791 FX_DOUBLE* pData = FX_Alloc(FX_DOUBLE, argc - 1); 2773 FX_DOUBLE* pData = FX_Alloc(FX_DOUBLE, argc - 1);
2792 for (int32_t i = 1; i < argc; i++) { 2774 for (int32_t i = 1; i < argc; i++) {
2793 pData[i - 1] = ValueToDouble(pThis, argValues[i].get()); 2775 pData[i - 1] = ValueToDouble(pThis, argValues[i].get());
2794 } 2776 }
2795 FX_DOUBLE nSum = 0; 2777 FX_DOUBLE nSum = 0;
2796 int32_t iIndex = 0; 2778 int32_t iIndex = 0;
2797 for (int32_t i = 0; i < argc - 1; i++) { 2779 for (int32_t i = 0; i < argc - 1; i++) {
2798 FX_DOUBLE nTemp = 1; 2780 FX_DOUBLE nTemp = 1;
2799 for (int32_t j = 0; j <= i; j++) { 2781 for (int32_t j = 0; j <= i; j++) {
2800 nTemp *= 1 + nRate; 2782 nTemp *= 1 + nRate;
2801 } 2783 }
2802 FX_DOUBLE nNum = *(pData + iIndex++); 2784 FX_DOUBLE nNum = *(pData + iIndex++);
2803 nSum += nNum / nTemp; 2785 nSum += nNum / nTemp;
2804 } 2786 }
2805 FXJSE_Value_SetDouble(args.GetReturnValue(), nSum); 2787 FXJSE_Value_SetDouble(args.GetReturnValue(), nSum);
2806 FX_Free(pData); 2788 FX_Free(pData);
2807 pData = 0; 2789 pData = 0;
2808 } 2790 }
2809 } else { 2791 } else {
2810 FXJSE_Value_SetNull(args.GetReturnValue()); 2792 FXJSE_Value_SetNull(args.GetReturnValue());
2811 } 2793 }
2812 } else { 2794 } else {
2813 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 2795 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"NPV");
2814 L"NPV");
2815 } 2796 }
2816 } 2797 }
2817 2798
2818 // static 2799 // static
2819 void CXFA_FM2JSContext::Pmt(CFXJSE_Value* pThis, 2800 void CXFA_FM2JSContext::Pmt(CFXJSE_Value* pThis,
2820 const CFX_ByteStringC& szFuncName, 2801 const CFX_ByteStringC& szFuncName,
2821 CFXJSE_Arguments& args) { 2802 CFXJSE_Arguments& args) {
2822 CXFA_FM2JSContext* pContext = 2803 CXFA_FM2JSContext* pContext =
2823 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 2804 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
2824 if (args.GetLength() == 3) { 2805 if (args.GetLength() == 3) {
2825 FX_BOOL bFlags = FALSE; 2806 FX_BOOL bFlags = FALSE;
2826 FX_FLOAT nPrincipal = 0; 2807 FX_FLOAT nPrincipal = 0;
2827 FX_FLOAT nRate = 0; 2808 FX_FLOAT nRate = 0;
2828 FX_FLOAT nPeriods = 0; 2809 FX_FLOAT nPeriods = 0;
2829 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2810 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
2830 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 2811 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
2831 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 2812 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
2832 bFlags = 2813 bFlags =
2833 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || 2814 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) ||
2834 ValueIsNull(pThis, argThree.get())); 2815 ValueIsNull(pThis, argThree.get()));
2835 if (bFlags) { 2816 if (bFlags) {
2836 FXJSE_Value_SetNull(args.GetReturnValue()); 2817 FXJSE_Value_SetNull(args.GetReturnValue());
2837 } else { 2818 } else {
2838 nPrincipal = ValueToFloat(pThis, argOne.get()); 2819 nPrincipal = ValueToFloat(pThis, argOne.get());
2839 nRate = ValueToFloat(pThis, argTwo.get()); 2820 nRate = ValueToFloat(pThis, argTwo.get());
2840 nPeriods = ValueToFloat(pThis, argThree.get()); 2821 nPeriods = ValueToFloat(pThis, argThree.get());
2841 bFlags = ((nPrincipal <= 0) || (nRate <= 0) || (nPeriods <= 0)); 2822 bFlags = ((nPrincipal <= 0) || (nRate <= 0) || (nPeriods <= 0));
2842 if (bFlags) { 2823 if (bFlags) {
2843 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); 2824 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
2844 } else { 2825 } else {
2845 FX_FLOAT nSum = 0; 2826 FX_FLOAT nSum = 0;
2846 FX_FLOAT nTmp = 1 + nRate; 2827 FX_FLOAT nTmp = 1 + nRate;
2847 nSum = nTmp; 2828 nSum = nTmp;
2848 for (int32_t i = 0; i < nPeriods - 1; ++i) { 2829 for (int32_t i = 0; i < nPeriods - 1; ++i) {
2849 nSum *= nTmp; 2830 nSum *= nTmp;
2850 } 2831 }
2851 FXJSE_Value_SetFloat(args.GetReturnValue(), 2832 FXJSE_Value_SetFloat(args.GetReturnValue(),
2852 (nPrincipal * nRate * nSum) / (nSum - 1)); 2833 (nPrincipal * nRate * nSum) / (nSum - 1));
2853 } 2834 }
2854 } 2835 }
2855 } else { 2836 } else {
2856 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 2837 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Pmt");
2857 L"Pmt");
2858 } 2838 }
2859 } 2839 }
2860 2840
2861 // static 2841 // static
2862 void CXFA_FM2JSContext::PPmt(CFXJSE_Value* pThis, 2842 void CXFA_FM2JSContext::PPmt(CFXJSE_Value* pThis,
2863 const CFX_ByteStringC& szFuncName, 2843 const CFX_ByteStringC& szFuncName,
2864 CFXJSE_Arguments& args) { 2844 CFXJSE_Arguments& args) {
2865 CXFA_FM2JSContext* pContext = 2845 CXFA_FM2JSContext* pContext =
2866 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 2846 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
2867 if (args.GetLength() == 5) { 2847 if (args.GetLength() == 5) {
(...skipping 17 matching lines...) Expand all
2885 FXJSE_Value_SetNull(args.GetReturnValue()); 2865 FXJSE_Value_SetNull(args.GetReturnValue());
2886 } else { 2866 } else {
2887 nPrincpalAmount = ValueToFloat(pThis, argOne.get()); 2867 nPrincpalAmount = ValueToFloat(pThis, argOne.get());
2888 nRate = ValueToFloat(pThis, argTwo.get()); 2868 nRate = ValueToFloat(pThis, argTwo.get());
2889 nPayment = ValueToFloat(pThis, argThree.get()); 2869 nPayment = ValueToFloat(pThis, argThree.get());
2890 nFirstMonth = ValueToFloat(pThis, argFour.get()); 2870 nFirstMonth = ValueToFloat(pThis, argFour.get());
2891 nNumberOfMonths = ValueToFloat(pThis, argFive.get()); 2871 nNumberOfMonths = ValueToFloat(pThis, argFive.get());
2892 bFlags = ((nPrincpalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) || 2872 bFlags = ((nPrincpalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) ||
2893 (nFirstMonth < 0) || (nNumberOfMonths < 0)); 2873 (nFirstMonth < 0) || (nNumberOfMonths < 0));
2894 if (bFlags) { 2874 if (bFlags) {
2895 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); 2875 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
2896 } else { 2876 } else {
2897 int32_t iEnd = (int32_t)(nFirstMonth + nNumberOfMonths - 1); 2877 int32_t iEnd = (int32_t)(nFirstMonth + nNumberOfMonths - 1);
2898 FX_FLOAT nSum = 0; 2878 FX_FLOAT nSum = 0;
2899 FX_FLOAT nRateOfMonth = nRate / 12; 2879 FX_FLOAT nRateOfMonth = nRate / 12;
2900 int32_t iNums = 2880 int32_t iNums =
2901 (int32_t)((FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount)) - 2881 (int32_t)((FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount)) -
2902 FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount - 2882 FXSYS_log10((FX_FLOAT)(nPayment / nPrincpalAmount -
2903 nRateOfMonth))) / 2883 nRateOfMonth))) /
2904 FXSYS_log10((FX_FLOAT)(1 + nRateOfMonth))); 2884 FXSYS_log10((FX_FLOAT)(1 + nRateOfMonth)));
2905 if (iEnd > iNums) { 2885 if (iEnd > iNums) {
2906 iEnd = iNums; 2886 iEnd = iNums;
2907 } 2887 }
2908 if (nPayment < nPrincpalAmount * nRateOfMonth) { 2888 if (nPayment < nPrincpalAmount * nRateOfMonth) {
2909 bFlags = TRUE; 2889 bFlags = TRUE;
2910 } 2890 }
2911 if (!bFlags) { 2891 if (!bFlags) {
2912 int32_t i = 0; 2892 int32_t i = 0;
2913 for (i = 0; i < nFirstMonth - 1; ++i) { 2893 for (i = 0; i < nFirstMonth - 1; ++i) {
2914 nPrincpalAmount -= nPayment - nPrincpalAmount * nRateOfMonth; 2894 nPrincpalAmount -= nPayment - nPrincpalAmount * nRateOfMonth;
2915 } 2895 }
2916 FX_FLOAT nTemp = 0; 2896 FX_FLOAT nTemp = 0;
2917 for (; i < iEnd; ++i) { 2897 for (; i < iEnd; ++i) {
2918 nTemp = nPayment - nPrincpalAmount * nRateOfMonth; 2898 nTemp = nPayment - nPrincpalAmount * nRateOfMonth;
2919 nSum += nTemp; 2899 nSum += nTemp;
2920 nPrincpalAmount -= nTemp; 2900 nPrincpalAmount -= nTemp;
2921 } 2901 }
2922 FXJSE_Value_SetFloat(args.GetReturnValue(), nSum); 2902 FXJSE_Value_SetFloat(args.GetReturnValue(), nSum);
2923 } else { 2903 } else {
2924 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); 2904 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
2925 } 2905 }
2926 } 2906 }
2927 } 2907 }
2928 } else { 2908 } else {
2929 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 2909 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"PPmt");
2930 L"PPmt");
2931 } 2910 }
2932 } 2911 }
2933 2912
2934 // static 2913 // static
2935 void CXFA_FM2JSContext::PV(CFXJSE_Value* pThis, 2914 void CXFA_FM2JSContext::PV(CFXJSE_Value* pThis,
2936 const CFX_ByteStringC& szFuncName, 2915 const CFX_ByteStringC& szFuncName,
2937 CFXJSE_Arguments& args) { 2916 CFXJSE_Arguments& args) {
2938 CXFA_FM2JSContext* pContext = 2917 CXFA_FM2JSContext* pContext =
2939 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 2918 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
2940 if (args.GetLength() == 3) { 2919 if (args.GetLength() == 3) {
2941 FX_BOOL bFlags = FALSE; 2920 FX_BOOL bFlags = FALSE;
2942 FX_DOUBLE nAmount = 0; 2921 FX_DOUBLE nAmount = 0;
2943 FX_DOUBLE nRate = 0; 2922 FX_DOUBLE nRate = 0;
2944 FX_DOUBLE nPeriod = 0; 2923 FX_DOUBLE nPeriod = 0;
2945 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2924 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
2946 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 2925 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
2947 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 2926 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
2948 bFlags = 2927 bFlags =
2949 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || 2928 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) ||
2950 ValueIsNull(pThis, argThree.get())); 2929 ValueIsNull(pThis, argThree.get()));
2951 if (bFlags) { 2930 if (bFlags) {
2952 FXJSE_Value_SetNull(args.GetReturnValue()); 2931 FXJSE_Value_SetNull(args.GetReturnValue());
2953 } else { 2932 } else {
2954 nAmount = ValueToDouble(pThis, argOne.get()); 2933 nAmount = ValueToDouble(pThis, argOne.get());
2955 nRate = ValueToDouble(pThis, argTwo.get()); 2934 nRate = ValueToDouble(pThis, argTwo.get());
2956 nPeriod = ValueToDouble(pThis, argThree.get()); 2935 nPeriod = ValueToDouble(pThis, argThree.get());
2957 bFlags = ((nAmount <= 0) || (nRate < 0) || (nPeriod <= 0)); 2936 bFlags = ((nAmount <= 0) || (nRate < 0) || (nPeriod <= 0));
2958 if (bFlags) { 2937 if (bFlags) {
2959 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); 2938 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
2960 } else { 2939 } else {
2961 FX_DOUBLE nTemp = 1; 2940 FX_DOUBLE nTemp = 1;
2962 for (int32_t i = 0; i < nPeriod; ++i) { 2941 for (int32_t i = 0; i < nPeriod; ++i) {
2963 nTemp *= 1 + nRate; 2942 nTemp *= 1 + nRate;
2964 } 2943 }
2965 nTemp = 1 / nTemp; 2944 nTemp = 1 / nTemp;
2966 FXJSE_Value_SetDouble(args.GetReturnValue(), 2945 FXJSE_Value_SetDouble(args.GetReturnValue(),
2967 nAmount * ((1 - nTemp) / nRate)); 2946 nAmount * ((1 - nTemp) / nRate));
2968 } 2947 }
2969 } 2948 }
2970 } else { 2949 } else {
2971 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 2950 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"PV");
2972 L"PV");
2973 } 2951 }
2974 } 2952 }
2975 2953
2976 // static 2954 // static
2977 void CXFA_FM2JSContext::Rate(CFXJSE_Value* pThis, 2955 void CXFA_FM2JSContext::Rate(CFXJSE_Value* pThis,
2978 const CFX_ByteStringC& szFuncName, 2956 const CFX_ByteStringC& szFuncName,
2979 CFXJSE_Arguments& args) { 2957 CFXJSE_Arguments& args) {
2980 CXFA_FM2JSContext* pContext = 2958 CXFA_FM2JSContext* pContext =
2981 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 2959 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
2982 if (args.GetLength() == 3) { 2960 if (args.GetLength() == 3) {
2983 FX_BOOL bFlags = FALSE; 2961 FX_BOOL bFlags = FALSE;
2984 FX_FLOAT nFuture = 0; 2962 FX_FLOAT nFuture = 0;
2985 FX_FLOAT nPresent = 0; 2963 FX_FLOAT nPresent = 0;
2986 FX_FLOAT nTotalNumber = 0; 2964 FX_FLOAT nTotalNumber = 0;
2987 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2965 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
2988 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 2966 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
2989 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 2967 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
2990 bFlags = 2968 bFlags =
2991 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || 2969 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) ||
2992 ValueIsNull(pThis, argThree.get())); 2970 ValueIsNull(pThis, argThree.get()));
2993 if (bFlags) { 2971 if (bFlags) {
2994 FXJSE_Value_SetNull(args.GetReturnValue()); 2972 FXJSE_Value_SetNull(args.GetReturnValue());
2995 } else { 2973 } else {
2996 nFuture = ValueToFloat(pThis, argOne.get()); 2974 nFuture = ValueToFloat(pThis, argOne.get());
2997 nPresent = ValueToFloat(pThis, argTwo.get()); 2975 nPresent = ValueToFloat(pThis, argTwo.get());
2998 nTotalNumber = ValueToFloat(pThis, argThree.get()); 2976 nTotalNumber = ValueToFloat(pThis, argThree.get());
2999 bFlags = ((nFuture <= 0) || (nPresent < 0) || (nTotalNumber <= 0)); 2977 bFlags = ((nFuture <= 0) || (nPresent < 0) || (nTotalNumber <= 0));
3000 if (bFlags) { 2978 if (bFlags) {
3001 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); 2979 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
3002 } else { 2980 } else {
3003 FXJSE_Value_SetFloat(args.GetReturnValue(), 2981 FXJSE_Value_SetFloat(args.GetReturnValue(),
3004 (FXSYS_pow((FX_FLOAT)(nFuture / nPresent), 2982 (FXSYS_pow((FX_FLOAT)(nFuture / nPresent),
3005 (FX_FLOAT)(1 / nTotalNumber)) - 2983 (FX_FLOAT)(1 / nTotalNumber)) -
3006 1)); 2984 1));
3007 } 2985 }
3008 } 2986 }
3009 } else { 2987 } else {
3010 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 2988 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Rate");
3011 L"Rate");
3012 } 2989 }
3013 } 2990 }
3014 2991
3015 // static 2992 // static
3016 void CXFA_FM2JSContext::Term(CFXJSE_Value* pThis, 2993 void CXFA_FM2JSContext::Term(CFXJSE_Value* pThis,
3017 const CFX_ByteStringC& szFuncName, 2994 const CFX_ByteStringC& szFuncName,
3018 CFXJSE_Arguments& args) { 2995 CFXJSE_Arguments& args) {
3019 CXFA_FM2JSContext* pContext = 2996 CXFA_FM2JSContext* pContext =
3020 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 2997 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
3021 if (args.GetLength() == 3) { 2998 if (args.GetLength() == 3) {
3022 FX_BOOL bFlags = FALSE; 2999 FX_BOOL bFlags = FALSE;
3023 FX_FLOAT nMount = 0; 3000 FX_FLOAT nMount = 0;
3024 FX_FLOAT nRate = 0; 3001 FX_FLOAT nRate = 0;
3025 FX_FLOAT nFuture = 0; 3002 FX_FLOAT nFuture = 0;
3026 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 3003 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
3027 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 3004 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
3028 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 3005 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
3029 bFlags = 3006 bFlags =
3030 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || 3007 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) ||
3031 ValueIsNull(pThis, argThree.get())); 3008 ValueIsNull(pThis, argThree.get()));
3032 if (bFlags) { 3009 if (bFlags) {
3033 FXJSE_Value_SetNull(args.GetReturnValue()); 3010 FXJSE_Value_SetNull(args.GetReturnValue());
3034 } else { 3011 } else {
3035 nMount = ValueToFloat(pThis, argOne.get()); 3012 nMount = ValueToFloat(pThis, argOne.get());
3036 nRate = ValueToFloat(pThis, argTwo.get()); 3013 nRate = ValueToFloat(pThis, argTwo.get());
3037 nFuture = ValueToFloat(pThis, argThree.get()); 3014 nFuture = ValueToFloat(pThis, argThree.get());
3038 bFlags = ((nMount <= 0) || (nRate <= 0) || (nFuture <= 0)); 3015 bFlags = ((nMount <= 0) || (nRate <= 0) || (nFuture <= 0));
3039 if (bFlags) { 3016 if (bFlags) {
3040 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); 3017 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
3041 } else { 3018 } else {
3042 FXJSE_Value_SetFloat( 3019 FXJSE_Value_SetFloat(
3043 args.GetReturnValue(), 3020 args.GetReturnValue(),
3044 (FXSYS_log((FX_FLOAT)(nFuture / nMount * nRate) + 1) / 3021 (FXSYS_log((FX_FLOAT)(nFuture / nMount * nRate) + 1) /
3045 FXSYS_log((FX_FLOAT)(1 + nRate)))); 3022 FXSYS_log((FX_FLOAT)(1 + nRate))));
3046 } 3023 }
3047 } 3024 }
3048 } else { 3025 } else {
3049 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 3026 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Term");
3050 L"Term");
3051 } 3027 }
3052 } 3028 }
3053 3029
3054 // static 3030 // static
3055 void CXFA_FM2JSContext::Choose(CFXJSE_Value* pThis, 3031 void CXFA_FM2JSContext::Choose(CFXJSE_Value* pThis,
3056 const CFX_ByteStringC& szFuncName, 3032 const CFX_ByteStringC& szFuncName,
3057 CFXJSE_Arguments& args) { 3033 CFXJSE_Arguments& args) {
3058 CXFA_FM2JSContext* pContext = 3034 CXFA_FM2JSContext* pContext =
3059 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3035 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
3060 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 3036 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
3127 } 3103 }
3128 iArgIndex++; 3104 iArgIndex++;
3129 } 3105 }
3130 if (!bFound) { 3106 if (!bFound) {
3131 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); 3107 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "");
3132 } 3108 }
3133 } 3109 }
3134 } else { 3110 } else {
3135 CXFA_FM2JSContext* pContext = 3111 CXFA_FM2JSContext* pContext =
3136 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3112 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
3137 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 3113 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Choose");
3138 L"Choose");
3139 } 3114 }
3140 } 3115 }
3141 3116
3142 // static 3117 // static
3143 void CXFA_FM2JSContext::Exists(CFXJSE_Value* pThis, 3118 void CXFA_FM2JSContext::Exists(CFXJSE_Value* pThis,
3144 const CFX_ByteStringC& szFuncName, 3119 const CFX_ByteStringC& szFuncName,
3145 CFXJSE_Arguments& args) { 3120 CFXJSE_Arguments& args) {
3146 if (args.GetLength() == 1) { 3121 if (args.GetLength() == 1) {
3147 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 3122 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
3148 FXJSE_Value_SetInteger(args.GetReturnValue(), 3123 FXJSE_Value_SetInteger(args.GetReturnValue(),
3149 FXJSE_Value_IsObject(argOne.get())); 3124 FXJSE_Value_IsObject(argOne.get()));
3150 } else { 3125 } else {
3151 CXFA_FM2JSContext* pContext = 3126 CXFA_FM2JSContext* pContext =
3152 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3127 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
3153 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 3128 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Exists");
3154 L"Exists");
3155 } 3129 }
3156 } 3130 }
3157 3131
3158 // static 3132 // static
3159 void CXFA_FM2JSContext::HasValue(CFXJSE_Value* pThis, 3133 void CXFA_FM2JSContext::HasValue(CFXJSE_Value* pThis,
3160 const CFX_ByteStringC& szFuncName, 3134 const CFX_ByteStringC& szFuncName,
3161 CFXJSE_Arguments& args) { 3135 CFXJSE_Arguments& args) {
3162 if (args.GetLength() == 1) { 3136 if (args.GetLength() == 1) {
3163 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 3137 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
3164 if (FXJSE_Value_IsUTF8String(argOne.get())) { 3138 if (FXJSE_Value_IsUTF8String(argOne.get())) {
3165 CFX_ByteString valueStr; 3139 CFX_ByteString valueStr;
3166 FXJSE_Value_ToUTF8String(argOne.get(), valueStr); 3140 FXJSE_Value_ToUTF8String(argOne.get(), valueStr);
3167 valueStr.TrimLeft(); 3141 valueStr.TrimLeft();
3168 FXJSE_Value_SetInteger(args.GetReturnValue(), (!valueStr.IsEmpty())); 3142 FXJSE_Value_SetInteger(args.GetReturnValue(), (!valueStr.IsEmpty()));
3169 } else if (FXJSE_Value_IsNumber(argOne.get()) || 3143 } else if (FXJSE_Value_IsNumber(argOne.get()) ||
3170 FXJSE_Value_IsBoolean(argOne.get())) { 3144 FXJSE_Value_IsBoolean(argOne.get())) {
3171 FXJSE_Value_SetInteger(args.GetReturnValue(), TRUE); 3145 FXJSE_Value_SetInteger(args.GetReturnValue(), TRUE);
3172 } else { 3146 } else {
3173 FXJSE_Value_SetInteger(args.GetReturnValue(), FALSE); 3147 FXJSE_Value_SetInteger(args.GetReturnValue(), FALSE);
3174 } 3148 }
3175 } else { 3149 } else {
3176 CXFA_FM2JSContext* pContext = 3150 CXFA_FM2JSContext* pContext =
3177 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3151 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
3178 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 3152 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"HasValue");
3179 L"HasValue");
3180 } 3153 }
3181 } 3154 }
3182 3155
3183 // static 3156 // static
3184 void CXFA_FM2JSContext::Oneof(CFXJSE_Value* pThis, 3157 void CXFA_FM2JSContext::Oneof(CFXJSE_Value* pThis,
3185 const CFX_ByteStringC& szFuncName, 3158 const CFX_ByteStringC& szFuncName,
3186 CFXJSE_Arguments& args) { 3159 CFXJSE_Arguments& args) {
3187 if (args.GetLength() > 1) { 3160 if (args.GetLength() > 1) {
3188 FX_BOOL bFlags = FALSE; 3161 FX_BOOL bFlags = FALSE;
3189 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 3162 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
3190 CFXJSE_Value** parametersValue = nullptr; 3163 CFXJSE_Value** parametersValue = nullptr;
3191 int32_t iCount = 0; 3164 int32_t iCount = 0;
3192 unfoldArgs(pThis, args, parametersValue, iCount, 1); 3165 unfoldArgs(pThis, args, parametersValue, iCount, 1);
3193 for (int32_t i = 0; i < iCount; i++) { 3166 for (int32_t i = 0; i < iCount; i++) {
3194 if (simpleValueCompare(pThis, argOne.get(), parametersValue[i])) { 3167 if (simpleValueCompare(pThis, argOne.get(), parametersValue[i])) {
3195 bFlags = TRUE; 3168 bFlags = TRUE;
3196 break; 3169 break;
3197 } 3170 }
3198 } 3171 }
3199 FXJSE_Value_SetInteger(args.GetReturnValue(), bFlags); 3172 FXJSE_Value_SetInteger(args.GetReturnValue(), bFlags);
3200 for (int32_t i = 0; i < iCount; i++) { 3173 for (int32_t i = 0; i < iCount; i++) {
3201 delete parametersValue[i]; 3174 delete parametersValue[i];
3202 } 3175 }
3203 FX_Free(parametersValue); 3176 FX_Free(parametersValue);
3204 } else { 3177 } else {
3205 CXFA_FM2JSContext* pContext = 3178 CXFA_FM2JSContext* pContext =
3206 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3179 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
3207 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 3180 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Oneof");
3208 L"Oneof");
3209 } 3181 }
3210 } 3182 }
3211 3183
3212 // static 3184 // static
3213 void CXFA_FM2JSContext::Within(CFXJSE_Value* pThis, 3185 void CXFA_FM2JSContext::Within(CFXJSE_Value* pThis,
3214 const CFX_ByteStringC& szFuncName, 3186 const CFX_ByteStringC& szFuncName,
3215 CFXJSE_Arguments& args) { 3187 CFXJSE_Arguments& args) {
3216 if (args.GetLength() == 3) { 3188 if (args.GetLength() == 3) {
3217 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 3189 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
3218 if (FXJSE_Value_IsNull(argOne.get())) { 3190 if (FXJSE_Value_IsNull(argOne.get())) {
(...skipping 17 matching lines...) Expand all
3236 ValueToUTF8String(argHeight.get(), heightString); 3208 ValueToUTF8String(argHeight.get(), heightString);
3237 FXJSE_Value_SetInteger( 3209 FXJSE_Value_SetInteger(
3238 args.GetReturnValue(), 3210 args.GetReturnValue(),
3239 ((oneString.Compare(lowString.AsStringC()) >= 0) && 3211 ((oneString.Compare(lowString.AsStringC()) >= 0) &&
3240 (oneString.Compare(heightString.AsStringC()) <= 0))); 3212 (oneString.Compare(heightString.AsStringC()) <= 0)));
3241 } 3213 }
3242 } 3214 }
3243 } else { 3215 } else {
3244 CXFA_FM2JSContext* pContext = 3216 CXFA_FM2JSContext* pContext =
3245 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3217 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
3246 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 3218 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Within");
3247 L"Within");
3248 } 3219 }
3249 } 3220 }
3250 3221
3251 // static 3222 // static
3252 void CXFA_FM2JSContext::If(CFXJSE_Value* pThis, 3223 void CXFA_FM2JSContext::If(CFXJSE_Value* pThis,
3253 const CFX_ByteStringC& szFuncName, 3224 const CFX_ByteStringC& szFuncName,
3254 CFXJSE_Arguments& args) { 3225 CFXJSE_Arguments& args) {
3255 if (args.GetLength() == 3) { 3226 if (args.GetLength() == 3) {
3256 std::unique_ptr<CFXJSE_Value> argCondition = GetSimpleValue(pThis, args, 0); 3227 std::unique_ptr<CFXJSE_Value> argCondition = GetSimpleValue(pThis, args, 0);
3257 std::unique_ptr<CFXJSE_Value> argFirstValue = 3228 std::unique_ptr<CFXJSE_Value> argFirstValue =
3258 GetSimpleValue(pThis, args, 1); 3229 GetSimpleValue(pThis, args, 1);
3259 std::unique_ptr<CFXJSE_Value> argSecondValue = 3230 std::unique_ptr<CFXJSE_Value> argSecondValue =
3260 GetSimpleValue(pThis, args, 2); 3231 GetSimpleValue(pThis, args, 2);
3261 FX_BOOL bCondition = FXJSE_Value_ToBoolean(argCondition.get()); 3232 FX_BOOL bCondition = FXJSE_Value_ToBoolean(argCondition.get());
3262 FXJSE_Value_Set(args.GetReturnValue(), 3233 FXJSE_Value_Set(args.GetReturnValue(),
3263 bCondition ? argFirstValue.get() : argSecondValue.get()); 3234 bCondition ? argFirstValue.get() : argSecondValue.get());
3264 } else { 3235 } else {
3265 CXFA_FM2JSContext* pContext = 3236 CXFA_FM2JSContext* pContext =
3266 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3237 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
3267 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 3238 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"If");
3268 L"If");
3269 } 3239 }
3270 } 3240 }
3271 3241
3272 // static 3242 // static
3273 void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis, 3243 void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis,
3274 const CFX_ByteStringC& szFuncName, 3244 const CFX_ByteStringC& szFuncName,
3275 CFXJSE_Arguments& args) { 3245 CFXJSE_Arguments& args) {
3276 CXFA_FM2JSContext* pContext = 3246 CXFA_FM2JSContext* pContext =
3277 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3247 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
3278 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 3248 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
(...skipping 15 matching lines...) Expand all
3294 std::unique_ptr<CFXJSE_Value> returnValue(new CFXJSE_Value(pIsolate)); 3264 std::unique_ptr<CFXJSE_Value> returnValue(new CFXJSE_Value(pIsolate));
3295 javaScript = wsJavaScriptBuf.AsStringC(); 3265 javaScript = wsJavaScriptBuf.AsStringC();
3296 FXJSE_ExecuteScript( 3266 FXJSE_ExecuteScript(
3297 pContext, 3267 pContext,
3298 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(), 3268 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(),
3299 returnValue.get()); 3269 returnValue.get());
3300 FXJSE_Value_Set(args.GetReturnValue(), returnValue.get()); 3270 FXJSE_Value_Set(args.GetReturnValue(), returnValue.get());
3301 FXJSE_Context_Release(pContext); 3271 FXJSE_Context_Release(pContext);
3302 } 3272 }
3303 } else { 3273 } else {
3304 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 3274 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Eval");
3305 L"Eval");
3306 } 3275 }
3307 } 3276 }
3308 3277
3309 // static 3278 // static
3310 void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis, 3279 void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis,
3311 const CFX_ByteStringC& szFuncName, 3280 const CFX_ByteStringC& szFuncName,
3312 CFXJSE_Arguments& args) { 3281 CFXJSE_Arguments& args) {
3313 CXFA_FM2JSContext* pContext = 3282 CXFA_FM2JSContext* pContext =
3314 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3283 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
3315 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 3284 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
(...skipping 15 matching lines...) Expand all
3331 #ifndef NDEBUG 3300 #ifndef NDEBUG
3332 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 3301 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
3333 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get()); 3302 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get());
3334 ASSERT(FXJSE_Value_ToInteger(lengthValue.get()) >= 3); 3303 ASSERT(FXJSE_Value_ToInteger(lengthValue.get()) >= 3);
3335 #endif 3304 #endif
3336 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 3305 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
3337 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 3306 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
3338 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 1, propertyValue.get()); 3307 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 1, propertyValue.get());
3339 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, jsObjectValue.get()); 3308 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, jsObjectValue.get());
3340 if (FXJSE_Value_IsNull(jsObjectValue.get())) { 3309 if (FXJSE_Value_IsNull(jsObjectValue.get())) {
3341 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); 3310 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
3342 } else if (FXJSE_Value_IsNull(propertyValue.get()) && 3311 } else if (FXJSE_Value_IsNull(propertyValue.get()) &&
3343 (!FXJSE_Value_IsNull(jsObjectValue.get()))) { 3312 (!FXJSE_Value_IsNull(jsObjectValue.get()))) {
3344 CFXJSE_Value* rgValues[3]; 3313 CFXJSE_Value* rgValues[3];
3345 for (int32_t i = 0; i < 3; i++) 3314 for (int32_t i = 0; i < 3; i++)
3346 rgValues[i] = new CFXJSE_Value(pIsolate); 3315 rgValues[i] = new CFXJSE_Value(pIsolate);
3347 3316
3348 FXJSE_Value_SetInteger(rgValues[0], 3); 3317 FXJSE_Value_SetInteger(rgValues[0], 3);
3349 FXJSE_Value_SetNull(rgValues[1]); 3318 FXJSE_Value_SetNull(rgValues[1]);
3350 FXJSE_Value_Set(rgValues[2], jsObjectValue.get()); 3319 FXJSE_Value_Set(rgValues[2], jsObjectValue.get());
3351 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); 3320 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues);
3352 for (int32_t i = 0; i < 3; i++) 3321 for (int32_t i = 0; i < 3; i++)
3353 delete rgValues[i]; 3322 delete rgValues[i];
3354 3323
3355 } else { 3324 } else {
3356 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); 3325 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
3357 } 3326 }
3358 } else if (FXJSE_Value_IsObject(argOne.get())) { 3327 } else if (FXJSE_Value_IsObject(argOne.get())) {
3359 CFXJSE_Value* rgValues[3]; 3328 CFXJSE_Value* rgValues[3];
3360 for (int32_t i = 0; i < 3; i++) 3329 for (int32_t i = 0; i < 3; i++)
3361 rgValues[i] = new CFXJSE_Value(pIsolate); 3330 rgValues[i] = new CFXJSE_Value(pIsolate);
3362 3331
3363 FXJSE_Value_SetInteger(rgValues[0], 3); 3332 FXJSE_Value_SetInteger(rgValues[0], 3);
3364 FXJSE_Value_SetNull(rgValues[1]); 3333 FXJSE_Value_SetNull(rgValues[1]);
3365 FXJSE_Value_Set(rgValues[2], argOne.get()); 3334 FXJSE_Value_Set(rgValues[2], argOne.get());
3366 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); 3335 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues);
3367 3336
3368 for (int32_t i = 0; i < 3; i++) 3337 for (int32_t i = 0; i < 3; i++)
3369 delete rgValues[i]; 3338 delete rgValues[i];
3370 } else if (FXJSE_Value_IsBoolean(argOne.get()) || 3339 } else if (FXJSE_Value_IsBoolean(argOne.get()) ||
3371 FXJSE_Value_IsUTF8String(argOne.get()) || 3340 FXJSE_Value_IsUTF8String(argOne.get()) ||
3372 FXJSE_Value_IsNumber(argOne.get())) { 3341 FXJSE_Value_IsNumber(argOne.get())) {
3373 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); 3342 FXJSE_Value_Set(args.GetReturnValue(), argOne.get());
3374 } else { 3343 } else {
3375 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); 3344 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
3376 } 3345 }
3377 } else { 3346 } else {
3378 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 3347 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Ref");
3379 L"Ref");
3380 } 3348 }
3381 } 3349 }
3382 3350
3383 // static 3351 // static
3384 void CXFA_FM2JSContext::UnitType(CFXJSE_Value* pThis, 3352 void CXFA_FM2JSContext::UnitType(CFXJSE_Value* pThis,
3385 const CFX_ByteStringC& szFuncName, 3353 const CFX_ByteStringC& szFuncName,
3386 CFXJSE_Arguments& args) { 3354 CFXJSE_Arguments& args) {
3387 if (args.GetLength() == 1) { 3355 if (args.GetLength() == 1) {
3388 std::unique_ptr<CFXJSE_Value> unitspanValue = 3356 std::unique_ptr<CFXJSE_Value> unitspanValue =
3389 GetSimpleValue(pThis, args, 0); 3357 GetSimpleValue(pThis, args, 0);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
3486 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "mp"); 3454 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "mp");
3487 break; 3455 break;
3488 default: 3456 default:
3489 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "in"); 3457 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "in");
3490 break; 3458 break;
3491 } 3459 }
3492 } 3460 }
3493 } else { 3461 } else {
3494 CXFA_FM2JSContext* pContext = 3462 CXFA_FM2JSContext* pContext =
3495 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3463 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
3496 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 3464 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"UnitType");
3497 L"UnitType");
3498 } 3465 }
3499 } 3466 }
3500 3467
3501 // static 3468 // static
3502 void CXFA_FM2JSContext::UnitValue(CFXJSE_Value* pThis, 3469 void CXFA_FM2JSContext::UnitValue(CFXJSE_Value* pThis,
3503 const CFX_ByteStringC& szFuncName, 3470 const CFX_ByteStringC& szFuncName,
3504 CFXJSE_Arguments& args) { 3471 CFXJSE_Arguments& args) {
3505 int32_t argc = args.GetLength(); 3472 int32_t argc = args.GetLength();
3506 if ((argc == 1) || (argc == 2)) { 3473 if ((argc == 1) || (argc == 2)) {
3507 std::unique_ptr<CFXJSE_Value> unitspanValue = 3474 std::unique_ptr<CFXJSE_Value> unitspanValue =
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
3644 } 3611 }
3645 } 3612 }
3646 FXJSE_Value_SetDouble(args.GetReturnValue(), dResult); 3613 FXJSE_Value_SetDouble(args.GetReturnValue(), dResult);
3647 } else { 3614 } else {
3648 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); 3615 FXJSE_Value_SetInteger(args.GetReturnValue(), 0);
3649 } 3616 }
3650 } 3617 }
3651 } else { 3618 } else {
3652 CXFA_FM2JSContext* pContext = 3619 CXFA_FM2JSContext* pContext =
3653 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3620 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
3654 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 3621 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"UnitValue");
3655 L"UnitValue");
3656 } 3622 }
3657 } 3623 }
3658 3624
3659 // static 3625 // static
3660 void CXFA_FM2JSContext::At(CFXJSE_Value* pThis, 3626 void CXFA_FM2JSContext::At(CFXJSE_Value* pThis,
3661 const CFX_ByteStringC& szFuncName, 3627 const CFX_ByteStringC& szFuncName,
3662 CFXJSE_Arguments& args) { 3628 CFXJSE_Arguments& args) {
3663 if (args.GetLength() == 2) { 3629 if (args.GetLength() == 2) {
3664 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 3630 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
3665 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 3631 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
3666 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get())) { 3632 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get())) {
3667 FXJSE_Value_SetNull(args.GetReturnValue()); 3633 FXJSE_Value_SetNull(args.GetReturnValue());
3668 } else { 3634 } else {
3669 CFX_ByteString stringTwo; 3635 CFX_ByteString stringTwo;
3670 ValueToUTF8String(argTwo.get(), stringTwo); 3636 ValueToUTF8String(argTwo.get(), stringTwo);
3671 if (stringTwo.IsEmpty()) { 3637 if (stringTwo.IsEmpty()) {
3672 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); 3638 FXJSE_Value_SetInteger(args.GetReturnValue(), 1);
3673 } else { 3639 } else {
3674 CFX_ByteString stringOne; 3640 CFX_ByteString stringOne;
3675 ValueToUTF8String(argOne.get(), stringOne); 3641 ValueToUTF8String(argOne.get(), stringOne);
3676 FX_STRSIZE iPosition = stringOne.Find(stringTwo.AsStringC()); 3642 FX_STRSIZE iPosition = stringOne.Find(stringTwo.AsStringC());
3677 FXJSE_Value_SetInteger(args.GetReturnValue(), iPosition + 1); 3643 FXJSE_Value_SetInteger(args.GetReturnValue(), iPosition + 1);
3678 } 3644 }
3679 } 3645 }
3680 } else { 3646 } else {
3681 CXFA_FM2JSContext* pContext = 3647 CXFA_FM2JSContext* pContext =
3682 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3648 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
3683 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 3649 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"At");
3684 L"At");
3685 } 3650 }
3686 } 3651 }
3687 3652
3688 // static 3653 // static
3689 void CXFA_FM2JSContext::Concat(CFXJSE_Value* pThis, 3654 void CXFA_FM2JSContext::Concat(CFXJSE_Value* pThis,
3690 const CFX_ByteStringC& szFuncName, 3655 const CFX_ByteStringC& szFuncName,
3691 CFXJSE_Arguments& args) { 3656 CFXJSE_Arguments& args) {
3692 int32_t argc = args.GetLength(); 3657 int32_t argc = args.GetLength();
3693 if (argc >= 1) { 3658 if (argc >= 1) {
3694 CFX_ByteString resultString; 3659 CFX_ByteString resultString;
(...skipping 11 matching lines...) Expand all
3706 3671
3707 if (bAllNull) { 3672 if (bAllNull) {
3708 FXJSE_Value_SetNull(args.GetReturnValue()); 3673 FXJSE_Value_SetNull(args.GetReturnValue());
3709 } else { 3674 } else {
3710 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 3675 FXJSE_Value_SetUTF8String(args.GetReturnValue(),
3711 resultString.AsStringC()); 3676 resultString.AsStringC());
3712 } 3677 }
3713 } else { 3678 } else {
3714 CXFA_FM2JSContext* pContext = 3679 CXFA_FM2JSContext* pContext =
3715 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3680 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
3716 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 3681 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Concat");
3717 L"Concat");
3718 } 3682 }
3719 } 3683 }
3720 3684
3721 // static 3685 // static
3722 void CXFA_FM2JSContext::Decode(CFXJSE_Value* pThis, 3686 void CXFA_FM2JSContext::Decode(CFXJSE_Value* pThis,
3723 const CFX_ByteStringC& szFuncName, 3687 const CFX_ByteStringC& szFuncName,
3724 CFXJSE_Arguments& args) { 3688 CFXJSE_Arguments& args) {
3725 int32_t argc = args.GetLength(); 3689 int32_t argc = args.GetLength();
3726 if (argc == 1) { 3690 if (argc == 1) {
3727 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 3691 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
(...skipping 22 matching lines...) Expand all
3750 } else if (identifyString.EqualNoCase("xml")) { 3714 } else if (identifyString.EqualNoCase("xml")) {
3751 DecodeXML(toDecodeString.AsStringC(), resultBuf); 3715 DecodeXML(toDecodeString.AsStringC(), resultBuf);
3752 } else { 3716 } else {
3753 DecodeURL(toDecodeString.AsStringC(), resultBuf); 3717 DecodeURL(toDecodeString.AsStringC(), resultBuf);
3754 } 3718 }
3755 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); 3719 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC());
3756 } 3720 }
3757 } else { 3721 } else {
3758 CXFA_FM2JSContext* pContext = 3722 CXFA_FM2JSContext* pContext =
3759 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3723 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
3760 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 3724 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Decode");
3761 L"Decode");
3762 } 3725 }
3763 } 3726 }
3764 3727
3765 // static 3728 // static
3766 void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString, 3729 void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString,
3767 CFX_ByteTextBuf& szResultString) { 3730 CFX_ByteTextBuf& szResultString) {
3768 CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString); 3731 CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString);
3769 const FX_WCHAR* pData = wsURLString.c_str(); 3732 const FX_WCHAR* pData = wsURLString.c_str();
3770 int32_t iLen = wsURLString.GetLength(); 3733 int32_t iLen = wsURLString.GetLength();
3771 int32_t i = 0; 3734 int32_t i = 0;
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
4026 } else if (identifyString.EqualNoCase("xml")) { 3989 } else if (identifyString.EqualNoCase("xml")) {
4027 EncodeXML(toEncodeString.AsStringC(), resultBuf); 3990 EncodeXML(toEncodeString.AsStringC(), resultBuf);
4028 } else { 3991 } else {
4029 EncodeURL(toEncodeString.AsStringC(), resultBuf); 3992 EncodeURL(toEncodeString.AsStringC(), resultBuf);
4030 } 3993 }
4031 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); 3994 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC());
4032 } 3995 }
4033 } else { 3996 } else {
4034 CXFA_FM2JSContext* pContext = 3997 CXFA_FM2JSContext* pContext =
4035 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3998 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
4036 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 3999 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Encode");
4037 L"Encode");
4038 } 4000 }
4039 } 4001 }
4040 4002
4041 // static 4003 // static
4042 void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString, 4004 void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString,
4043 CFX_ByteTextBuf& szResultBuf) { 4005 CFX_ByteTextBuf& szResultBuf) {
4044 CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString); 4006 CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString);
4045 CFX_WideTextBuf wsResultBuf; 4007 CFX_WideTextBuf wsResultBuf;
4046 FX_WCHAR ch = 0; 4008 FX_WCHAR ch = 0;
4047 int32_t iLength = wsURLString.GetLength(); 4009 int32_t iLength = wsURLString.GetLength();
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
4403 CFX_WideString wsRet; 4365 CFX_WideString wsRet;
4404 if (localeValue.FormatPatterns(wsRet, wsPattern, pLocale, 4366 if (localeValue.FormatPatterns(wsRet, wsPattern, pLocale,
4405 XFA_VALUEPICTURE_Display)) { 4367 XFA_VALUEPICTURE_Display)) {
4406 FXJSE_Value_SetUTF8String( 4368 FXJSE_Value_SetUTF8String(
4407 args.GetReturnValue(), 4369 args.GetReturnValue(),
4408 FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()).AsStringC()); 4370 FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()).AsStringC());
4409 } else { 4371 } else {
4410 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); 4372 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "");
4411 } 4373 }
4412 } else { 4374 } else {
4413 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 4375 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Format");
4414 L"Format");
4415 } 4376 }
4416 } 4377 }
4417 4378
4418 // static 4379 // static
4419 void CXFA_FM2JSContext::Left(CFXJSE_Value* pThis, 4380 void CXFA_FM2JSContext::Left(CFXJSE_Value* pThis,
4420 const CFX_ByteStringC& szFuncName, 4381 const CFX_ByteStringC& szFuncName,
4421 CFXJSE_Arguments& args) { 4382 CFXJSE_Arguments& args) {
4422 if (args.GetLength() == 2) { 4383 if (args.GetLength() == 2) {
4423 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 4384 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
4424 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 4385 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
(...skipping 10 matching lines...) Expand all
4435 int32_t count = ValueToInteger(pThis, argTwo.get()); 4396 int32_t count = ValueToInteger(pThis, argTwo.get());
4436 if (count < 0) { 4397 if (count < 0) {
4437 count = 0; 4398 count = 0;
4438 } 4399 }
4439 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 4400 FXJSE_Value_SetUTF8String(args.GetReturnValue(),
4440 sourceString.Left(count).AsStringC()); 4401 sourceString.Left(count).AsStringC());
4441 } 4402 }
4442 } else { 4403 } else {
4443 CXFA_FM2JSContext* pContext = 4404 CXFA_FM2JSContext* pContext =
4444 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 4405 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
4445 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 4406 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Left");
4446 L"Left");
4447 } 4407 }
4448 } 4408 }
4449 4409
4450 // static 4410 // static
4451 void CXFA_FM2JSContext::Len(CFXJSE_Value* pThis, 4411 void CXFA_FM2JSContext::Len(CFXJSE_Value* pThis,
4452 const CFX_ByteStringC& szFuncName, 4412 const CFX_ByteStringC& szFuncName,
4453 CFXJSE_Arguments& args) { 4413 CFXJSE_Arguments& args) {
4454 if (args.GetLength() == 1) { 4414 if (args.GetLength() == 1) {
4455 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 4415 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
4456 if (ValueIsNull(pThis, argOne.get())) { 4416 if (ValueIsNull(pThis, argOne.get())) {
4457 FXJSE_Value_SetNull(args.GetReturnValue()); 4417 FXJSE_Value_SetNull(args.GetReturnValue());
4458 } else { 4418 } else {
4459 CFX_ByteString sourceString; 4419 CFX_ByteString sourceString;
4460 ValueToUTF8String(argOne.get(), sourceString); 4420 ValueToUTF8String(argOne.get(), sourceString);
4461 FXJSE_Value_SetInteger(args.GetReturnValue(), sourceString.GetLength()); 4421 FXJSE_Value_SetInteger(args.GetReturnValue(), sourceString.GetLength());
4462 } 4422 }
4463 } else { 4423 } else {
4464 CXFA_FM2JSContext* pContext = 4424 CXFA_FM2JSContext* pContext =
4465 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 4425 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
4466 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 4426 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Len");
4467 L"Len");
4468 } 4427 }
4469 } 4428 }
4470 4429
4471 // static 4430 // static
4472 void CXFA_FM2JSContext::Lower(CFXJSE_Value* pThis, 4431 void CXFA_FM2JSContext::Lower(CFXJSE_Value* pThis,
4473 const CFX_ByteStringC& szFuncName, 4432 const CFX_ByteStringC& szFuncName,
4474 CFXJSE_Arguments& args) { 4433 CFXJSE_Arguments& args) {
4475 int32_t argc = args.GetLength(); 4434 int32_t argc = args.GetLength();
4476 if ((argc > 0) && (argc < 3)) { 4435 if ((argc > 0) && (argc < 3)) {
4477 CFX_ByteString argString; 4436 CFX_ByteString argString;
(...skipping 23 matching lines...) Expand all
4501 } 4460 }
4502 lowStringBuf.AppendChar(0); 4461 lowStringBuf.AppendChar(0);
4503 FXJSE_Value_SetUTF8String( 4462 FXJSE_Value_SetUTF8String(
4504 args.GetReturnValue(), 4463 args.GetReturnValue(),
4505 FX_UTF8Encode(lowStringBuf.GetBuffer(), lowStringBuf.GetLength()) 4464 FX_UTF8Encode(lowStringBuf.GetBuffer(), lowStringBuf.GetLength())
4506 .AsStringC()); 4465 .AsStringC());
4507 } 4466 }
4508 } else { 4467 } else {
4509 CXFA_FM2JSContext* pContext = 4468 CXFA_FM2JSContext* pContext =
4510 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 4469 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
4511 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 4470 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Lower");
4512 L"Lower");
4513 } 4471 }
4514 } 4472 }
4515 4473
4516 // static 4474 // static
4517 void CXFA_FM2JSContext::Ltrim(CFXJSE_Value* pThis, 4475 void CXFA_FM2JSContext::Ltrim(CFXJSE_Value* pThis,
4518 const CFX_ByteStringC& szFuncName, 4476 const CFX_ByteStringC& szFuncName,
4519 CFXJSE_Arguments& args) { 4477 CFXJSE_Arguments& args) {
4520 if (args.GetLength() == 1) { 4478 if (args.GetLength() == 1) {
4521 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 4479 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
4522 if (ValueIsNull(pThis, argOne.get())) { 4480 if (ValueIsNull(pThis, argOne.get())) {
4523 FXJSE_Value_SetNull(args.GetReturnValue()); 4481 FXJSE_Value_SetNull(args.GetReturnValue());
4524 } else { 4482 } else {
4525 CFX_ByteString sourceString; 4483 CFX_ByteString sourceString;
4526 ValueToUTF8String(argOne.get(), sourceString); 4484 ValueToUTF8String(argOne.get(), sourceString);
4527 sourceString.TrimLeft(); 4485 sourceString.TrimLeft();
4528 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 4486 FXJSE_Value_SetUTF8String(args.GetReturnValue(),
4529 sourceString.AsStringC()); 4487 sourceString.AsStringC());
4530 } 4488 }
4531 } else { 4489 } else {
4532 CXFA_FM2JSContext* pContext = 4490 CXFA_FM2JSContext* pContext =
4533 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 4491 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
4534 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 4492 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Ltrim");
4535 L"Ltrim");
4536 } 4493 }
4537 } 4494 }
4538 4495
4539 // static 4496 // static
4540 void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis, 4497 void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis,
4541 const CFX_ByteStringC& szFuncName, 4498 const CFX_ByteStringC& szFuncName,
4542 CFXJSE_Arguments& args) { 4499 CFXJSE_Arguments& args) {
4543 CXFA_FM2JSContext* pContext = 4500 CXFA_FM2JSContext* pContext =
4544 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 4501 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
4545 if (args.GetLength() == 2) { 4502 if (args.GetLength() == 2) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
4665 szParsedValue.AsStringC()); 4622 szParsedValue.AsStringC());
4666 } else { 4623 } else {
4667 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); 4624 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "");
4668 } 4625 }
4669 } 4626 }
4670 } break; 4627 } break;
4671 } 4628 }
4672 } 4629 }
4673 } 4630 }
4674 } else { 4631 } else {
4675 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 4632 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Parse");
4676 L"Parse");
4677 } 4633 }
4678 } 4634 }
4679 4635
4680 // static 4636 // static
4681 void CXFA_FM2JSContext::Replace(CFXJSE_Value* pThis, 4637 void CXFA_FM2JSContext::Replace(CFXJSE_Value* pThis,
4682 const CFX_ByteStringC& szFuncName, 4638 const CFX_ByteStringC& szFuncName,
4683 CFXJSE_Arguments& args) { 4639 CFXJSE_Arguments& args) {
4684 int32_t argc = args.GetLength(); 4640 int32_t argc = args.GetLength();
4685 if ((argc == 2) || (argc == 3)) { 4641 if ((argc == 2) || (argc == 3)) {
4686 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 4642 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
4727 } 4683 }
4728 } else { 4684 } else {
4729 resultString.AppendChar(ch); 4685 resultString.AppendChar(ch);
4730 } 4686 }
4731 } 4687 }
4732 resultString.AppendChar(0); 4688 resultString.AppendChar(0);
4733 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); 4689 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC());
4734 } else { 4690 } else {
4735 CXFA_FM2JSContext* pContext = 4691 CXFA_FM2JSContext* pContext =
4736 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 4692 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
4737 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 4693 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Replace");
4738 L"Replace");
4739 } 4694 }
4740 } 4695 }
4741 4696
4742 // static 4697 // static
4743 void CXFA_FM2JSContext::Right(CFXJSE_Value* pThis, 4698 void CXFA_FM2JSContext::Right(CFXJSE_Value* pThis,
4744 const CFX_ByteStringC& szFuncName, 4699 const CFX_ByteStringC& szFuncName,
4745 CFXJSE_Arguments& args) { 4700 CFXJSE_Arguments& args) {
4746 if (args.GetLength() == 2) { 4701 if (args.GetLength() == 2) {
4747 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 4702 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
4748 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 4703 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
(...skipping 10 matching lines...) Expand all
4759 int32_t count = ValueToInteger(pThis, argTwo.get()); 4714 int32_t count = ValueToInteger(pThis, argTwo.get());
4760 if (count < 0) { 4715 if (count < 0) {
4761 count = 0; 4716 count = 0;
4762 } 4717 }
4763 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 4718 FXJSE_Value_SetUTF8String(args.GetReturnValue(),
4764 sourceString.Right(count).AsStringC()); 4719 sourceString.Right(count).AsStringC());
4765 } 4720 }
4766 } else { 4721 } else {
4767 CXFA_FM2JSContext* pContext = 4722 CXFA_FM2JSContext* pContext =
4768 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 4723 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
4769 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 4724 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Right");
4770 L"Right");
4771 } 4725 }
4772 } 4726 }
4773 4727
4774 // static 4728 // static
4775 void CXFA_FM2JSContext::Rtrim(CFXJSE_Value* pThis, 4729 void CXFA_FM2JSContext::Rtrim(CFXJSE_Value* pThis,
4776 const CFX_ByteStringC& szFuncName, 4730 const CFX_ByteStringC& szFuncName,
4777 CFXJSE_Arguments& args) { 4731 CFXJSE_Arguments& args) {
4778 if (args.GetLength() == 1) { 4732 if (args.GetLength() == 1) {
4779 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 4733 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
4780 if (ValueIsNull(pThis, argOne.get())) { 4734 if (ValueIsNull(pThis, argOne.get())) {
4781 FXJSE_Value_SetNull(args.GetReturnValue()); 4735 FXJSE_Value_SetNull(args.GetReturnValue());
4782 } else { 4736 } else {
4783 CFX_ByteString sourceString; 4737 CFX_ByteString sourceString;
4784 ValueToUTF8String(argOne.get(), sourceString); 4738 ValueToUTF8String(argOne.get(), sourceString);
4785 sourceString.TrimRight(); 4739 sourceString.TrimRight();
4786 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 4740 FXJSE_Value_SetUTF8String(args.GetReturnValue(),
4787 sourceString.AsStringC()); 4741 sourceString.AsStringC());
4788 } 4742 }
4789 } else { 4743 } else {
4790 CXFA_FM2JSContext* pContext = 4744 CXFA_FM2JSContext* pContext =
4791 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 4745 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
4792 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 4746 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Rtrim");
4793 L"Rtrim");
4794 } 4747 }
4795 } 4748 }
4796 4749
4797 // static 4750 // static
4798 void CXFA_FM2JSContext::Space(CFXJSE_Value* pThis, 4751 void CXFA_FM2JSContext::Space(CFXJSE_Value* pThis,
4799 const CFX_ByteStringC& szFuncName, 4752 const CFX_ByteStringC& szFuncName,
4800 CFXJSE_Arguments& args) { 4753 CFXJSE_Arguments& args) {
4801 if (args.GetLength() == 1) { 4754 if (args.GetLength() == 1) {
4802 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 4755 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
4803 if (FXJSE_Value_IsNull(argOne.get())) { 4756 if (FXJSE_Value_IsNull(argOne.get())) {
4804 FXJSE_Value_SetNull(args.GetReturnValue()); 4757 FXJSE_Value_SetNull(args.GetReturnValue());
4805 } else { 4758 } else {
4806 int32_t count = 0; 4759 int32_t count = 0;
4807 count = ValueToInteger(pThis, argOne.get()); 4760 count = ValueToInteger(pThis, argOne.get());
4808 count = (count < 0) ? 0 : count; 4761 count = (count < 0) ? 0 : count;
4809 CFX_ByteTextBuf spaceString; 4762 CFX_ByteTextBuf spaceString;
4810 int32_t index = 0; 4763 int32_t index = 0;
4811 while (index < count) { 4764 while (index < count) {
4812 spaceString.AppendByte(' '); 4765 spaceString.AppendByte(' ');
4813 index++; 4766 index++;
4814 } 4767 }
4815 spaceString.AppendByte(0); 4768 spaceString.AppendByte(0);
4816 FXJSE_Value_SetUTF8String(args.GetReturnValue(), spaceString.AsStringC()); 4769 FXJSE_Value_SetUTF8String(args.GetReturnValue(), spaceString.AsStringC());
4817 } 4770 }
4818 } else { 4771 } else {
4819 CXFA_FM2JSContext* pContext = 4772 CXFA_FM2JSContext* pContext =
4820 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 4773 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
4821 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 4774 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Space");
4822 L"Space");
4823 } 4775 }
4824 } 4776 }
4825 4777
4826 // static 4778 // static
4827 void CXFA_FM2JSContext::Str(CFXJSE_Value* pThis, 4779 void CXFA_FM2JSContext::Str(CFXJSE_Value* pThis,
4828 const CFX_ByteStringC& szFuncName, 4780 const CFX_ByteStringC& szFuncName,
4829 CFXJSE_Arguments& args) { 4781 CFXJSE_Arguments& args) {
4830 int32_t argc = args.GetLength(); 4782 int32_t argc = args.GetLength();
4831 if ((argc > 0) && (argc < 4)) { 4783 if ((argc > 0) && (argc < 4)) {
4832 FX_BOOL bFlags = FALSE; 4784 FX_BOOL bFlags = FALSE;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
4931 resultBuf.AppendChar(0); 4883 resultBuf.AppendChar(0);
4932 } 4884 }
4933 } 4885 }
4934 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); 4886 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC());
4935 } else { 4887 } else {
4936 FXJSE_Value_SetNull(args.GetReturnValue()); 4888 FXJSE_Value_SetNull(args.GetReturnValue());
4937 } 4889 }
4938 } else { 4890 } else {
4939 CXFA_FM2JSContext* pContext = 4891 CXFA_FM2JSContext* pContext =
4940 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 4892 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
4941 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 4893 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Str");
4942 L"Str");
4943 } 4894 }
4944 } 4895 }
4945 4896
4946 // static 4897 // static
4947 void CXFA_FM2JSContext::Stuff(CFXJSE_Value* pThis, 4898 void CXFA_FM2JSContext::Stuff(CFXJSE_Value* pThis,
4948 const CFX_ByteStringC& szFuncName, 4899 const CFX_ByteStringC& szFuncName,
4949 CFXJSE_Arguments& args) { 4900 CFXJSE_Arguments& args) {
4950 int32_t argc = args.GetLength(); 4901 int32_t argc = args.GetLength();
4951 if ((argc == 3) || (argc == 4)) { 4902 if ((argc == 3) || (argc == 4)) {
4952 CFX_ByteString sourceString; 4903 CFX_ByteString sourceString;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
4990 i = iStart + iDelete; 4941 i = iStart + iDelete;
4991 while (i < iLength) { 4942 while (i < iLength) {
4992 resultString.AppendChar(sourceString.GetAt(i)); 4943 resultString.AppendChar(sourceString.GetAt(i));
4993 ++i; 4944 ++i;
4994 } 4945 }
4995 resultString.AppendChar(0); 4946 resultString.AppendChar(0);
4996 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); 4947 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC());
4997 } else { 4948 } else {
4998 CXFA_FM2JSContext* pContext = 4949 CXFA_FM2JSContext* pContext =
4999 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 4950 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5000 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 4951 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Stuff");
5001 L"Stuff");
5002 } 4952 }
5003 } 4953 }
5004 4954
5005 // static 4955 // static
5006 void CXFA_FM2JSContext::Substr(CFXJSE_Value* pThis, 4956 void CXFA_FM2JSContext::Substr(CFXJSE_Value* pThis,
5007 const CFX_ByteStringC& szFuncName, 4957 const CFX_ByteStringC& szFuncName,
5008 CFXJSE_Arguments& args) { 4958 CFXJSE_Arguments& args) {
5009 if (args.GetLength() == 3) { 4959 if (args.GetLength() == 3) {
5010 std::unique_ptr<CFXJSE_Value> stringValue = GetSimpleValue(pThis, args, 0); 4960 std::unique_ptr<CFXJSE_Value> stringValue = GetSimpleValue(pThis, args, 0);
5011 std::unique_ptr<CFXJSE_Value> startValue = GetSimpleValue(pThis, args, 1); 4961 std::unique_ptr<CFXJSE_Value> startValue = GetSimpleValue(pThis, args, 1);
(...skipping 23 matching lines...) Expand all
5035 iCount = 0; 4985 iCount = 0;
5036 } 4986 }
5037 iStart -= 1; 4987 iStart -= 1;
5038 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 4988 FXJSE_Value_SetUTF8String(args.GetReturnValue(),
5039 szSourceStr.Mid(iStart, iCount).AsStringC()); 4989 szSourceStr.Mid(iStart, iCount).AsStringC());
5040 } 4990 }
5041 } 4991 }
5042 } else { 4992 } else {
5043 CXFA_FM2JSContext* pContext = 4993 CXFA_FM2JSContext* pContext =
5044 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 4994 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5045 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 4995 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Substr");
5046 L"Substr");
5047 } 4996 }
5048 } 4997 }
5049 4998
5050 // static 4999 // static
5051 void CXFA_FM2JSContext::Uuid(CFXJSE_Value* pThis, 5000 void CXFA_FM2JSContext::Uuid(CFXJSE_Value* pThis,
5052 const CFX_ByteStringC& szFuncName, 5001 const CFX_ByteStringC& szFuncName,
5053 CFXJSE_Arguments& args) { 5002 CFXJSE_Arguments& args) {
5054 int32_t argc = args.GetLength(); 5003 int32_t argc = args.GetLength();
5055 if ((argc == 0) || (argc == 1)) { 5004 if ((argc == 0) || (argc == 1)) {
5056 int32_t iNum = 0; 5005 int32_t iNum = 0;
5057 if (argc == 1) { 5006 if (argc == 1) {
5058 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 5007 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
5059 iNum = (int32_t)ValueToFloat(pThis, argOne.get()); 5008 iNum = (int32_t)ValueToFloat(pThis, argOne.get());
5060 } 5009 }
5061 FX_GUID guid; 5010 FX_GUID guid;
5062 FX_GUID_CreateV4(&guid); 5011 FX_GUID_CreateV4(&guid);
5063 CFX_ByteString bsUId; 5012 CFX_ByteString bsUId;
5064 FX_GUID_ToString(&guid, bsUId, iNum); 5013 FX_GUID_ToString(&guid, bsUId, iNum);
5065 FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsUId.AsStringC()); 5014 FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsUId.AsStringC());
5066 } else { 5015 } else {
5067 CXFA_FM2JSContext* pContext = 5016 CXFA_FM2JSContext* pContext =
5068 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5017 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5069 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 5018 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Uuid");
5070 L"Uuid");
5071 } 5019 }
5072 } 5020 }
5073 5021
5074 // static 5022 // static
5075 void CXFA_FM2JSContext::Upper(CFXJSE_Value* pThis, 5023 void CXFA_FM2JSContext::Upper(CFXJSE_Value* pThis,
5076 const CFX_ByteStringC& szFuncName, 5024 const CFX_ByteStringC& szFuncName,
5077 CFXJSE_Arguments& args) { 5025 CFXJSE_Arguments& args) {
5078 int32_t argc = args.GetLength(); 5026 int32_t argc = args.GetLength();
5079 if ((argc > 0) && (argc < 3)) { 5027 if ((argc > 0) && (argc < 3)) {
5080 CFX_ByteString argString; 5028 CFX_ByteString argString;
(...skipping 23 matching lines...) Expand all
5104 } 5052 }
5105 upperStringBuf.AppendChar(0); 5053 upperStringBuf.AppendChar(0);
5106 FXJSE_Value_SetUTF8String( 5054 FXJSE_Value_SetUTF8String(
5107 args.GetReturnValue(), 5055 args.GetReturnValue(),
5108 FX_UTF8Encode(upperStringBuf.GetBuffer(), upperStringBuf.GetLength()) 5056 FX_UTF8Encode(upperStringBuf.GetBuffer(), upperStringBuf.GetLength())
5109 .AsStringC()); 5057 .AsStringC());
5110 } 5058 }
5111 } else { 5059 } else {
5112 CXFA_FM2JSContext* pContext = 5060 CXFA_FM2JSContext* pContext =
5113 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5061 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5114 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 5062 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Upper");
5115 L"Upper");
5116 } 5063 }
5117 } 5064 }
5118 5065
5119 // static 5066 // static
5120 void CXFA_FM2JSContext::WordNum(CFXJSE_Value* pThis, 5067 void CXFA_FM2JSContext::WordNum(CFXJSE_Value* pThis,
5121 const CFX_ByteStringC& szFuncName, 5068 const CFX_ByteStringC& szFuncName,
5122 CFXJSE_Arguments& args) { 5069 CFXJSE_Arguments& args) {
5123 int32_t argc = args.GetLength(); 5070 int32_t argc = args.GetLength();
5124 if ((argc > 0) && (argc < 4)) { 5071 if ((argc > 0) && (argc < 4)) {
5125 FX_BOOL bFlags = FALSE; 5072 FX_BOOL bFlags = FALSE;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
5159 numberString.Format("%.2f", fNumber); 5106 numberString.Format("%.2f", fNumber);
5160 WordUS(numberString.AsStringC(), iIdentifier, resultBuf); 5107 WordUS(numberString.AsStringC(), iIdentifier, resultBuf);
5161 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); 5108 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC());
5162 } 5109 }
5163 } else { 5110 } else {
5164 FXJSE_Value_SetNull(args.GetReturnValue()); 5111 FXJSE_Value_SetNull(args.GetReturnValue());
5165 } 5112 }
5166 } else { 5113 } else {
5167 CXFA_FM2JSContext* pContext = 5114 CXFA_FM2JSContext* pContext =
5168 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5115 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5169 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 5116 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"WordNum");
5170 L"WordNum");
5171 } 5117 }
5172 } 5118 }
5173 5119
5174 // static 5120 // static
5175 void CXFA_FM2JSContext::TrillionUS(const CFX_ByteStringC& szData, 5121 void CXFA_FM2JSContext::TrillionUS(const CFX_ByteStringC& szData,
5176 CFX_ByteTextBuf& strBuf) { 5122 CFX_ByteTextBuf& strBuf) {
5177 CFX_ByteStringC pUnits[] = {"zero", "one", "two", "three", "four", 5123 CFX_ByteStringC pUnits[] = {"zero", "one", "two", "three", "four",
5178 "five", "six", "seven", "eight", "nine"}; 5124 "five", "six", "seven", "eight", "nine"};
5179 CFX_ByteStringC pCapUnits[] = {"Zero", "One", "Two", "Three", "Four", 5125 CFX_ByteStringC pCapUnits[] = {"Zero", "One", "Two", "Three", "Four",
5180 "Five", "Six", "Seven", "Eight", "Nine"}; 5126 "Five", "Six", "Seven", "Eight", "Nine"};
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
5394 if (pFile) { 5340 if (pFile) {
5395 int32_t size = pFile->GetSize(); 5341 int32_t size = pFile->GetSize();
5396 uint8_t* pData = FX_Alloc(uint8_t, size); 5342 uint8_t* pData = FX_Alloc(uint8_t, size);
5397 pFile->ReadBlock(pData, size); 5343 pFile->ReadBlock(pData, size);
5398 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 5344 FXJSE_Value_SetUTF8String(args.GetReturnValue(),
5399 CFX_ByteStringC(pData, size)); 5345 CFX_ByteStringC(pData, size));
5400 FX_Free(pData); 5346 FX_Free(pData);
5401 pFile->Release(); 5347 pFile->Release();
5402 } 5348 }
5403 } else { 5349 } else {
5404 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 5350 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Get");
5405 L"Get");
5406 } 5351 }
5407 } 5352 }
5408 5353
5409 // static 5354 // static
5410 void CXFA_FM2JSContext::Post(CFXJSE_Value* pThis, 5355 void CXFA_FM2JSContext::Post(CFXJSE_Value* pThis,
5411 const CFX_ByteStringC& szFuncName, 5356 const CFX_ByteStringC& szFuncName,
5412 CFXJSE_Arguments& args) { 5357 CFXJSE_Arguments& args) {
5413 CXFA_FM2JSContext* pContext = 5358 CXFA_FM2JSContext* pContext =
5414 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5359 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5415 int32_t argc = args.GetLength(); 5360 int32_t argc = args.GetLength();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
5450 CFX_WideString::FromUTF8(bsData.AsStringC()), 5395 CFX_WideString::FromUTF8(bsData.AsStringC()),
5451 CFX_WideString::FromUTF8(bsContentType.AsStringC()), 5396 CFX_WideString::FromUTF8(bsContentType.AsStringC()),
5452 CFX_WideString::FromUTF8(bsEncode.AsStringC()), 5397 CFX_WideString::FromUTF8(bsEncode.AsStringC()),
5453 CFX_WideString::FromUTF8(bsHeader.AsStringC()), decodedResponse); 5398 CFX_WideString::FromUTF8(bsHeader.AsStringC()), decodedResponse);
5454 if (bFlags) { 5399 if (bFlags) {
5455 FXJSE_Value_SetUTF8String( 5400 FXJSE_Value_SetUTF8String(
5456 args.GetReturnValue(), 5401 args.GetReturnValue(),
5457 FX_UTF8Encode(decodedResponse.c_str(), decodedResponse.GetLength()) 5402 FX_UTF8Encode(decodedResponse.c_str(), decodedResponse.GetLength())
5458 .AsStringC()); 5403 .AsStringC());
5459 } else { 5404 } else {
5460 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); 5405 pContext->ThrowException(XFA_IDS_SERVER_DENY);
5461 } 5406 }
5462 } else { 5407 } else {
5463 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 5408 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Post");
5464 L"Post");
5465 } 5409 }
5466 } 5410 }
5467 5411
5468 // static 5412 // static
5469 void CXFA_FM2JSContext::Put(CFXJSE_Value* pThis, 5413 void CXFA_FM2JSContext::Put(CFXJSE_Value* pThis,
5470 const CFX_ByteStringC& szFuncName, 5414 const CFX_ByteStringC& szFuncName,
5471 CFXJSE_Arguments& args) { 5415 CFXJSE_Arguments& args) {
5472 CXFA_FM2JSContext* pContext = 5416 CXFA_FM2JSContext* pContext =
5473 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5417 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5474 int32_t argc = args.GetLength(); 5418 int32_t argc = args.GetLength();
(...skipping 18 matching lines...) Expand all
5493 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 5437 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
5494 ValueToUTF8String(argThree.get(), bsEncode); 5438 ValueToUTF8String(argThree.get(), bsEncode);
5495 } 5439 }
5496 FX_BOOL bFlags = pAppProvider->PutRequestURL( 5440 FX_BOOL bFlags = pAppProvider->PutRequestURL(
5497 CFX_WideString::FromUTF8(bsURL.AsStringC()), 5441 CFX_WideString::FromUTF8(bsURL.AsStringC()),
5498 CFX_WideString::FromUTF8(bsData.AsStringC()), 5442 CFX_WideString::FromUTF8(bsData.AsStringC()),
5499 CFX_WideString::FromUTF8(bsEncode.AsStringC())); 5443 CFX_WideString::FromUTF8(bsEncode.AsStringC()));
5500 if (bFlags) { 5444 if (bFlags) {
5501 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); 5445 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "");
5502 } else { 5446 } else {
5503 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); 5447 pContext->ThrowException(XFA_IDS_SERVER_DENY);
5504 } 5448 }
5505 } else { 5449 } else {
5506 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 5450 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Put");
5507 L"Put");
5508 } 5451 }
5509 } 5452 }
5510 5453
5511 // static 5454 // static
5512 void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis, 5455 void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis,
5513 const CFX_ByteStringC& szFuncName, 5456 const CFX_ByteStringC& szFuncName,
5514 CFXJSE_Arguments& args) { 5457 CFXJSE_Arguments& args) {
5515 CXFA_FM2JSContext* pContext = 5458 CXFA_FM2JSContext* pContext =
5516 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5459 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5517 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 5460 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
5518 if (args.GetLength() == 2) { 5461 if (args.GetLength() == 2) {
5519 std::unique_ptr<CFXJSE_Value> lValue = args.GetValue(0); 5462 std::unique_ptr<CFXJSE_Value> lValue = args.GetValue(0);
5520 std::unique_ptr<CFXJSE_Value> rValue = GetSimpleValue(pThis, args, 1); 5463 std::unique_ptr<CFXJSE_Value> rValue = GetSimpleValue(pThis, args, 1);
5521 FX_BOOL bSetStatus = TRUE; 5464 FX_BOOL bSetStatus = TRUE;
5522 if (FXJSE_Value_IsArray(lValue.get())) { 5465 if (FXJSE_Value_IsArray(lValue.get())) {
5523 std::unique_ptr<CFXJSE_Value> leftLengthValue(new CFXJSE_Value(pIsolate)); 5466 std::unique_ptr<CFXJSE_Value> leftLengthValue(new CFXJSE_Value(pIsolate));
5524 FXJSE_Value_GetObjectProp(lValue.get(), "length", leftLengthValue.get()); 5467 FXJSE_Value_GetObjectProp(lValue.get(), "length", leftLengthValue.get());
5525 int32_t iLeftLength = FXJSE_Value_ToInteger(leftLengthValue.get()); 5468 int32_t iLeftLength = FXJSE_Value_ToInteger(leftLengthValue.get());
5526 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 5469 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
5527 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 5470 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
5528 FXJSE_Value_GetObjectPropByIdx(lValue.get(), 1, propertyValue.get()); 5471 FXJSE_Value_GetObjectPropByIdx(lValue.get(), 1, propertyValue.get());
5529 if (FXJSE_Value_IsNull(propertyValue.get())) { 5472 if (FXJSE_Value_IsNull(propertyValue.get())) {
5530 for (int32_t i = 2; i < iLeftLength; i++) { 5473 for (int32_t i = 2; i < iLeftLength; i++) {
5531 FXJSE_Value_GetObjectPropByIdx(lValue.get(), i, jsObjectValue.get()); 5474 FXJSE_Value_GetObjectPropByIdx(lValue.get(), i, jsObjectValue.get());
5532 bSetStatus = SetObjectDefaultValue(jsObjectValue.get(), rValue.get()); 5475 bSetStatus = SetObjectDefaultValue(jsObjectValue.get(), rValue.get());
5533 if (!bSetStatus) { 5476 if (!bSetStatus) {
5534 pContext->ThrowScriptErrorMessage(XFA_IDS_NOT_DEFAUL_VALUE); 5477 pContext->ThrowException(XFA_IDS_NOT_DEFAUL_VALUE);
5535 break; 5478 break;
5536 } 5479 }
5537 } 5480 }
5538 } else { 5481 } else {
5539 CFX_ByteString propertyStr; 5482 CFX_ByteString propertyStr;
5540 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); 5483 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr);
5541 for (int32_t i = 2; i < iLeftLength; i++) { 5484 for (int32_t i = 2; i < iLeftLength; i++) {
5542 FXJSE_Value_GetObjectPropByIdx(lValue.get(), i, jsObjectValue.get()); 5485 FXJSE_Value_GetObjectPropByIdx(lValue.get(), i, jsObjectValue.get());
5543 FXJSE_Value_SetObjectProp(jsObjectValue.get(), 5486 FXJSE_Value_SetObjectProp(jsObjectValue.get(),
5544 propertyStr.AsStringC(), rValue.get()); 5487 propertyStr.AsStringC(), rValue.get());
5545 } 5488 }
5546 } 5489 }
5547 } else if (FXJSE_Value_IsObject(lValue.get())) { 5490 } else if (FXJSE_Value_IsObject(lValue.get())) {
5548 bSetStatus = SetObjectDefaultValue(lValue.get(), rValue.get()); 5491 bSetStatus = SetObjectDefaultValue(lValue.get(), rValue.get());
5549 if (!bSetStatus) { 5492 if (!bSetStatus) {
5550 pContext->ThrowScriptErrorMessage(XFA_IDS_NOT_DEFAUL_VALUE); 5493 pContext->ThrowException(XFA_IDS_NOT_DEFAUL_VALUE);
5551 } 5494 }
5552 } 5495 }
5553 FXJSE_Value_Set(args.GetReturnValue(), rValue.get()); 5496 FXJSE_Value_Set(args.GetReturnValue(), rValue.get());
5554 } else { 5497 } else {
5555 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 5498 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5556 } 5499 }
5557 } 5500 }
5558 5501
5559 // static 5502 // static
5560 void CXFA_FM2JSContext::logical_or_operator(CFXJSE_Value* pThis, 5503 void CXFA_FM2JSContext::logical_or_operator(CFXJSE_Value* pThis,
5561 const CFX_ByteStringC& szFuncName, 5504 const CFX_ByteStringC& szFuncName,
5562 CFXJSE_Arguments& args) { 5505 CFXJSE_Arguments& args) {
5563 if (args.GetLength() == 2) { 5506 if (args.GetLength() == 2) {
5564 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5507 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
5565 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5508 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
5566 if (FXJSE_Value_IsNull(argFirst.get()) && 5509 if (FXJSE_Value_IsNull(argFirst.get()) &&
5567 FXJSE_Value_IsNull(argSecond.get())) { 5510 FXJSE_Value_IsNull(argSecond.get())) {
5568 FXJSE_Value_SetNull(args.GetReturnValue()); 5511 FXJSE_Value_SetNull(args.GetReturnValue());
5569 } else { 5512 } else {
5570 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); 5513 FX_FLOAT first = ValueToFloat(pThis, argFirst.get());
5571 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); 5514 FX_FLOAT second = ValueToFloat(pThis, argSecond.get());
5572 FXJSE_Value_SetInteger(args.GetReturnValue(), (first || second) ? 1 : 0); 5515 FXJSE_Value_SetInteger(args.GetReturnValue(), (first || second) ? 1 : 0);
5573 } 5516 }
5574 } else { 5517 } else {
5575 CXFA_FM2JSContext* pContext = 5518 CXFA_FM2JSContext* pContext =
5576 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5519 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5577 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 5520 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5578 } 5521 }
5579 } 5522 }
5580 5523
5581 // static 5524 // static
5582 void CXFA_FM2JSContext::logical_and_operator(CFXJSE_Value* pThis, 5525 void CXFA_FM2JSContext::logical_and_operator(CFXJSE_Value* pThis,
5583 const CFX_ByteStringC& szFuncName, 5526 const CFX_ByteStringC& szFuncName,
5584 CFXJSE_Arguments& args) { 5527 CFXJSE_Arguments& args) {
5585 if (args.GetLength() == 2) { 5528 if (args.GetLength() == 2) {
5586 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5529 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
5587 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5530 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
5588 if (FXJSE_Value_IsNull(argFirst.get()) && 5531 if (FXJSE_Value_IsNull(argFirst.get()) &&
5589 FXJSE_Value_IsNull(argSecond.get())) { 5532 FXJSE_Value_IsNull(argSecond.get())) {
5590 FXJSE_Value_SetNull(args.GetReturnValue()); 5533 FXJSE_Value_SetNull(args.GetReturnValue());
5591 } else { 5534 } else {
5592 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); 5535 FX_FLOAT first = ValueToFloat(pThis, argFirst.get());
5593 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); 5536 FX_FLOAT second = ValueToFloat(pThis, argSecond.get());
5594 FXJSE_Value_SetInteger(args.GetReturnValue(), (first && second) ? 1 : 0); 5537 FXJSE_Value_SetInteger(args.GetReturnValue(), (first && second) ? 1 : 0);
5595 } 5538 }
5596 } else { 5539 } else {
5597 CXFA_FM2JSContext* pContext = 5540 CXFA_FM2JSContext* pContext =
5598 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5541 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5599 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 5542 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5600 } 5543 }
5601 } 5544 }
5602 5545
5603 // static 5546 // static
5604 void CXFA_FM2JSContext::equality_operator(CFXJSE_Value* pThis, 5547 void CXFA_FM2JSContext::equality_operator(CFXJSE_Value* pThis,
5605 const CFX_ByteStringC& szFuncName, 5548 const CFX_ByteStringC& szFuncName,
5606 CFXJSE_Arguments& args) { 5549 CFXJSE_Arguments& args) {
5607 if (args.GetLength() == 2) { 5550 if (args.GetLength() == 2) {
5608 if (fm_ref_equal(pThis, args)) { 5551 if (fm_ref_equal(pThis, args)) {
5609 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); 5552 FXJSE_Value_SetInteger(args.GetReturnValue(), 1);
(...skipping 18 matching lines...) Expand all
5628 } else { 5571 } else {
5629 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5572 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5630 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5573 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5631 FXJSE_Value_SetInteger(args.GetReturnValue(), 5574 FXJSE_Value_SetInteger(args.GetReturnValue(),
5632 (first == second) ? 1 : 0); 5575 (first == second) ? 1 : 0);
5633 } 5576 }
5634 } 5577 }
5635 } else { 5578 } else {
5636 CXFA_FM2JSContext* pContext = 5579 CXFA_FM2JSContext* pContext =
5637 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5580 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5638 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 5581 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5639 } 5582 }
5640 } 5583 }
5641 5584
5642 // static 5585 // static
5643 void CXFA_FM2JSContext::notequality_operator(CFXJSE_Value* pThis, 5586 void CXFA_FM2JSContext::notequality_operator(CFXJSE_Value* pThis,
5644 const CFX_ByteStringC& szFuncName, 5587 const CFX_ByteStringC& szFuncName,
5645 CFXJSE_Arguments& args) { 5588 CFXJSE_Arguments& args) {
5646 if (args.GetLength() == 2) { 5589 if (args.GetLength() == 2) {
5647 if (fm_ref_equal(pThis, args)) { 5590 if (fm_ref_equal(pThis, args)) {
5648 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); 5591 FXJSE_Value_SetInteger(args.GetReturnValue(), 0);
(...skipping 17 matching lines...) Expand all
5666 firstOutput != secondOutput); 5609 firstOutput != secondOutput);
5667 } else { 5610 } else {
5668 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5611 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5669 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5612 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5670 FXJSE_Value_SetInteger(args.GetReturnValue(), first != second); 5613 FXJSE_Value_SetInteger(args.GetReturnValue(), first != second);
5671 } 5614 }
5672 } 5615 }
5673 } else { 5616 } else {
5674 CXFA_FM2JSContext* pContext = 5617 CXFA_FM2JSContext* pContext =
5675 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5618 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5676 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 5619 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5677 } 5620 }
5678 } 5621 }
5679 5622
5680 // static 5623 // static
5681 FX_BOOL CXFA_FM2JSContext::fm_ref_equal(CFXJSE_Value* pThis, 5624 FX_BOOL CXFA_FM2JSContext::fm_ref_equal(CFXJSE_Value* pThis,
5682 CFXJSE_Arguments& args) { 5625 CFXJSE_Arguments& args) {
5683 FX_BOOL bRet = FALSE; 5626 FX_BOOL bRet = FALSE;
5684 CXFA_FM2JSContext* pContext = 5627 CXFA_FM2JSContext* pContext =
5685 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5628 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5686 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 5629 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
5728 args.GetReturnValue(), 5671 args.GetReturnValue(),
5729 firstOutput.Compare(secondOutput.AsStringC()) == -1); 5672 firstOutput.Compare(secondOutput.AsStringC()) == -1);
5730 } else { 5673 } else {
5731 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5674 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5732 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5675 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5733 FXJSE_Value_SetInteger(args.GetReturnValue(), (first < second) ? 1 : 0); 5676 FXJSE_Value_SetInteger(args.GetReturnValue(), (first < second) ? 1 : 0);
5734 } 5677 }
5735 } else { 5678 } else {
5736 CXFA_FM2JSContext* pContext = 5679 CXFA_FM2JSContext* pContext =
5737 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5680 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5738 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 5681 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5739 } 5682 }
5740 } 5683 }
5741 5684
5742 // static 5685 // static
5743 void CXFA_FM2JSContext::lessequal_operator(CFXJSE_Value* pThis, 5686 void CXFA_FM2JSContext::lessequal_operator(CFXJSE_Value* pThis,
5744 const CFX_ByteStringC& szFuncName, 5687 const CFX_ByteStringC& szFuncName,
5745 CFXJSE_Arguments& args) { 5688 CFXJSE_Arguments& args) {
5746 if (args.GetLength() == 2) { 5689 if (args.GetLength() == 2) {
5747 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5690 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
5748 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5691 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
(...skipping 14 matching lines...) Expand all
5763 args.GetReturnValue(), 5706 args.GetReturnValue(),
5764 firstOutput.Compare(secondOutput.AsStringC()) != 1); 5707 firstOutput.Compare(secondOutput.AsStringC()) != 1);
5765 } else { 5708 } else {
5766 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5709 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5767 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5710 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5768 FXJSE_Value_SetInteger(args.GetReturnValue(), (first <= second) ? 1 : 0); 5711 FXJSE_Value_SetInteger(args.GetReturnValue(), (first <= second) ? 1 : 0);
5769 } 5712 }
5770 } else { 5713 } else {
5771 CXFA_FM2JSContext* pContext = 5714 CXFA_FM2JSContext* pContext =
5772 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5715 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5773 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 5716 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5774 } 5717 }
5775 } 5718 }
5776 5719
5777 // static 5720 // static
5778 void CXFA_FM2JSContext::greater_operator(CFXJSE_Value* pThis, 5721 void CXFA_FM2JSContext::greater_operator(CFXJSE_Value* pThis,
5779 const CFX_ByteStringC& szFuncName, 5722 const CFX_ByteStringC& szFuncName,
5780 CFXJSE_Arguments& args) { 5723 CFXJSE_Arguments& args) {
5781 if (args.GetLength() == 2) { 5724 if (args.GetLength() == 2) {
5782 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5725 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
5783 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5726 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
(...skipping 10 matching lines...) Expand all
5794 args.GetReturnValue(), 5737 args.GetReturnValue(),
5795 firstOutput.Compare(secondOutput.AsStringC()) == 1); 5738 firstOutput.Compare(secondOutput.AsStringC()) == 1);
5796 } else { 5739 } else {
5797 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5740 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5798 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5741 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5799 FXJSE_Value_SetInteger(args.GetReturnValue(), (first > second) ? 1 : 0); 5742 FXJSE_Value_SetInteger(args.GetReturnValue(), (first > second) ? 1 : 0);
5800 } 5743 }
5801 } else { 5744 } else {
5802 CXFA_FM2JSContext* pContext = 5745 CXFA_FM2JSContext* pContext =
5803 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5746 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5804 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 5747 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5805 } 5748 }
5806 } 5749 }
5807 5750
5808 // static 5751 // static
5809 void CXFA_FM2JSContext::greaterequal_operator(CFXJSE_Value* pThis, 5752 void CXFA_FM2JSContext::greaterequal_operator(CFXJSE_Value* pThis,
5810 const CFX_ByteStringC& szFuncName, 5753 const CFX_ByteStringC& szFuncName,
5811 CFXJSE_Arguments& args) { 5754 CFXJSE_Arguments& args) {
5812 if (args.GetLength() == 2) { 5755 if (args.GetLength() == 2) {
5813 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5756 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
5814 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5757 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
(...skipping 14 matching lines...) Expand all
5829 args.GetReturnValue(), 5772 args.GetReturnValue(),
5830 firstOutput.Compare(secondOutput.AsStringC()) != -1); 5773 firstOutput.Compare(secondOutput.AsStringC()) != -1);
5831 } else { 5774 } else {
5832 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5775 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5833 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5776 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5834 FXJSE_Value_SetInteger(args.GetReturnValue(), (first >= second) ? 1 : 0); 5777 FXJSE_Value_SetInteger(args.GetReturnValue(), (first >= second) ? 1 : 0);
5835 } 5778 }
5836 } else { 5779 } else {
5837 CXFA_FM2JSContext* pContext = 5780 CXFA_FM2JSContext* pContext =
5838 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5781 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5839 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 5782 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5840 } 5783 }
5841 } 5784 }
5842 5785
5843 // static 5786 // static
5844 void CXFA_FM2JSContext::plus_operator(CFXJSE_Value* pThis, 5787 void CXFA_FM2JSContext::plus_operator(CFXJSE_Value* pThis,
5845 const CFX_ByteStringC& szFuncName, 5788 const CFX_ByteStringC& szFuncName,
5846 CFXJSE_Arguments& args) { 5789 CFXJSE_Arguments& args) {
5847 if (args.GetLength() == 2) { 5790 if (args.GetLength() == 2) {
5848 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0); 5791 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0);
5849 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1); 5792 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1);
5850 if (ValueIsNull(pThis, argFirst.get()) && 5793 if (ValueIsNull(pThis, argFirst.get()) &&
5851 ValueIsNull(pThis, argSecond.get())) { 5794 ValueIsNull(pThis, argSecond.get())) {
5852 FXJSE_Value_SetNull(args.GetReturnValue()); 5795 FXJSE_Value_SetNull(args.GetReturnValue());
5853 } else { 5796 } else {
5854 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5797 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5855 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5798 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5856 FXJSE_Value_SetDouble(args.GetReturnValue(), first + second); 5799 FXJSE_Value_SetDouble(args.GetReturnValue(), first + second);
5857 } 5800 }
5858 } else { 5801 } else {
5859 CXFA_FM2JSContext* pContext = 5802 CXFA_FM2JSContext* pContext =
5860 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5803 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5861 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 5804 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5862 } 5805 }
5863 } 5806 }
5864 5807
5865 // static 5808 // static
5866 void CXFA_FM2JSContext::minus_operator(CFXJSE_Value* pThis, 5809 void CXFA_FM2JSContext::minus_operator(CFXJSE_Value* pThis,
5867 const CFX_ByteStringC& szFuncName, 5810 const CFX_ByteStringC& szFuncName,
5868 CFXJSE_Arguments& args) { 5811 CFXJSE_Arguments& args) {
5869 if (args.GetLength() == 2) { 5812 if (args.GetLength() == 2) {
5870 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5813 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
5871 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5814 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
5872 if (FXJSE_Value_IsNull(argFirst.get()) && 5815 if (FXJSE_Value_IsNull(argFirst.get()) &&
5873 FXJSE_Value_IsNull(argSecond.get())) { 5816 FXJSE_Value_IsNull(argSecond.get())) {
5874 FXJSE_Value_SetNull(args.GetReturnValue()); 5817 FXJSE_Value_SetNull(args.GetReturnValue());
5875 } else { 5818 } else {
5876 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5819 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5877 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5820 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5878 FXJSE_Value_SetDouble(args.GetReturnValue(), first - second); 5821 FXJSE_Value_SetDouble(args.GetReturnValue(), first - second);
5879 } 5822 }
5880 } else { 5823 } else {
5881 CXFA_FM2JSContext* pContext = 5824 CXFA_FM2JSContext* pContext =
5882 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5825 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5883 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 5826 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5884 } 5827 }
5885 } 5828 }
5886 5829
5887 // static 5830 // static
5888 void CXFA_FM2JSContext::multiple_operator(CFXJSE_Value* pThis, 5831 void CXFA_FM2JSContext::multiple_operator(CFXJSE_Value* pThis,
5889 const CFX_ByteStringC& szFuncName, 5832 const CFX_ByteStringC& szFuncName,
5890 CFXJSE_Arguments& args) { 5833 CFXJSE_Arguments& args) {
5891 if (args.GetLength() == 2) { 5834 if (args.GetLength() == 2) {
5892 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5835 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
5893 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5836 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
5894 if (FXJSE_Value_IsNull(argFirst.get()) && 5837 if (FXJSE_Value_IsNull(argFirst.get()) &&
5895 FXJSE_Value_IsNull(argSecond.get())) { 5838 FXJSE_Value_IsNull(argSecond.get())) {
5896 FXJSE_Value_SetNull(args.GetReturnValue()); 5839 FXJSE_Value_SetNull(args.GetReturnValue());
5897 } else { 5840 } else {
5898 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5841 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5899 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5842 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5900 FXJSE_Value_SetDouble(args.GetReturnValue(), first * second); 5843 FXJSE_Value_SetDouble(args.GetReturnValue(), first * second);
5901 } 5844 }
5902 } else { 5845 } else {
5903 CXFA_FM2JSContext* pContext = 5846 CXFA_FM2JSContext* pContext =
5904 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5847 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5905 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 5848 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5906 } 5849 }
5907 } 5850 }
5908 5851
5909 // static 5852 // static
5910 void CXFA_FM2JSContext::divide_operator(CFXJSE_Value* pThis, 5853 void CXFA_FM2JSContext::divide_operator(CFXJSE_Value* pThis,
5911 const CFX_ByteStringC& szFuncName, 5854 const CFX_ByteStringC& szFuncName,
5912 CFXJSE_Arguments& args) { 5855 CFXJSE_Arguments& args) {
5913 CXFA_FM2JSContext* pContext = 5856 CXFA_FM2JSContext* pContext =
5914 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5857 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5915 if (args.GetLength() == 2) { 5858 if (args.GetLength() == 2) {
5916 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5859 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
5917 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5860 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
5918 if (FXJSE_Value_IsNull(argFirst.get()) && 5861 if (FXJSE_Value_IsNull(argFirst.get()) &&
5919 FXJSE_Value_IsNull(argSecond.get())) { 5862 FXJSE_Value_IsNull(argSecond.get())) {
5920 FXJSE_Value_SetNull(args.GetReturnValue()); 5863 FXJSE_Value_SetNull(args.GetReturnValue());
5921 } else { 5864 } else {
5922 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5865 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5923 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5866 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5924 if (second == 0.0) { 5867 if (second == 0.0) {
5925 pContext->ThrowScriptErrorMessage(XFA_IDS_DIVIDE_ZERO); 5868 pContext->ThrowException(XFA_IDS_DIVIDE_ZERO);
5926 } else { 5869 } else {
5927 FXJSE_Value_SetDouble(args.GetReturnValue(), first / second); 5870 FXJSE_Value_SetDouble(args.GetReturnValue(), first / second);
5928 } 5871 }
5929 } 5872 }
5930 } else { 5873 } else {
5931 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 5874 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5932 } 5875 }
5933 } 5876 }
5934 5877
5935 // static 5878 // static
5936 void CXFA_FM2JSContext::positive_operator(CFXJSE_Value* pThis, 5879 void CXFA_FM2JSContext::positive_operator(CFXJSE_Value* pThis,
5937 const CFX_ByteStringC& szFuncName, 5880 const CFX_ByteStringC& szFuncName,
5938 CFXJSE_Arguments& args) { 5881 CFXJSE_Arguments& args) {
5939 if (args.GetLength() == 1) { 5882 if (args.GetLength() == 1) {
5940 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 5883 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
5941 if (FXJSE_Value_IsNull(argOne.get())) { 5884 if (FXJSE_Value_IsNull(argOne.get())) {
5942 FXJSE_Value_SetNull(args.GetReturnValue()); 5885 FXJSE_Value_SetNull(args.GetReturnValue());
5943 } else { 5886 } else {
5944 FXJSE_Value_SetDouble(args.GetReturnValue(), 5887 FXJSE_Value_SetDouble(args.GetReturnValue(),
5945 0.0 + ValueToDouble(pThis, argOne.get())); 5888 0.0 + ValueToDouble(pThis, argOne.get()));
5946 } 5889 }
5947 } else { 5890 } else {
5948 CXFA_FM2JSContext* pContext = 5891 CXFA_FM2JSContext* pContext =
5949 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5892 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5950 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 5893 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5951 } 5894 }
5952 } 5895 }
5953 5896
5954 // static 5897 // static
5955 void CXFA_FM2JSContext::negative_operator(CFXJSE_Value* pThis, 5898 void CXFA_FM2JSContext::negative_operator(CFXJSE_Value* pThis,
5956 const CFX_ByteStringC& szFuncName, 5899 const CFX_ByteStringC& szFuncName,
5957 CFXJSE_Arguments& args) { 5900 CFXJSE_Arguments& args) {
5958 if (args.GetLength() == 1) { 5901 if (args.GetLength() == 1) {
5959 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 5902 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
5960 if (FXJSE_Value_IsNull(argOne.get())) { 5903 if (FXJSE_Value_IsNull(argOne.get())) {
5961 FXJSE_Value_SetNull(args.GetReturnValue()); 5904 FXJSE_Value_SetNull(args.GetReturnValue());
5962 } else { 5905 } else {
5963 FXJSE_Value_SetDouble(args.GetReturnValue(), 5906 FXJSE_Value_SetDouble(args.GetReturnValue(),
5964 0.0 - ValueToDouble(pThis, argOne.get())); 5907 0.0 - ValueToDouble(pThis, argOne.get()));
5965 } 5908 }
5966 } else { 5909 } else {
5967 CXFA_FM2JSContext* pContext = 5910 CXFA_FM2JSContext* pContext =
5968 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5911 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5969 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 5912 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5970 } 5913 }
5971 } 5914 }
5972 5915
5973 // static 5916 // static
5974 void CXFA_FM2JSContext::logical_not_operator(CFXJSE_Value* pThis, 5917 void CXFA_FM2JSContext::logical_not_operator(CFXJSE_Value* pThis,
5975 const CFX_ByteStringC& szFuncName, 5918 const CFX_ByteStringC& szFuncName,
5976 CFXJSE_Arguments& args) { 5919 CFXJSE_Arguments& args) {
5977 if (args.GetLength() == 1) { 5920 if (args.GetLength() == 1) {
5978 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 5921 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
5979 if (FXJSE_Value_IsNull(argOne.get())) { 5922 if (FXJSE_Value_IsNull(argOne.get())) {
5980 FXJSE_Value_SetNull(args.GetReturnValue()); 5923 FXJSE_Value_SetNull(args.GetReturnValue());
5981 } else { 5924 } else {
5982 FX_DOUBLE first = ValueToDouble(pThis, argOne.get()); 5925 FX_DOUBLE first = ValueToDouble(pThis, argOne.get());
5983 FXJSE_Value_SetInteger(args.GetReturnValue(), (first == 0.0) ? 1 : 0); 5926 FXJSE_Value_SetInteger(args.GetReturnValue(), (first == 0.0) ? 1 : 0);
5984 } 5927 }
5985 } else { 5928 } else {
5986 CXFA_FM2JSContext* pContext = 5929 CXFA_FM2JSContext* pContext =
5987 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5930 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5988 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 5931 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5989 } 5932 }
5990 } 5933 }
5991 5934
5992 // static 5935 // static
5993 void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis, 5936 void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis,
5994 const CFX_ByteStringC& szFuncName, 5937 const CFX_ByteStringC& szFuncName,
5995 CFXJSE_Arguments& args) { 5938 CFXJSE_Arguments& args) {
5996 CXFA_FM2JSContext* pContext = 5939 CXFA_FM2JSContext* pContext =
5997 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5940 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5998 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 5941 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
6058 FXJSE_Value_SetArray(args.GetReturnValue(), (iCounter + 2), rgValues); 6001 FXJSE_Value_SetArray(args.GetReturnValue(), (iCounter + 2), rgValues);
6059 for (int32_t i = 0; i < (iCounter + 2); i++) 6002 for (int32_t i = 0; i < (iCounter + 2); i++)
6060 delete rgValues[i]; 6003 delete rgValues[i];
6061 6004
6062 FX_Free(rgValues); 6005 FX_Free(rgValues);
6063 } else { 6006 } else {
6064 CFX_WideString wsPropertyName = 6007 CFX_WideString wsPropertyName =
6065 CFX_WideString::FromUTF8(szName.AsStringC()); 6008 CFX_WideString::FromUTF8(szName.AsStringC());
6066 CFX_WideString wsSomExpression = 6009 CFX_WideString wsSomExpression =
6067 CFX_WideString::FromUTF8(szSomExp.AsStringC()); 6010 CFX_WideString::FromUTF8(szSomExp.AsStringC());
6068 pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, 6011 pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
6069 wsPropertyName.c_str(), 6012 wsPropertyName.c_str(),
6070 wsSomExpression.c_str()); 6013 wsSomExpression.c_str());
6071 } 6014 }
6072 for (int32_t i = 0; i < iLength - 2; i++) { 6015 for (int32_t i = 0; i < iLength - 2; i++) {
6073 for (int32_t j = 0; j < iSizes[i]; j++) 6016 for (int32_t j = 0; j < iSizes[i]; j++)
6074 delete hResolveValues[i][j]; 6017 delete hResolveValues[i][j];
6075 6018
6076 if (iSizes[i] > 0) { 6019 if (iSizes[i] > 0) {
6077 FX_Free(hResolveValues[i]); 6020 FX_Free(hResolveValues[i]);
6078 } 6021 }
6079 } 6022 }
6080 FX_Free(hResolveValues); 6023 FX_Free(hResolveValues);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
6121 FX_Free(rgValues); 6064 FX_Free(rgValues);
6122 for (int32_t i = 0; i < iSize; i++) 6065 for (int32_t i = 0; i < iSize; i++)
6123 delete hResolveValues[i]; 6066 delete hResolveValues[i];
6124 6067
6125 FX_Free(hResolveValues); 6068 FX_Free(hResolveValues);
6126 } else { 6069 } else {
6127 CFX_WideString wsPropertyName = 6070 CFX_WideString wsPropertyName =
6128 CFX_WideString::FromUTF8(szName.AsStringC()); 6071 CFX_WideString::FromUTF8(szName.AsStringC());
6129 CFX_WideString wsSomExpression = 6072 CFX_WideString wsSomExpression =
6130 CFX_WideString::FromUTF8(szSomExp.AsStringC()); 6073 CFX_WideString::FromUTF8(szSomExp.AsStringC());
6131 pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, 6074 pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
6132 wsPropertyName.c_str(), 6075 wsPropertyName.c_str(),
6133 wsSomExpression.c_str()); 6076 wsSomExpression.c_str());
6134 } 6077 }
6135 } 6078 }
6136 } else { 6079 } else {
6137 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 6080 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
6138 } 6081 }
6139 } 6082 }
6140 6083
6141 // static 6084 // static
6142 void CXFA_FM2JSContext::dotdot_accessor(CFXJSE_Value* pThis, 6085 void CXFA_FM2JSContext::dotdot_accessor(CFXJSE_Value* pThis,
6143 const CFX_ByteStringC& szFuncName, 6086 const CFX_ByteStringC& szFuncName,
6144 CFXJSE_Arguments& args) { 6087 CFXJSE_Arguments& args) {
6145 CXFA_FM2JSContext* pContext = 6088 CXFA_FM2JSContext* pContext =
6146 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 6089 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
6147 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 6090 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
6204 FXJSE_Value_SetArray(args.GetReturnValue(), (iCounter + 2), rgValues); 6147 FXJSE_Value_SetArray(args.GetReturnValue(), (iCounter + 2), rgValues);
6205 for (int32_t i = 0; i < (iCounter + 2); i++) 6148 for (int32_t i = 0; i < (iCounter + 2); i++)
6206 delete rgValues[i]; 6149 delete rgValues[i];
6207 6150
6208 FX_Free(rgValues); 6151 FX_Free(rgValues);
6209 } else { 6152 } else {
6210 CFX_WideString wsPropertyName = 6153 CFX_WideString wsPropertyName =
6211 CFX_WideString::FromUTF8(szName.AsStringC()); 6154 CFX_WideString::FromUTF8(szName.AsStringC());
6212 CFX_WideString wsSomExpression = 6155 CFX_WideString wsSomExpression =
6213 CFX_WideString::FromUTF8(szSomExp.AsStringC()); 6156 CFX_WideString::FromUTF8(szSomExp.AsStringC());
6214 pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, 6157 pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
6215 wsPropertyName.c_str(), 6158 wsPropertyName.c_str(),
6216 wsSomExpression.c_str()); 6159 wsSomExpression.c_str());
6217 } 6160 }
6218 for (int32_t i = 0; i < iLength - 2; i++) { 6161 for (int32_t i = 0; i < iLength - 2; i++) {
6219 for (int32_t j = 0; j < iSizes[i]; j++) 6162 for (int32_t j = 0; j < iSizes[i]; j++)
6220 delete hResolveValues[i][j]; 6163 delete hResolveValues[i][j];
6221 6164
6222 FX_Free(hResolveValues[i]); 6165 FX_Free(hResolveValues[i]);
6223 } 6166 }
6224 FX_Free(hResolveValues); 6167 FX_Free(hResolveValues);
6225 FX_Free(iSizes); 6168 FX_Free(iSizes);
6226 } else { 6169 } else {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
6265 FX_Free(rgValues); 6208 FX_Free(rgValues);
6266 for (int32_t i = 0; i < iSize; i++) 6209 for (int32_t i = 0; i < iSize; i++)
6267 delete hResolveValues[i]; 6210 delete hResolveValues[i];
6268 6211
6269 FX_Free(hResolveValues); 6212 FX_Free(hResolveValues);
6270 } else { 6213 } else {
6271 CFX_WideString wsPropertyName = 6214 CFX_WideString wsPropertyName =
6272 CFX_WideString::FromUTF8(szName.AsStringC()); 6215 CFX_WideString::FromUTF8(szName.AsStringC());
6273 CFX_WideString wsSomExpression = 6216 CFX_WideString wsSomExpression =
6274 CFX_WideString::FromUTF8(szSomExp.AsStringC()); 6217 CFX_WideString::FromUTF8(szSomExp.AsStringC());
6275 pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, 6218 pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
6276 wsPropertyName.c_str(), 6219 wsPropertyName.c_str(),
6277 wsSomExpression.c_str()); 6220 wsSomExpression.c_str());
6278 } 6221 }
6279 } 6222 }
6280 } else { 6223 } else {
6281 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 6224 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
6282 } 6225 }
6283 } 6226 }
6284 6227
6285 // static 6228 // static
6286 void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis, 6229 void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis,
6287 const CFX_ByteStringC& szFuncName, 6230 const CFX_ByteStringC& szFuncName,
6288 CFXJSE_Arguments& args) { 6231 CFXJSE_Arguments& args) {
6289 CXFA_FM2JSContext* pContext = 6232 CXFA_FM2JSContext* pContext =
6290 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 6233 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
6291 if (args.GetLength() == 1) { 6234 if (args.GetLength() == 1) {
6292 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 6235 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
6293 CFX_ByteString argString; 6236 CFX_ByteString argString;
6294 ValueToUTF8String(argOne.get(), argString); 6237 ValueToUTF8String(argOne.get(), argString);
6295 if (argString.IsEmpty()) { 6238 if (argString.IsEmpty()) {
6296 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); 6239 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
6297 } else { 6240 } else {
6298 CFX_WideString scriptString = 6241 CFX_WideString scriptString =
6299 CFX_WideString::FromUTF8(argString.AsStringC()); 6242 CFX_WideString::FromUTF8(argString.AsStringC());
6300 CFX_WideTextBuf wsJavaScriptBuf; 6243 CFX_WideTextBuf wsJavaScriptBuf;
6301 CFX_WideString wsError; 6244 CFX_WideString wsError;
6302 CXFA_FM2JSContext::Translate(scriptString.AsStringC(), wsJavaScriptBuf, 6245 CXFA_FM2JSContext::Translate(scriptString.AsStringC(), wsJavaScriptBuf,
6303 wsError); 6246 wsError);
6304 if (wsError.IsEmpty()) { 6247 if (wsError.IsEmpty()) {
6305 CFX_WideString javaScript = wsJavaScriptBuf.MakeString(); 6248 CFX_WideString javaScript = wsJavaScriptBuf.MakeString();
6306 FXJSE_Value_SetUTF8String( 6249 FXJSE_Value_SetUTF8String(
6307 args.GetReturnValue(), 6250 args.GetReturnValue(),
6308 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()) 6251 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength())
6309 .AsStringC()); 6252 .AsStringC());
6310 } else { 6253 } else {
6311 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 6254 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
6312 } 6255 }
6313 } 6256 }
6314 } else { 6257 } else {
6315 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 6258 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Eval");
6316 L"Eval");
6317 } 6259 }
6318 } 6260 }
6319 6261
6320 // static 6262 // static
6321 void CXFA_FM2JSContext::is_fm_object(CFXJSE_Value* pThis, 6263 void CXFA_FM2JSContext::is_fm_object(CFXJSE_Value* pThis,
6322 const CFX_ByteStringC& szFuncName, 6264 const CFX_ByteStringC& szFuncName,
6323 CFXJSE_Arguments& args) { 6265 CFXJSE_Arguments& args) {
6324 if (args.GetLength() == 1) { 6266 if (args.GetLength() == 1) {
6325 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 6267 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
6326 FXJSE_Value_SetBoolean(args.GetReturnValue(), 6268 FXJSE_Value_SetBoolean(args.GetReturnValue(),
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
6364 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); 6306 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr);
6365 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), 6307 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(),
6366 args.GetReturnValue()); 6308 args.GetReturnValue());
6367 } 6309 }
6368 } else if (FXJSE_Value_IsObject(argOne.get())) { 6310 } else if (FXJSE_Value_IsObject(argOne.get())) {
6369 GetObjectDefaultValue(argOne.get(), args.GetReturnValue()); 6311 GetObjectDefaultValue(argOne.get(), args.GetReturnValue());
6370 } else { 6312 } else {
6371 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); 6313 FXJSE_Value_Set(args.GetReturnValue(), argOne.get());
6372 } 6314 }
6373 } else { 6315 } else {
6374 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 6316 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
6375 } 6317 }
6376 } 6318 }
6377 6319
6378 // static 6320 // static
6379 void CXFA_FM2JSContext::get_fm_jsobj(CFXJSE_Value* pThis, 6321 void CXFA_FM2JSContext::get_fm_jsobj(CFXJSE_Value* pThis,
6380 const CFX_ByteStringC& szFuncName, 6322 const CFX_ByteStringC& szFuncName,
6381 CFXJSE_Arguments& args) { 6323 CFXJSE_Arguments& args) {
6382 if (args.GetLength() == 1) { 6324 if (args.GetLength() == 1) {
6383 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 6325 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
6384 if (FXJSE_Value_IsArray(argOne.get())) { 6326 if (FXJSE_Value_IsArray(argOne.get())) {
6385 #ifndef NDEBUG 6327 #ifndef NDEBUG
6386 CXFA_FM2JSContext* pContext = 6328 CXFA_FM2JSContext* pContext =
6387 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 6329 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
6388 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 6330 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
6389 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 6331 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
6390 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get()); 6332 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get());
6391 ASSERT(FXJSE_Value_ToInteger(lengthValue.get()) >= 3); 6333 ASSERT(FXJSE_Value_ToInteger(lengthValue.get()) >= 3);
6392 #endif 6334 #endif
6393 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, args.GetReturnValue()); 6335 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, args.GetReturnValue());
6394 } else { 6336 } else {
6395 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); 6337 FXJSE_Value_Set(args.GetReturnValue(), argOne.get());
6396 } 6338 }
6397 } else { 6339 } else {
6398 CXFA_FM2JSContext* pContext = 6340 CXFA_FM2JSContext* pContext =
6399 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 6341 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
6400 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 6342 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
6401 } 6343 }
6402 } 6344 }
6403 6345
6404 // static 6346 // static
6405 void CXFA_FM2JSContext::fm_var_filter(CFXJSE_Value* pThis, 6347 void CXFA_FM2JSContext::fm_var_filter(CFXJSE_Value* pThis,
6406 const CFX_ByteStringC& szFuncName, 6348 const CFX_ByteStringC& szFuncName,
6407 CFXJSE_Arguments& args) { 6349 CFXJSE_Arguments& args) {
6408 CXFA_FM2JSContext* pContext = 6350 CXFA_FM2JSContext* pContext =
6409 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 6351 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
6410 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 6352 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
(...skipping 18 matching lines...) Expand all
6429 FXJSE_Value_SetNull(rgValues[2]); 6371 FXJSE_Value_SetNull(rgValues[2]);
6430 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); 6372 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues);
6431 for (int32_t i = 0; i < 3; i++) 6373 for (int32_t i = 0; i < 3; i++)
6432 delete rgValues[i]; 6374 delete rgValues[i];
6433 } else if (iFlags == 3) { 6375 } else if (iFlags == 3) {
6434 std::unique_ptr<CFXJSE_Value> objectValue(new CFXJSE_Value(pIsolate)); 6376 std::unique_ptr<CFXJSE_Value> objectValue(new CFXJSE_Value(pIsolate));
6435 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, objectValue.get()); 6377 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, objectValue.get());
6436 if (!FXJSE_Value_IsNull(objectValue.get())) { 6378 if (!FXJSE_Value_IsNull(objectValue.get())) {
6437 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); 6379 FXJSE_Value_Set(args.GetReturnValue(), argOne.get());
6438 } else { 6380 } else {
6439 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 6381 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
6440 } 6382 }
6441 } else { 6383 } else {
6442 std::unique_ptr<CFXJSE_Value> simpleValue = 6384 std::unique_ptr<CFXJSE_Value> simpleValue =
6443 GetSimpleValue(pThis, args, 0); 6385 GetSimpleValue(pThis, args, 0);
6444 FXJSE_Value_Set(args.GetReturnValue(), simpleValue.get()); 6386 FXJSE_Value_Set(args.GetReturnValue(), simpleValue.get());
6445 } 6387 }
6446 } else { 6388 } else {
6447 std::unique_ptr<CFXJSE_Value> simpleValue = 6389 std::unique_ptr<CFXJSE_Value> simpleValue =
6448 GetSimpleValue(pThis, args, 0); 6390 GetSimpleValue(pThis, args, 0);
6449 FXJSE_Value_Set(args.GetReturnValue(), simpleValue.get()); 6391 FXJSE_Value_Set(args.GetReturnValue(), simpleValue.get());
6450 } 6392 }
6451 } else { 6393 } else {
6452 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 6394 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
6453 } 6395 }
6454 } 6396 }
6455 6397
6456 // static 6398 // static
6457 void CXFA_FM2JSContext::concat_fm_object(CFXJSE_Value* pThis, 6399 void CXFA_FM2JSContext::concat_fm_object(CFXJSE_Value* pThis,
6458 const CFX_ByteStringC& szFuncName, 6400 const CFX_ByteStringC& szFuncName,
6459 CFXJSE_Arguments& args) { 6401 CFXJSE_Arguments& args) {
6460 CXFA_FM2JSContext* pContext = 6402 CXFA_FM2JSContext* pContext =
6461 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 6403 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
6462 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 6404 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
7078 FXJSE_Value_SetNull(m_pValue.get()); 7020 FXJSE_Value_SetNull(m_pValue.get());
7079 FXJSE_Value_SetObject(m_pValue.get(), this, m_pFMClass); 7021 FXJSE_Value_SetObject(m_pValue.get(), this, m_pFMClass);
7080 } 7022 }
7081 7023
7082 CXFA_FM2JSContext::~CXFA_FM2JSContext() {} 7024 CXFA_FM2JSContext::~CXFA_FM2JSContext() {}
7083 7025
7084 void CXFA_FM2JSContext::GlobalPropertyGetter(CFXJSE_Value* pValue) { 7026 void CXFA_FM2JSContext::GlobalPropertyGetter(CFXJSE_Value* pValue) {
7085 FXJSE_Value_Set(pValue, m_pValue.get()); 7027 FXJSE_Value_Set(pValue, m_pValue.get());
7086 } 7028 }
7087 7029
7088 void CXFA_FM2JSContext::ThrowScriptErrorMessage(int32_t iStringID, ...) { 7030 void CXFA_FM2JSContext::ThrowException(int32_t iStringID, ...) {
7089 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); 7031 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider();
7090 ASSERT(pAppProvider); 7032 ASSERT(pAppProvider);
7091 CFX_WideString wsFormat; 7033 CFX_WideString wsFormat;
7092 pAppProvider->LoadString(iStringID, wsFormat); 7034 pAppProvider->LoadString(iStringID, wsFormat);
7093 CFX_WideString wsMessage; 7035 CFX_WideString wsMessage;
7094 va_list arg_ptr; 7036 va_list arg_ptr;
7095 va_start(arg_ptr, iStringID); 7037 va_start(arg_ptr, iStringID);
7096 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); 7038 wsMessage.FormatV(wsFormat.c_str(), arg_ptr);
7097 va_end(arg_ptr); 7039 va_end(arg_ptr);
7098 FXJSE_ThrowMessage( 7040 FXJSE_ThrowMessage(
7099 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); 7041 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC());
7100 } 7042 }
OLDNEW
« no previous file with comments | « xfa/fxfa/fm2js/xfa_fm2jscontext.h ('k') | xfa/fxfa/parser/xfa_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698