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

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

Issue 2026993003: Remove FXJSE_Value_ToObject and call methods directly (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@context_cleanup_3
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
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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 return false; 494 return false;
495 } 495 }
496 496
497 } // namespace 497 } // namespace
498 498
499 // static 499 // static
500 void CXFA_FM2JSContext::Abs(CFXJSE_Value* pThis, 500 void CXFA_FM2JSContext::Abs(CFXJSE_Value* pThis,
501 const CFX_ByteStringC& szFuncName, 501 const CFX_ByteStringC& szFuncName,
502 CFXJSE_Arguments& args) { 502 CFXJSE_Arguments& args) {
503 if (args.GetLength() != 1) { 503 if (args.GetLength() != 1) {
504 CXFA_FM2JSContext* pContext = 504 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
505 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 505 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Abs");
506 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
507 L"Abs");
508 return; 506 return;
509 } 507 }
510 508
511 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 509 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
512 if (ValueIsNull(pThis, argOne.get())) { 510 if (ValueIsNull(pThis, argOne.get())) {
513 FXJSE_Value_SetNull(args.GetReturnValue()); 511 FXJSE_Value_SetNull(args.GetReturnValue());
514 return; 512 return;
515 } 513 }
516 514
517 FX_DOUBLE dValue = ValueToDouble(pThis, argOne.get()); 515 FX_DOUBLE dValue = ValueToDouble(pThis, argOne.get());
518 if (dValue < 0) 516 if (dValue < 0)
519 dValue = -dValue; 517 dValue = -dValue;
520 518
521 FXJSE_Value_SetDouble(args.GetReturnValue(), dValue); 519 FXJSE_Value_SetDouble(args.GetReturnValue(), dValue);
522 } 520 }
523 521
524 // static 522 // static
525 void CXFA_FM2JSContext::Avg(CFXJSE_Value* pThis, 523 void CXFA_FM2JSContext::Avg(CFXJSE_Value* pThis,
526 const CFX_ByteStringC& szFuncName, 524 const CFX_ByteStringC& szFuncName,
527 CFXJSE_Arguments& args) { 525 CFXJSE_Arguments& args) {
528 int32_t argc = args.GetLength(); 526 int32_t argc = args.GetLength();
529 if (argc < 1) { 527 if (argc < 1) {
530 FXJSE_Value_SetNull(args.GetReturnValue()); 528 FXJSE_Value_SetNull(args.GetReturnValue());
531 return; 529 return;
532 } 530 }
533 531
534 CXFA_FM2JSContext* pContext = 532 v8::Isolate* pIsolate = pThis->ToJSContext(nullptr)->GetScriptRuntime();
535 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
536 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
537 uint32_t uCount = 0; 533 uint32_t uCount = 0;
538 FX_DOUBLE dSum = 0.0; 534 FX_DOUBLE dSum = 0.0;
539 for (int32_t i = 0; i < argc; i++) { 535 for (int32_t i = 0; i < argc; i++) {
540 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); 536 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i);
541 if (FXJSE_Value_IsNull(argValue.get())) 537 if (FXJSE_Value_IsNull(argValue.get()))
542 continue; 538 continue;
543 539
544 if (!FXJSE_Value_IsArray(argValue.get())) { 540 if (!FXJSE_Value_IsArray(argValue.get())) {
545 dSum += ValueToDouble(pThis, argValue.get()); 541 dSum += ValueToDouble(pThis, argValue.get());
546 uCount++; 542 uCount++;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 } 591 }
596 592
597 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum / uCount); 593 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum / uCount);
598 } 594 }
599 595
600 // static 596 // static
601 void CXFA_FM2JSContext::Ceil(CFXJSE_Value* pThis, 597 void CXFA_FM2JSContext::Ceil(CFXJSE_Value* pThis,
602 const CFX_ByteStringC& szFuncName, 598 const CFX_ByteStringC& szFuncName,
603 CFXJSE_Arguments& args) { 599 CFXJSE_Arguments& args) {
604 if (args.GetLength() != 1) { 600 if (args.GetLength() != 1) {
605 CXFA_FM2JSContext* pContext = 601 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
606 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 602 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Ceil");
607 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
608 L"Ceil");
609 return; 603 return;
610 } 604 }
611 605
612 std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, args, 0); 606 std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, args, 0);
613 if (ValueIsNull(pThis, argValue.get())) { 607 if (ValueIsNull(pThis, argValue.get())) {
614 FXJSE_Value_SetNull(args.GetReturnValue()); 608 FXJSE_Value_SetNull(args.GetReturnValue());
615 return; 609 return;
616 } 610 }
617 611
618 FXJSE_Value_SetFloat(args.GetReturnValue(), 612 FXJSE_Value_SetFloat(args.GetReturnValue(),
619 FXSYS_ceil(ValueToFloat(pThis, argValue.get()))); 613 FXSYS_ceil(ValueToFloat(pThis, argValue.get())));
620 } 614 }
621 615
622 // static 616 // static
623 void CXFA_FM2JSContext::Count(CFXJSE_Value* pThis, 617 void CXFA_FM2JSContext::Count(CFXJSE_Value* pThis,
624 const CFX_ByteStringC& szFuncName, 618 const CFX_ByteStringC& szFuncName,
625 CFXJSE_Arguments& args) { 619 CFXJSE_Arguments& args) {
626 CXFA_FM2JSContext* pContext = 620 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
627 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
628 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 621 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
629 int32_t iCount = 0; 622 int32_t iCount = 0;
630 for (int32_t i = 0; i < args.GetLength(); i++) { 623 for (int32_t i = 0; i < args.GetLength(); i++) {
631 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); 624 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i);
632 if (FXJSE_Value_IsNull(argValue.get())) 625 if (FXJSE_Value_IsNull(argValue.get()))
633 continue; 626 continue;
634 627
635 if (FXJSE_Value_IsArray(argValue.get())) { 628 if (FXJSE_Value_IsArray(argValue.get())) {
636 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 629 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
637 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); 630 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 } 672 }
680 } 673 }
681 FXJSE_Value_SetInteger(args.GetReturnValue(), iCount); 674 FXJSE_Value_SetInteger(args.GetReturnValue(), iCount);
682 } 675 }
683 676
684 // static 677 // static
685 void CXFA_FM2JSContext::Floor(CFXJSE_Value* pThis, 678 void CXFA_FM2JSContext::Floor(CFXJSE_Value* pThis,
686 const CFX_ByteStringC& szFuncName, 679 const CFX_ByteStringC& szFuncName,
687 CFXJSE_Arguments& args) { 680 CFXJSE_Arguments& args) {
688 if (args.GetLength() != 1) { 681 if (args.GetLength() != 1) {
689 CXFA_FM2JSContext* pContext = 682 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
690 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 683 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Floor");
691 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
692 L"Floor");
693 return; 684 return;
694 } 685 }
695 686
696 std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, args, 0); 687 std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, args, 0);
697 if (ValueIsNull(pThis, argValue.get())) { 688 if (ValueIsNull(pThis, argValue.get())) {
698 FXJSE_Value_SetNull(args.GetReturnValue()); 689 FXJSE_Value_SetNull(args.GetReturnValue());
699 return; 690 return;
700 } 691 }
701 692
702 FXJSE_Value_SetFloat(args.GetReturnValue(), 693 FXJSE_Value_SetFloat(args.GetReturnValue(),
703 FXSYS_floor(ValueToFloat(pThis, argValue.get()))); 694 FXSYS_floor(ValueToFloat(pThis, argValue.get())));
704 } 695 }
705 696
706 // static 697 // static
707 void CXFA_FM2JSContext::Max(CFXJSE_Value* pThis, 698 void CXFA_FM2JSContext::Max(CFXJSE_Value* pThis,
708 const CFX_ByteStringC& szFuncName, 699 const CFX_ByteStringC& szFuncName,
709 CFXJSE_Arguments& args) { 700 CFXJSE_Arguments& args) {
710 CXFA_FM2JSContext* pContext = 701 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
711 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
712 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 702 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
713 uint32_t uCount = 0; 703 uint32_t uCount = 0;
714 FX_DOUBLE dMaxValue = 0.0; 704 FX_DOUBLE dMaxValue = 0.0;
715 for (int32_t i = 0; i < args.GetLength(); i++) { 705 for (int32_t i = 0; i < args.GetLength(); i++) {
716 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); 706 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i);
717 if (FXJSE_Value_IsNull(argValue.get())) 707 if (FXJSE_Value_IsNull(argValue.get()))
718 continue; 708 continue;
719 709
720 if (FXJSE_Value_IsArray(argValue.get())) { 710 if (FXJSE_Value_IsArray(argValue.get())) {
721 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 711 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 return; 772 return;
783 } 773 }
784 774
785 FXJSE_Value_SetDouble(args.GetReturnValue(), dMaxValue); 775 FXJSE_Value_SetDouble(args.GetReturnValue(), dMaxValue);
786 } 776 }
787 777
788 // static 778 // static
789 void CXFA_FM2JSContext::Min(CFXJSE_Value* pThis, 779 void CXFA_FM2JSContext::Min(CFXJSE_Value* pThis,
790 const CFX_ByteStringC& szFuncName, 780 const CFX_ByteStringC& szFuncName,
791 CFXJSE_Arguments& args) { 781 CFXJSE_Arguments& args) {
792 CXFA_FM2JSContext* pContext = 782 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
793 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
794 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 783 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
795 uint32_t uCount = 0; 784 uint32_t uCount = 0;
796 FX_DOUBLE dMinValue = 0.0; 785 FX_DOUBLE dMinValue = 0.0;
797 for (int32_t i = 0; i < args.GetLength(); i++) { 786 for (int32_t i = 0; i < args.GetLength(); i++) {
798 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); 787 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i);
799 if (FXJSE_Value_IsNull(argValue.get())) 788 if (FXJSE_Value_IsNull(argValue.get()))
800 continue; 789 continue;
801 790
802 if (FXJSE_Value_IsArray(argValue.get())) { 791 if (FXJSE_Value_IsArray(argValue.get())) {
803 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 792 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 return; 853 return;
865 } 854 }
866 855
867 FXJSE_Value_SetDouble(args.GetReturnValue(), dMinValue); 856 FXJSE_Value_SetDouble(args.GetReturnValue(), dMinValue);
868 } 857 }
869 858
870 // static 859 // static
871 void CXFA_FM2JSContext::Mod(CFXJSE_Value* pThis, 860 void CXFA_FM2JSContext::Mod(CFXJSE_Value* pThis,
872 const CFX_ByteStringC& szFuncName, 861 const CFX_ByteStringC& szFuncName,
873 CFXJSE_Arguments& args) { 862 CFXJSE_Arguments& args) {
874 CXFA_FM2JSContext* pContext = 863 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
875 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
876 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 864 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
877 if (args.GetLength() != 2) { 865 if (args.GetLength() != 2) {
878 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 866 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
879 L"Mod"); 867 L"Mod");
880 return; 868 return;
881 } 869 }
882 870
883 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 871 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
884 std::unique_ptr<CFXJSE_Value> argTwo = args.GetValue(1); 872 std::unique_ptr<CFXJSE_Value> argTwo = args.GetValue(1);
885 if (FXJSE_Value_IsNull(argOne.get()) || FXJSE_Value_IsNull(argTwo.get())) { 873 if (FXJSE_Value_IsNull(argOne.get()) || FXJSE_Value_IsNull(argTwo.get())) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 } 939 }
952 940
953 FXJSE_Value_SetDouble(args.GetReturnValue(), 941 FXJSE_Value_SetDouble(args.GetReturnValue(),
954 dDividend - dDividor * (int32_t)(dDividend / dDividor)); 942 dDividend - dDividor * (int32_t)(dDividend / dDividor));
955 } 943 }
956 944
957 // static 945 // static
958 void CXFA_FM2JSContext::Round(CFXJSE_Value* pThis, 946 void CXFA_FM2JSContext::Round(CFXJSE_Value* pThis,
959 const CFX_ByteStringC& szFuncName, 947 const CFX_ByteStringC& szFuncName,
960 CFXJSE_Arguments& args) { 948 CFXJSE_Arguments& args) {
961 CXFA_FM2JSContext* pContext = 949 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
962 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
963 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 950 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
964 int32_t argc = args.GetLength(); 951 int32_t argc = args.GetLength();
965 uint8_t uPrecision = 0; 952 uint8_t uPrecision = 0;
966 953
967 if (argc != 1 && argc != 2) { 954 if (argc != 1 && argc != 2) {
968 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 955 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
969 L"Round"); 956 L"Round");
970 return; 957 return;
971 } 958 }
972 959
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 // static 1053 // static
1067 void CXFA_FM2JSContext::Sum(CFXJSE_Value* pThis, 1054 void CXFA_FM2JSContext::Sum(CFXJSE_Value* pThis,
1068 const CFX_ByteStringC& szFuncName, 1055 const CFX_ByteStringC& szFuncName,
1069 CFXJSE_Arguments& args) { 1056 CFXJSE_Arguments& args) {
1070 int32_t argc = args.GetLength(); 1057 int32_t argc = args.GetLength();
1071 if (argc == 0) { 1058 if (argc == 0) {
1072 FXJSE_Value_SetNull(args.GetReturnValue()); 1059 FXJSE_Value_SetNull(args.GetReturnValue());
1073 return; 1060 return;
1074 } 1061 }
1075 1062
1076 CXFA_FM2JSContext* pContext = 1063 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
1077 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
1078 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 1064 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
1079 uint32_t uCount = 0; 1065 uint32_t uCount = 0;
1080 FX_DOUBLE dSum = 0.0; 1066 FX_DOUBLE dSum = 0.0;
1081 for (int32_t i = 0; i < argc; i++) { 1067 for (int32_t i = 0; i < argc; i++) {
1082 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); 1068 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i);
1083 if (FXJSE_Value_IsNull(argValue.get())) 1069 if (FXJSE_Value_IsNull(argValue.get()))
1084 continue; 1070 continue;
1085 1071
1086 if (FXJSE_Value_IsArray(argValue.get())) { 1072 if (FXJSE_Value_IsArray(argValue.get())) {
1087 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 1073 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 } 1130 }
1145 1131
1146 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum); 1132 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum);
1147 } 1133 }
1148 1134
1149 // static 1135 // static
1150 void CXFA_FM2JSContext::Date(CFXJSE_Value* pThis, 1136 void CXFA_FM2JSContext::Date(CFXJSE_Value* pThis,
1151 const CFX_ByteStringC& szFuncName, 1137 const CFX_ByteStringC& szFuncName,
1152 CFXJSE_Arguments& args) { 1138 CFXJSE_Arguments& args) {
1153 if (args.GetLength() != 0) { 1139 if (args.GetLength() != 0) {
1154 CXFA_FM2JSContext* pContext = 1140 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
1155 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1141 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Date");
1156 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
1157 L"Date");
1158 return; 1142 return;
1159 } 1143 }
1160 1144
1161 time_t currentTime; 1145 time_t currentTime;
1162 time(&currentTime); 1146 time(&currentTime);
1163 struct tm* pTmStruct = gmtime(&currentTime); 1147 struct tm* pTmStruct = gmtime(&currentTime);
1164 1148
1165 CFX_ByteString bufferYear; 1149 CFX_ByteString bufferYear;
1166 CFX_ByteString bufferMon; 1150 CFX_ByteString bufferMon;
1167 CFX_ByteString bufferDay; 1151 CFX_ByteString bufferDay;
1168 bufferYear.Format("%d", pTmStruct->tm_year + 1900); 1152 bufferYear.Format("%d", pTmStruct->tm_year + 1900);
1169 bufferMon.Format("%02d", pTmStruct->tm_mon + 1); 1153 bufferMon.Format("%02d", pTmStruct->tm_mon + 1);
1170 bufferDay.Format("%02d", pTmStruct->tm_mday); 1154 bufferDay.Format("%02d", pTmStruct->tm_mday);
1171 1155
1172 CFX_ByteString bufferCurrent = bufferYear + bufferMon + bufferDay; 1156 CFX_ByteString bufferCurrent = bufferYear + bufferMon + bufferDay;
1173 FXJSE_Value_SetInteger(args.GetReturnValue(), 1157 FXJSE_Value_SetInteger(args.GetReturnValue(),
1174 DateString2Num(bufferCurrent.AsStringC())); 1158 DateString2Num(bufferCurrent.AsStringC()));
1175 } 1159 }
1176 1160
1177 // static 1161 // static
1178 void CXFA_FM2JSContext::Date2Num(CFXJSE_Value* pThis, 1162 void CXFA_FM2JSContext::Date2Num(CFXJSE_Value* pThis,
1179 const CFX_ByteStringC& szFuncName, 1163 const CFX_ByteStringC& szFuncName,
1180 CFXJSE_Arguments& args) { 1164 CFXJSE_Arguments& args) {
1181 int32_t argc = args.GetLength(); 1165 int32_t argc = args.GetLength();
1182 if ((argc <= 0) || (argc >= 4)) { 1166 if ((argc <= 0) || (argc >= 4)) {
1183 CXFA_FM2JSContext* pContext = 1167 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
1184 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1168 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Date2Num");
1185 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
1186 L"Date2Num");
1187 return; 1169 return;
1188 } 1170 }
1189 1171
1190 std::unique_ptr<CFXJSE_Value> dateValue = GetSimpleValue(pThis, args, 0); 1172 std::unique_ptr<CFXJSE_Value> dateValue = GetSimpleValue(pThis, args, 0);
1191 if (ValueIsNull(pThis, dateValue.get())) { 1173 if (ValueIsNull(pThis, dateValue.get())) {
1192 FXJSE_Value_SetNull(args.GetReturnValue()); 1174 FXJSE_Value_SetNull(args.GetReturnValue());
1193 return; 1175 return;
1194 } 1176 }
1195 1177
1196 CFX_ByteString dateString; 1178 CFX_ByteString dateString;
(...skipping 29 matching lines...) Expand all
1226 FXJSE_Value_SetInteger(args.GetReturnValue(), 1208 FXJSE_Value_SetInteger(args.GetReturnValue(),
1227 DateString2Num(szIsoDateString.AsStringC())); 1209 DateString2Num(szIsoDateString.AsStringC()));
1228 } 1210 }
1229 1211
1230 // static 1212 // static
1231 void CXFA_FM2JSContext::DateFmt(CFXJSE_Value* pThis, 1213 void CXFA_FM2JSContext::DateFmt(CFXJSE_Value* pThis,
1232 const CFX_ByteStringC& szFuncName, 1214 const CFX_ByteStringC& szFuncName,
1233 CFXJSE_Arguments& args) { 1215 CFXJSE_Arguments& args) {
1234 int32_t argc = args.GetLength(); 1216 int32_t argc = args.GetLength();
1235 if (argc >= 3) { 1217 if (argc >= 3) {
1236 CXFA_FM2JSContext* pContext = 1218 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
1237 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1219 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Date2Num");
1238 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
1239 L"Date2Num");
1240 return; 1220 return;
1241 } 1221 }
1242 1222
1243 int32_t iStyle = 0; 1223 int32_t iStyle = 0;
1244 if (argc > 0) { 1224 if (argc > 0) {
1245 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0); 1225 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0);
1246 if (FXJSE_Value_IsNull(argStyle.get())) { 1226 if (FXJSE_Value_IsNull(argStyle.get())) {
1247 FXJSE_Value_SetNull(args.GetReturnValue()); 1227 FXJSE_Value_SetNull(args.GetReturnValue());
1248 return; 1228 return;
1249 } 1229 }
(...skipping 19 matching lines...) Expand all
1269 formatStr = ""; 1249 formatStr = "";
1270 1250
1271 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); 1251 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC());
1272 } 1252 }
1273 1253
1274 // static 1254 // static
1275 void CXFA_FM2JSContext::IsoDate2Num(CFXJSE_Value* pThis, 1255 void CXFA_FM2JSContext::IsoDate2Num(CFXJSE_Value* pThis,
1276 const CFX_ByteStringC& szFuncName, 1256 const CFX_ByteStringC& szFuncName,
1277 CFXJSE_Arguments& args) { 1257 CFXJSE_Arguments& args) {
1278 if (args.GetLength() != 1) { 1258 if (args.GetLength() != 1) {
1279 CXFA_FM2JSContext* pContext = 1259 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
1280 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1260 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"IsoDate2Num");
1281 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
1282 L"IsoDate2Num");
1283 return; 1261 return;
1284 } 1262 }
1285 1263
1286 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 1264 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
1287 if (FXJSE_Value_IsNull(argOne.get())) { 1265 if (FXJSE_Value_IsNull(argOne.get())) {
1288 FXJSE_Value_SetNull(args.GetReturnValue()); 1266 FXJSE_Value_SetNull(args.GetReturnValue());
1289 return; 1267 return;
1290 } 1268 }
1291 1269
1292 CFX_ByteString szArgString; 1270 CFX_ByteString szArgString;
1293 ValueToUTF8String(argOne.get(), szArgString); 1271 ValueToUTF8String(argOne.get(), szArgString);
1294 FXJSE_Value_SetInteger(args.GetReturnValue(), 1272 FXJSE_Value_SetInteger(args.GetReturnValue(),
1295 DateString2Num(szArgString.AsStringC())); 1273 DateString2Num(szArgString.AsStringC()));
1296 } 1274 }
1297 1275
1298 // static 1276 // static
1299 void CXFA_FM2JSContext::IsoTime2Num(CFXJSE_Value* pThis, 1277 void CXFA_FM2JSContext::IsoTime2Num(CFXJSE_Value* pThis,
1300 const CFX_ByteStringC& szFuncName, 1278 const CFX_ByteStringC& szFuncName,
1301 CFXJSE_Arguments& args) { 1279 CFXJSE_Arguments& args) {
1302 CXFA_FM2JSContext* pContext = 1280 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
1303 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
1304 if (args.GetLength() != 1) { 1281 if (args.GetLength() != 1) {
1305 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 1282 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
1306 L"IsoTime2Num"); 1283 L"IsoTime2Num");
1307 return; 1284 return;
1308 } 1285 }
1309 1286
1310 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 1287 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
1311 if (ValueIsNull(pThis, argOne.get())) { 1288 if (ValueIsNull(pThis, argOne.get())) {
1312 FXJSE_Value_SetNull(args.GetReturnValue()); 1289 FXJSE_Value_SetNull(args.GetReturnValue());
1313 return; 1290 return;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 CFX_ByteString formatStr; 1362 CFX_ByteString formatStr;
1386 GetLocalDateFormat(pThis, iStyle, szLocal.AsStringC(), formatStr, FALSE); 1363 GetLocalDateFormat(pThis, iStyle, szLocal.AsStringC(), formatStr, FALSE);
1387 if (formatStr.IsEmpty()) { 1364 if (formatStr.IsEmpty()) {
1388 formatStr = ""; 1365 formatStr = "";
1389 } 1366 }
1390 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); 1367 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC());
1391 } else { 1368 } else {
1392 FXJSE_Value_SetNull(args.GetReturnValue()); 1369 FXJSE_Value_SetNull(args.GetReturnValue());
1393 } 1370 }
1394 } else { 1371 } else {
1395 CXFA_FM2JSContext* pContext = 1372 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
1396 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1373 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"LocalDateFmt");
1397 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
1398 L"LocalDateFmt");
1399 } 1374 }
1400 } 1375 }
1401 1376
1402 // static 1377 // static
1403 void CXFA_FM2JSContext::LocalTimeFmt(CFXJSE_Value* pThis, 1378 void CXFA_FM2JSContext::LocalTimeFmt(CFXJSE_Value* pThis,
1404 const CFX_ByteStringC& szFuncName, 1379 const CFX_ByteStringC& szFuncName,
1405 CFXJSE_Arguments& args) { 1380 CFXJSE_Arguments& args) {
1406 int32_t argc = args.GetLength(); 1381 int32_t argc = args.GetLength();
1407 if (argc < 3) { 1382 if (argc < 3) {
1408 FX_BOOL bFlags = FALSE; 1383 FX_BOOL bFlags = FALSE;
(...skipping 21 matching lines...) Expand all
1430 CFX_ByteString formatStr; 1405 CFX_ByteString formatStr;
1431 GetLocalTimeFormat(pThis, iStyle, szLocal.AsStringC(), formatStr, FALSE); 1406 GetLocalTimeFormat(pThis, iStyle, szLocal.AsStringC(), formatStr, FALSE);
1432 if (formatStr.IsEmpty()) { 1407 if (formatStr.IsEmpty()) {
1433 formatStr = ""; 1408 formatStr = "";
1434 } 1409 }
1435 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); 1410 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC());
1436 } else { 1411 } else {
1437 FXJSE_Value_SetNull(args.GetReturnValue()); 1412 FXJSE_Value_SetNull(args.GetReturnValue());
1438 } 1413 }
1439 } else { 1414 } else {
1440 CXFA_FM2JSContext* pContext = 1415 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
1441 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1416 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"LocalTimeFmt");
1442 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
1443 L"LocalTimeFmt");
1444 } 1417 }
1445 } 1418 }
1446 1419
1447 // static 1420 // static
1448 void CXFA_FM2JSContext::Num2Date(CFXJSE_Value* pThis, 1421 void CXFA_FM2JSContext::Num2Date(CFXJSE_Value* pThis,
1449 const CFX_ByteStringC& szFuncName, 1422 const CFX_ByteStringC& szFuncName,
1450 CFXJSE_Arguments& args) { 1423 CFXJSE_Arguments& args) {
1451 int32_t argc = args.GetLength(); 1424 int32_t argc = args.GetLength();
1452 if ((argc > 0) && (argc < 4)) { 1425 if ((argc > 0) && (argc < 4)) {
1453 FX_BOOL bFlags = FALSE; 1426 FX_BOOL bFlags = FALSE;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 szLocalDateString); 1552 szLocalDateString);
1580 if (szLocalDateString.IsEmpty()) { 1553 if (szLocalDateString.IsEmpty()) {
1581 szLocalDateString = ""; 1554 szLocalDateString = "";
1582 } 1555 }
1583 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 1556 FXJSE_Value_SetUTF8String(args.GetReturnValue(),
1584 szLocalDateString.AsStringC()); 1557 szLocalDateString.AsStringC());
1585 } else { 1558 } else {
1586 FXJSE_Value_SetNull(args.GetReturnValue()); 1559 FXJSE_Value_SetNull(args.GetReturnValue());
1587 } 1560 }
1588 } else { 1561 } else {
1589 CXFA_FM2JSContext* pContext = 1562 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
1590 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1563 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2Date");
1591 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
1592 L"Num2Date");
1593 } 1564 }
1594 } 1565 }
1595 1566
1596 // static 1567 // static
1597 void CXFA_FM2JSContext::Num2GMTime(CFXJSE_Value* pThis, 1568 void CXFA_FM2JSContext::Num2GMTime(CFXJSE_Value* pThis,
1598 const CFX_ByteStringC& szFuncName, 1569 const CFX_ByteStringC& szFuncName,
1599 CFXJSE_Arguments& args) { 1570 CFXJSE_Arguments& args) {
1600 int32_t argc = args.GetLength(); 1571 int32_t argc = args.GetLength();
1601 if ((argc > 0) && (argc < 4)) { 1572 if ((argc > 0) && (argc < 4)) {
1602 FX_BOOL bFlags = FALSE; 1573 FX_BOOL bFlags = FALSE;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 localString.AsStringC(), TRUE, szGMTTimeString); 1606 localString.AsStringC(), TRUE, szGMTTimeString);
1636 if (szGMTTimeString.IsEmpty()) { 1607 if (szGMTTimeString.IsEmpty()) {
1637 szGMTTimeString = ""; 1608 szGMTTimeString = "";
1638 } 1609 }
1639 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 1610 FXJSE_Value_SetUTF8String(args.GetReturnValue(),
1640 szGMTTimeString.AsStringC()); 1611 szGMTTimeString.AsStringC());
1641 } else { 1612 } else {
1642 FXJSE_Value_SetNull(args.GetReturnValue()); 1613 FXJSE_Value_SetNull(args.GetReturnValue());
1643 } 1614 }
1644 } else { 1615 } else {
1645 CXFA_FM2JSContext* pContext = 1616 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
1646 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1617 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2GMTime");
1647 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
1648 L"Num2GMTime");
1649 } 1618 }
1650 } 1619 }
1651 1620
1652 // static 1621 // static
1653 void CXFA_FM2JSContext::Num2Time(CFXJSE_Value* pThis, 1622 void CXFA_FM2JSContext::Num2Time(CFXJSE_Value* pThis,
1654 const CFX_ByteStringC& szFuncName, 1623 const CFX_ByteStringC& szFuncName,
1655 CFXJSE_Arguments& args) { 1624 CFXJSE_Arguments& args) {
1656 int32_t argc = args.GetLength(); 1625 int32_t argc = args.GetLength();
1657 if ((argc > 0) && (argc < 4)) { 1626 if ((argc > 0) && (argc < 4)) {
1658 FX_BOOL bFlags = FALSE; 1627 FX_BOOL bFlags = FALSE;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1691 localString.AsStringC(), FALSE, szLocalTimeString); 1660 localString.AsStringC(), FALSE, szLocalTimeString);
1692 if (szLocalTimeString.IsEmpty()) { 1661 if (szLocalTimeString.IsEmpty()) {
1693 szLocalTimeString = ""; 1662 szLocalTimeString = "";
1694 } 1663 }
1695 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 1664 FXJSE_Value_SetUTF8String(args.GetReturnValue(),
1696 szLocalTimeString.AsStringC()); 1665 szLocalTimeString.AsStringC());
1697 } else { 1666 } else {
1698 FXJSE_Value_SetNull(args.GetReturnValue()); 1667 FXJSE_Value_SetNull(args.GetReturnValue());
1699 } 1668 }
1700 } else { 1669 } else {
1701 CXFA_FM2JSContext* pContext = 1670 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
1702 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1671 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2Time");
1703 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
1704 L"Num2Time");
1705 } 1672 }
1706 } 1673 }
1707 1674
1708 // static 1675 // static
1709 void CXFA_FM2JSContext::Time(CFXJSE_Value* pThis, 1676 void CXFA_FM2JSContext::Time(CFXJSE_Value* pThis,
1710 const CFX_ByteStringC& szFuncName, 1677 const CFX_ByteStringC& szFuncName,
1711 CFXJSE_Arguments& args) { 1678 CFXJSE_Arguments& args) {
1712 if (args.GetLength() == 0) { 1679 if (args.GetLength() == 0) {
1713 time_t now; 1680 time_t now;
1714 time(&now); 1681 time(&now);
1715 struct tm* pGmt = gmtime(&now); 1682 struct tm* pGmt = gmtime(&now);
1716 int32_t iGMHour = pGmt->tm_hour; 1683 int32_t iGMHour = pGmt->tm_hour;
1717 int32_t iGMMin = pGmt->tm_min; 1684 int32_t iGMMin = pGmt->tm_min;
1718 int32_t iGMSec = pGmt->tm_sec; 1685 int32_t iGMSec = pGmt->tm_sec;
1719 FXJSE_Value_SetInteger(args.GetReturnValue(), 1686 FXJSE_Value_SetInteger(args.GetReturnValue(),
1720 ((iGMHour * 3600 + iGMMin * 60 + iGMSec) * 1000)); 1687 ((iGMHour * 3600 + iGMMin * 60 + iGMSec) * 1000));
1721 } else { 1688 } else {
1722 CXFA_FM2JSContext* pContext = 1689 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
1723 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1690 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Time");
1724 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
1725 L"Time");
1726 } 1691 }
1727 } 1692 }
1728 1693
1729 // static 1694 // static
1730 void CXFA_FM2JSContext::Time2Num(CFXJSE_Value* pThis, 1695 void CXFA_FM2JSContext::Time2Num(CFXJSE_Value* pThis,
1731 const CFX_ByteStringC& szFuncName, 1696 const CFX_ByteStringC& szFuncName,
1732 CFXJSE_Arguments& args) { 1697 CFXJSE_Arguments& args) {
1733 int32_t argc = args.GetLength(); 1698 int32_t argc = args.GetLength();
1734 if ((argc > 0) && (argc < 4)) { 1699 if ((argc > 0) && (argc < 4)) {
1735 FX_BOOL bFlags = FALSE; 1700 FX_BOOL bFlags = FALSE;
(...skipping 17 matching lines...) Expand all
1753 } 1718 }
1754 if (argc == 3) { 1719 if (argc == 3) {
1755 std::unique_ptr<CFXJSE_Value> localValue = GetSimpleValue(pThis, args, 2); 1720 std::unique_ptr<CFXJSE_Value> localValue = GetSimpleValue(pThis, args, 2);
1756 if (ValueIsNull(pThis, localValue.get())) { 1721 if (ValueIsNull(pThis, localValue.get())) {
1757 bFlags = TRUE; 1722 bFlags = TRUE;
1758 } else { 1723 } else {
1759 ValueToUTF8String(localValue.get(), localString); 1724 ValueToUTF8String(localValue.get(), localString);
1760 } 1725 }
1761 } 1726 }
1762 if (!bFlags) { 1727 if (!bFlags) {
1763 CXFA_FM2JSContext* pContext = 1728 CXFA_Document* pDoc = pThis->ToJSContext(nullptr)->GetDocument();
1764 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
1765 CXFA_Document* pDoc = pContext->GetDocument();
1766 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); 1729 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr();
1767 IFX_Locale* pLocale = nullptr; 1730 IFX_Locale* pLocale = nullptr;
1768 if (localString.IsEmpty()) { 1731 if (localString.IsEmpty()) {
1769 CXFA_Node* pThisNode = 1732 CXFA_Node* pThisNode =
1770 ToNode(pDoc->GetScriptContext()->GetThisObject()); 1733 ToNode(pDoc->GetScriptContext()->GetThisObject());
1771 ASSERT(pThisNode); 1734 ASSERT(pThisNode);
1772 CXFA_WidgetData widgetData(pThisNode); 1735 CXFA_WidgetData widgetData(pThisNode);
1773 pLocale = widgetData.GetLocal(); 1736 pLocale = widgetData.GetLocal();
1774 } else { 1737 } else {
1775 pLocale = pMgr->GetLocaleByName( 1738 pLocale = pMgr->GetLocaleByName(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1810 int32_t iResult = 1773 int32_t iResult =
1811 hour * 3600000 + min * 60000 + second * 1000 + milSecond + 1; 1774 hour * 3600000 + min * 60000 + second * 1000 + milSecond + 1;
1812 FXJSE_Value_SetInteger(args.GetReturnValue(), iResult); 1775 FXJSE_Value_SetInteger(args.GetReturnValue(), iResult);
1813 } else { 1776 } else {
1814 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); 1777 FXJSE_Value_SetInteger(args.GetReturnValue(), 0);
1815 } 1778 }
1816 } else { 1779 } else {
1817 FXJSE_Value_SetNull(args.GetReturnValue()); 1780 FXJSE_Value_SetNull(args.GetReturnValue());
1818 } 1781 }
1819 } else { 1782 } else {
1820 CXFA_FM2JSContext* pContext = 1783 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
1821 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1784 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Time2Num");
1822 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
1823 L"Time2Num");
1824 } 1785 }
1825 } 1786 }
1826 1787
1827 // static 1788 // static
1828 void CXFA_FM2JSContext::TimeFmt(CFXJSE_Value* pThis, 1789 void CXFA_FM2JSContext::TimeFmt(CFXJSE_Value* pThis,
1829 const CFX_ByteStringC& szFuncName, 1790 const CFX_ByteStringC& szFuncName,
1830 CFXJSE_Arguments& args) { 1791 CFXJSE_Arguments& args) {
1831 int32_t argc = args.GetLength(); 1792 int32_t argc = args.GetLength();
1832 if (argc < 3) { 1793 if (argc < 3) {
1833 FX_BOOL bFlags = FALSE; 1794 FX_BOOL bFlags = FALSE;
(...skipping 21 matching lines...) Expand all
1855 CFX_ByteString formatStr; 1816 CFX_ByteString formatStr;
1856 GetStandardTimeFormat(pThis, iStyle, szLocal.AsStringC(), formatStr); 1817 GetStandardTimeFormat(pThis, iStyle, szLocal.AsStringC(), formatStr);
1857 if (formatStr.IsEmpty()) { 1818 if (formatStr.IsEmpty()) {
1858 formatStr = ""; 1819 formatStr = "";
1859 } 1820 }
1860 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); 1821 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC());
1861 } else { 1822 } else {
1862 FXJSE_Value_SetNull(args.GetReturnValue()); 1823 FXJSE_Value_SetNull(args.GetReturnValue());
1863 } 1824 }
1864 } else { 1825 } else {
1865 CXFA_FM2JSContext* pContext = 1826 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
1866 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 1827 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"TimeFmt");
1867 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
1868 L"TimeFmt");
1869 } 1828 }
1870 } 1829 }
1871 1830
1872 // static 1831 // static
1873 FX_BOOL CXFA_FM2JSContext::IsIsoDateFormat(const FX_CHAR* pData, 1832 FX_BOOL CXFA_FM2JSContext::IsIsoDateFormat(const FX_CHAR* pData,
1874 int32_t iLength, 1833 int32_t iLength,
1875 int32_t& iStyle, 1834 int32_t& iStyle,
1876 int32_t& iYear, 1835 int32_t& iYear,
1877 int32_t& iMonth, 1836 int32_t& iMonth,
1878 int32_t& iDay) { 1837 int32_t& iDay) {
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
2193 iRet = TRUE; 2152 iRet = TRUE;
2194 return iRet; 2153 return iRet;
2195 } 2154 }
2196 2155
2197 // static 2156 // static
2198 FX_BOOL CXFA_FM2JSContext::Local2IsoDate(CFXJSE_Value* pThis, 2157 FX_BOOL CXFA_FM2JSContext::Local2IsoDate(CFXJSE_Value* pThis,
2199 const CFX_ByteStringC& szDate, 2158 const CFX_ByteStringC& szDate,
2200 const CFX_ByteStringC& szFormat, 2159 const CFX_ByteStringC& szFormat,
2201 const CFX_ByteStringC& szLocale, 2160 const CFX_ByteStringC& szLocale,
2202 CFX_ByteString& strIsoDate) { 2161 CFX_ByteString& strIsoDate) {
2203 CXFA_FM2JSContext* pContext = 2162 CXFA_Document* pDoc = pThis->ToJSContext(nullptr)->GetDocument();
2204 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
2205 CXFA_Document* pDoc = pContext->GetDocument();
2206 if (!pDoc) { 2163 if (!pDoc) {
2207 return FALSE; 2164 return FALSE;
2208 } 2165 }
2209 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); 2166 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr();
2210 IFX_Locale* pLocale = nullptr; 2167 IFX_Locale* pLocale = nullptr;
2211 if (szLocale.IsEmpty()) { 2168 if (szLocale.IsEmpty()) {
2212 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); 2169 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
2213 ASSERT(pThisNode); 2170 ASSERT(pThisNode);
2214 CXFA_WidgetData widgetData(pThisNode); 2171 CXFA_WidgetData widgetData(pThisNode);
2215 pLocale = widgetData.GetLocal(); 2172 pLocale = widgetData.GetLocal();
(...skipping 15 matching lines...) Expand all
2231 strIsoDate.Format("%4d-%02d-%02d", dt.GetYear(), dt.GetMonth(), dt.GetDay()); 2188 strIsoDate.Format("%4d-%02d-%02d", dt.GetYear(), dt.GetMonth(), dt.GetDay());
2232 return TRUE; 2189 return TRUE;
2233 } 2190 }
2234 2191
2235 // static 2192 // static
2236 FX_BOOL CXFA_FM2JSContext::Local2IsoTime(CFXJSE_Value* pThis, 2193 FX_BOOL CXFA_FM2JSContext::Local2IsoTime(CFXJSE_Value* pThis,
2237 const CFX_ByteStringC& szTime, 2194 const CFX_ByteStringC& szTime,
2238 const CFX_ByteStringC& szFormat, 2195 const CFX_ByteStringC& szFormat,
2239 const CFX_ByteStringC& szLocale, 2196 const CFX_ByteStringC& szLocale,
2240 CFX_ByteString& strIsoTime) { 2197 CFX_ByteString& strIsoTime) {
2241 CXFA_FM2JSContext* pContext = 2198 CXFA_Document* pDoc = pThis->ToJSContext(nullptr)->GetDocument();
2242 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
2243 CXFA_Document* pDoc = pContext->GetDocument();
2244 if (!pDoc) { 2199 if (!pDoc) {
2245 return FALSE; 2200 return FALSE;
2246 } 2201 }
2247 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); 2202 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr();
2248 IFX_Locale* pLocale = nullptr; 2203 IFX_Locale* pLocale = nullptr;
2249 if (szLocale.IsEmpty()) { 2204 if (szLocale.IsEmpty()) {
2250 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); 2205 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
2251 ASSERT(pThisNode); 2206 ASSERT(pThisNode);
2252 CXFA_WidgetData widgetData(pThisNode); 2207 CXFA_WidgetData widgetData(pThisNode);
2253 pLocale = widgetData.GetLocal(); 2208 pLocale = widgetData.GetLocal();
(...skipping 18 matching lines...) Expand all
2272 utime.GetSecond(), utime.GetMillisecond()); 2227 utime.GetSecond(), utime.GetMillisecond());
2273 return TRUE; 2228 return TRUE;
2274 } 2229 }
2275 2230
2276 // static 2231 // static
2277 FX_BOOL CXFA_FM2JSContext::IsoDate2Local(CFXJSE_Value* pThis, 2232 FX_BOOL CXFA_FM2JSContext::IsoDate2Local(CFXJSE_Value* pThis,
2278 const CFX_ByteStringC& szDate, 2233 const CFX_ByteStringC& szDate,
2279 const CFX_ByteStringC& szFormat, 2234 const CFX_ByteStringC& szFormat,
2280 const CFX_ByteStringC& szLocale, 2235 const CFX_ByteStringC& szLocale,
2281 CFX_ByteString& strLocalDate) { 2236 CFX_ByteString& strLocalDate) {
2282 CXFA_FM2JSContext* pContext = 2237 CXFA_Document* pDoc = pThis->ToJSContext(nullptr)->GetDocument();
2283 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
2284 CXFA_Document* pDoc = pContext->GetDocument();
2285 if (!pDoc) { 2238 if (!pDoc) {
2286 return FALSE; 2239 return FALSE;
2287 } 2240 }
2288 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); 2241 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr();
2289 IFX_Locale* pLocale = nullptr; 2242 IFX_Locale* pLocale = nullptr;
2290 if (szLocale.IsEmpty()) { 2243 if (szLocale.IsEmpty()) {
2291 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); 2244 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
2292 ASSERT(pThisNode); 2245 ASSERT(pThisNode);
2293 CXFA_WidgetData widgetData(pThisNode); 2246 CXFA_WidgetData widgetData(pThisNode);
2294 pLocale = widgetData.GetLocal(); 2247 pLocale = widgetData.GetLocal();
(...skipping 17 matching lines...) Expand all
2312 strLocalDate = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()); 2265 strLocalDate = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength());
2313 return TRUE; 2266 return TRUE;
2314 } 2267 }
2315 2268
2316 // static 2269 // static
2317 FX_BOOL CXFA_FM2JSContext::IsoTime2Local(CFXJSE_Value* pThis, 2270 FX_BOOL CXFA_FM2JSContext::IsoTime2Local(CFXJSE_Value* pThis,
2318 const CFX_ByteStringC& szTime, 2271 const CFX_ByteStringC& szTime,
2319 const CFX_ByteStringC& szFormat, 2272 const CFX_ByteStringC& szFormat,
2320 const CFX_ByteStringC& szLocale, 2273 const CFX_ByteStringC& szLocale,
2321 CFX_ByteString& strLocalTime) { 2274 CFX_ByteString& strLocalTime) {
2322 CXFA_FM2JSContext* pContext = 2275 CXFA_Document* pDoc = pThis->ToJSContext(nullptr)->GetDocument();
2323 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
2324 CXFA_Document* pDoc = pContext->GetDocument();
2325 if (!pDoc) { 2276 if (!pDoc) {
2326 return FALSE; 2277 return FALSE;
2327 } 2278 }
2328 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); 2279 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr();
2329 IFX_Locale* pLocale = nullptr; 2280 IFX_Locale* pLocale = nullptr;
2330 if (szLocale.IsEmpty()) { 2281 if (szLocale.IsEmpty()) {
2331 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); 2282 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
2332 ASSERT(pThisNode); 2283 ASSERT(pThisNode);
2333 CXFA_WidgetData widgetData(pThisNode); 2284 CXFA_WidgetData widgetData(pThisNode);
2334 pLocale = widgetData.GetLocal(); 2285 pLocale = widgetData.GetLocal();
(...skipping 19 matching lines...) Expand all
2354 strLocalTime = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()); 2305 strLocalTime = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength());
2355 return TRUE; 2306 return TRUE;
2356 } 2307 }
2357 2308
2358 // static 2309 // static
2359 FX_BOOL CXFA_FM2JSContext::GetGMTTime(CFXJSE_Value* pThis, 2310 FX_BOOL CXFA_FM2JSContext::GetGMTTime(CFXJSE_Value* pThis,
2360 const CFX_ByteStringC& szTime, 2311 const CFX_ByteStringC& szTime,
2361 const CFX_ByteStringC& szFormat, 2312 const CFX_ByteStringC& szFormat,
2362 const CFX_ByteStringC& szLocale, 2313 const CFX_ByteStringC& szLocale,
2363 CFX_ByteString& strGMTTime) { 2314 CFX_ByteString& strGMTTime) {
2364 CXFA_FM2JSContext* pContext = 2315 CXFA_Document* pDoc = pThis->ToJSContext(nullptr)->GetDocument();
2365 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
2366 CXFA_Document* pDoc = pContext->GetDocument();
2367 if (!pDoc) { 2316 if (!pDoc) {
2368 return FALSE; 2317 return FALSE;
2369 } 2318 }
2370 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); 2319 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr();
2371 IFX_Locale* pLocale = nullptr; 2320 IFX_Locale* pLocale = nullptr;
2372 if (szLocale.IsEmpty()) { 2321 if (szLocale.IsEmpty()) {
2373 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); 2322 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
2374 ASSERT(pThisNode); 2323 ASSERT(pThisNode);
2375 CXFA_WidgetData widgetData(pThisNode); 2324 CXFA_WidgetData widgetData(pThisNode);
2376 pLocale = widgetData.GetLocal(); 2325 pLocale = widgetData.GetLocal();
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2491 case 3: 2440 case 3:
2492 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Long; 2441 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Long;
2493 break; 2442 break;
2494 case 4: 2443 case 4:
2495 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Full; 2444 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Full;
2496 break; 2445 break;
2497 default: 2446 default:
2498 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; 2447 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium;
2499 break; 2448 break;
2500 } 2449 }
2501 CXFA_FM2JSContext* pContext = 2450
2502 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 2451 CXFA_Document* pDoc = pThis->ToJSContext(nullptr)->GetDocument();
2503 CXFA_Document* pDoc = pContext->GetDocument();
2504 if (!pDoc) { 2452 if (!pDoc) {
2505 return; 2453 return;
2506 } 2454 }
2507 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); 2455 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr();
2508 IFX_Locale* pLocale = nullptr; 2456 IFX_Locale* pLocale = nullptr;
2509 if (szLocalStr.IsEmpty()) { 2457 if (szLocalStr.IsEmpty()) {
2510 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); 2458 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
2511 ASSERT(pThisNode); 2459 ASSERT(pThisNode);
2512 CXFA_WidgetData widgetData(pThisNode); 2460 CXFA_WidgetData widgetData(pThisNode);
2513 pLocale = widgetData.GetLocal(); 2461 pLocale = widgetData.GetLocal();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2547 case 3: 2495 case 3:
2548 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Long; 2496 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Long;
2549 break; 2497 break;
2550 case 4: 2498 case 4:
2551 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Full; 2499 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Full;
2552 break; 2500 break;
2553 default: 2501 default:
2554 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; 2502 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium;
2555 break; 2503 break;
2556 } 2504 }
2557 CXFA_FM2JSContext* pContext = 2505
2558 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 2506 CXFA_Document* pDoc = pThis->ToJSContext(nullptr)->GetDocument();
2559 CXFA_Document* pDoc = pContext->GetDocument();
2560 if (!pDoc) { 2507 if (!pDoc) {
2561 return; 2508 return;
2562 } 2509 }
2563 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); 2510 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr();
2564 IFX_Locale* pLocale = nullptr; 2511 IFX_Locale* pLocale = nullptr;
2565 if (szLocalStr.IsEmpty()) { 2512 if (szLocalStr.IsEmpty()) {
2566 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); 2513 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
2567 ASSERT(pThisNode); 2514 ASSERT(pThisNode);
2568 CXFA_WidgetData widgetData(pThisNode); 2515 CXFA_WidgetData widgetData(pThisNode);
2569 pLocale = widgetData.GetLocal(); 2516 pLocale = widgetData.GetLocal();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2652 int32_t iLocalSec = pLocal->tm_sec; 2599 int32_t iLocalSec = pLocal->tm_sec;
2653 iHour = iLocalHour - iGMHour; 2600 iHour = iLocalHour - iGMHour;
2654 iMin = iLocalMin - iGMMin; 2601 iMin = iLocalMin - iGMMin;
2655 iSec = iLocalSec - iGMSec; 2602 iSec = iLocalSec - iGMSec;
2656 } 2603 }
2657 2604
2658 // static 2605 // static
2659 void CXFA_FM2JSContext::Apr(CFXJSE_Value* pThis, 2606 void CXFA_FM2JSContext::Apr(CFXJSE_Value* pThis,
2660 const CFX_ByteStringC& szFuncName, 2607 const CFX_ByteStringC& szFuncName,
2661 CFXJSE_Arguments& args) { 2608 CFXJSE_Arguments& args) {
2662 CXFA_FM2JSContext* pContext = 2609 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
2663 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
2664 if (args.GetLength() == 3) { 2610 if (args.GetLength() == 3) {
2665 FX_BOOL bFlags = FALSE; 2611 FX_BOOL bFlags = FALSE;
2666 FX_DOUBLE nPrincipal = 0; 2612 FX_DOUBLE nPrincipal = 0;
2667 FX_DOUBLE nPayment = 0; 2613 FX_DOUBLE nPayment = 0;
2668 FX_DOUBLE nPeriods = 0; 2614 FX_DOUBLE nPeriods = 0;
2669 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2615 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
2670 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 2616 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
2671 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 2617 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
2672 bFlags = 2618 bFlags =
2673 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || 2619 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) ||
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2717 } else { 2663 } else {
2718 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 2664 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
2719 L"Apr"); 2665 L"Apr");
2720 } 2666 }
2721 } 2667 }
2722 2668
2723 // static 2669 // static
2724 void CXFA_FM2JSContext::CTerm(CFXJSE_Value* pThis, 2670 void CXFA_FM2JSContext::CTerm(CFXJSE_Value* pThis,
2725 const CFX_ByteStringC& szFuncName, 2671 const CFX_ByteStringC& szFuncName,
2726 CFXJSE_Arguments& args) { 2672 CFXJSE_Arguments& args) {
2727 CXFA_FM2JSContext* pContext = 2673 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
2728 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
2729 if (args.GetLength() == 3) { 2674 if (args.GetLength() == 3) {
2730 FX_BOOL bFlags = FALSE; 2675 FX_BOOL bFlags = FALSE;
2731 FX_FLOAT nRate = 0; 2676 FX_FLOAT nRate = 0;
2732 FX_FLOAT nFutureValue = 0; 2677 FX_FLOAT nFutureValue = 0;
2733 FX_FLOAT nInitAmount = 0; 2678 FX_FLOAT nInitAmount = 0;
2734 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2679 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
2735 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 2680 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
2736 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 2681 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
2737 bFlags = 2682 bFlags =
2738 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || 2683 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) ||
(...skipping 16 matching lines...) Expand all
2755 } else { 2700 } else {
2756 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 2701 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
2757 L"CTerm"); 2702 L"CTerm");
2758 } 2703 }
2759 } 2704 }
2760 2705
2761 // static 2706 // static
2762 void CXFA_FM2JSContext::FV(CFXJSE_Value* pThis, 2707 void CXFA_FM2JSContext::FV(CFXJSE_Value* pThis,
2763 const CFX_ByteStringC& szFuncName, 2708 const CFX_ByteStringC& szFuncName,
2764 CFXJSE_Arguments& args) { 2709 CFXJSE_Arguments& args) {
2765 CXFA_FM2JSContext* pContext = 2710 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
2766 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
2767 if (args.GetLength() == 3) { 2711 if (args.GetLength() == 3) {
2768 FX_BOOL bFlags = FALSE; 2712 FX_BOOL bFlags = FALSE;
2769 FX_DOUBLE nAmount = 0; 2713 FX_DOUBLE nAmount = 0;
2770 FX_DOUBLE nRate = 0; 2714 FX_DOUBLE nRate = 0;
2771 FX_DOUBLE nPeriod = 0; 2715 FX_DOUBLE nPeriod = 0;
2772 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2716 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
2773 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 2717 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
2774 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 2718 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
2775 bFlags = 2719 bFlags =
2776 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || 2720 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) ||
(...skipping 24 matching lines...) Expand all
2801 } else { 2745 } else {
2802 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 2746 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
2803 L"FV"); 2747 L"FV");
2804 } 2748 }
2805 } 2749 }
2806 2750
2807 // static 2751 // static
2808 void CXFA_FM2JSContext::IPmt(CFXJSE_Value* pThis, 2752 void CXFA_FM2JSContext::IPmt(CFXJSE_Value* pThis,
2809 const CFX_ByteStringC& szFuncName, 2753 const CFX_ByteStringC& szFuncName,
2810 CFXJSE_Arguments& args) { 2754 CFXJSE_Arguments& args) {
2811 CXFA_FM2JSContext* pContext = 2755 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
2812 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
2813 if (args.GetLength() == 5) { 2756 if (args.GetLength() == 5) {
2814 FX_BOOL bFlags = FALSE; 2757 FX_BOOL bFlags = FALSE;
2815 FX_FLOAT nPrincpalAmount = 0; 2758 FX_FLOAT nPrincpalAmount = 0;
2816 FX_FLOAT nRate = 0; 2759 FX_FLOAT nRate = 0;
2817 FX_FLOAT nPayment = 0; 2760 FX_FLOAT nPayment = 0;
2818 FX_FLOAT nFirstMonth = 0; 2761 FX_FLOAT nFirstMonth = 0;
2819 FX_FLOAT nNumberOfMonths = 0; 2762 FX_FLOAT nNumberOfMonths = 0;
2820 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2763 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
2821 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 2764 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
2822 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 2765 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2873 } else { 2816 } else {
2874 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 2817 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
2875 L"IPmt"); 2818 L"IPmt");
2876 } 2819 }
2877 } 2820 }
2878 2821
2879 // static 2822 // static
2880 void CXFA_FM2JSContext::NPV(CFXJSE_Value* pThis, 2823 void CXFA_FM2JSContext::NPV(CFXJSE_Value* pThis,
2881 const CFX_ByteStringC& szFuncName, 2824 const CFX_ByteStringC& szFuncName,
2882 CFXJSE_Arguments& args) { 2825 CFXJSE_Arguments& args) {
2883 CXFA_FM2JSContext* pContext = 2826 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
2884 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
2885 int32_t argc = args.GetLength(); 2827 int32_t argc = args.GetLength();
2886 if (argc > 2) { 2828 if (argc > 2) {
2887 FX_BOOL bFlags = FALSE; 2829 FX_BOOL bFlags = FALSE;
2888 std::vector<std::unique_ptr<CFXJSE_Value>> argValues; 2830 std::vector<std::unique_ptr<CFXJSE_Value>> argValues;
2889 for (int32_t i = 0; i < argc; i++) { 2831 for (int32_t i = 0; i < argc; i++) {
2890 argValues.push_back(GetSimpleValue(pThis, args, i)); 2832 argValues.push_back(GetSimpleValue(pThis, args, i));
2891 if (ValueIsNull(pThis, argValues[i].get())) { 2833 if (ValueIsNull(pThis, argValues[i].get())) {
2892 bFlags = TRUE; 2834 bFlags = TRUE;
2893 } 2835 }
2894 } 2836 }
(...skipping 27 matching lines...) Expand all
2922 } else { 2864 } else {
2923 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 2865 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
2924 L"NPV"); 2866 L"NPV");
2925 } 2867 }
2926 } 2868 }
2927 2869
2928 // static 2870 // static
2929 void CXFA_FM2JSContext::Pmt(CFXJSE_Value* pThis, 2871 void CXFA_FM2JSContext::Pmt(CFXJSE_Value* pThis,
2930 const CFX_ByteStringC& szFuncName, 2872 const CFX_ByteStringC& szFuncName,
2931 CFXJSE_Arguments& args) { 2873 CFXJSE_Arguments& args) {
2932 CXFA_FM2JSContext* pContext = 2874 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
2933 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
2934 if (args.GetLength() == 3) { 2875 if (args.GetLength() == 3) {
2935 FX_BOOL bFlags = FALSE; 2876 FX_BOOL bFlags = FALSE;
2936 FX_FLOAT nPrincipal = 0; 2877 FX_FLOAT nPrincipal = 0;
2937 FX_FLOAT nRate = 0; 2878 FX_FLOAT nRate = 0;
2938 FX_FLOAT nPeriods = 0; 2879 FX_FLOAT nPeriods = 0;
2939 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2880 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
2940 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 2881 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
2941 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 2882 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
2942 bFlags = 2883 bFlags =
2943 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || 2884 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) ||
(...skipping 21 matching lines...) Expand all
2965 } else { 2906 } else {
2966 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 2907 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
2967 L"Pmt"); 2908 L"Pmt");
2968 } 2909 }
2969 } 2910 }
2970 2911
2971 // static 2912 // static
2972 void CXFA_FM2JSContext::PPmt(CFXJSE_Value* pThis, 2913 void CXFA_FM2JSContext::PPmt(CFXJSE_Value* pThis,
2973 const CFX_ByteStringC& szFuncName, 2914 const CFX_ByteStringC& szFuncName,
2974 CFXJSE_Arguments& args) { 2915 CFXJSE_Arguments& args) {
2975 CXFA_FM2JSContext* pContext = 2916 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
2976 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
2977 if (args.GetLength() == 5) { 2917 if (args.GetLength() == 5) {
2978 FX_BOOL bFlags = FALSE; 2918 FX_BOOL bFlags = FALSE;
2979 FX_FLOAT nPrincpalAmount = 0; 2919 FX_FLOAT nPrincpalAmount = 0;
2980 FX_FLOAT nRate = 0; 2920 FX_FLOAT nRate = 0;
2981 FX_FLOAT nPayment = 0; 2921 FX_FLOAT nPayment = 0;
2982 FX_FLOAT nFirstMonth = 0; 2922 FX_FLOAT nFirstMonth = 0;
2983 FX_FLOAT nNumberOfMonths = 0; 2923 FX_FLOAT nNumberOfMonths = 0;
2984 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2924 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
2985 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 2925 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
2986 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 2926 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
3038 } else { 2978 } else {
3039 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 2979 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
3040 L"PPmt"); 2980 L"PPmt");
3041 } 2981 }
3042 } 2982 }
3043 2983
3044 // static 2984 // static
3045 void CXFA_FM2JSContext::PV(CFXJSE_Value* pThis, 2985 void CXFA_FM2JSContext::PV(CFXJSE_Value* pThis,
3046 const CFX_ByteStringC& szFuncName, 2986 const CFX_ByteStringC& szFuncName,
3047 CFXJSE_Arguments& args) { 2987 CFXJSE_Arguments& args) {
3048 CXFA_FM2JSContext* pContext = 2988 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
3049 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
3050 if (args.GetLength() == 3) { 2989 if (args.GetLength() == 3) {
3051 FX_BOOL bFlags = FALSE; 2990 FX_BOOL bFlags = FALSE;
3052 FX_DOUBLE nAmount = 0; 2991 FX_DOUBLE nAmount = 0;
3053 FX_DOUBLE nRate = 0; 2992 FX_DOUBLE nRate = 0;
3054 FX_DOUBLE nPeriod = 0; 2993 FX_DOUBLE nPeriod = 0;
3055 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2994 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
3056 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 2995 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
3057 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 2996 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
3058 bFlags = 2997 bFlags =
3059 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || 2998 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) ||
(...skipping 20 matching lines...) Expand all
3080 } else { 3019 } else {
3081 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 3020 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
3082 L"PV"); 3021 L"PV");
3083 } 3022 }
3084 } 3023 }
3085 3024
3086 // static 3025 // static
3087 void CXFA_FM2JSContext::Rate(CFXJSE_Value* pThis, 3026 void CXFA_FM2JSContext::Rate(CFXJSE_Value* pThis,
3088 const CFX_ByteStringC& szFuncName, 3027 const CFX_ByteStringC& szFuncName,
3089 CFXJSE_Arguments& args) { 3028 CFXJSE_Arguments& args) {
3090 CXFA_FM2JSContext* pContext = 3029 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
3091 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
3092 if (args.GetLength() == 3) { 3030 if (args.GetLength() == 3) {
3093 FX_BOOL bFlags = FALSE; 3031 FX_BOOL bFlags = FALSE;
3094 FX_FLOAT nFuture = 0; 3032 FX_FLOAT nFuture = 0;
3095 FX_FLOAT nPresent = 0; 3033 FX_FLOAT nPresent = 0;
3096 FX_FLOAT nTotalNumber = 0; 3034 FX_FLOAT nTotalNumber = 0;
3097 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 3035 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
3098 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 3036 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
3099 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 3037 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
3100 bFlags = 3038 bFlags =
3101 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || 3039 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) ||
(...skipping 17 matching lines...) Expand all
3119 } else { 3057 } else {
3120 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 3058 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
3121 L"Rate"); 3059 L"Rate");
3122 } 3060 }
3123 } 3061 }
3124 3062
3125 // static 3063 // static
3126 void CXFA_FM2JSContext::Term(CFXJSE_Value* pThis, 3064 void CXFA_FM2JSContext::Term(CFXJSE_Value* pThis,
3127 const CFX_ByteStringC& szFuncName, 3065 const CFX_ByteStringC& szFuncName,
3128 CFXJSE_Arguments& args) { 3066 CFXJSE_Arguments& args) {
3129 CXFA_FM2JSContext* pContext = 3067 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
3130 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
3131 if (args.GetLength() == 3) { 3068 if (args.GetLength() == 3) {
3132 FX_BOOL bFlags = FALSE; 3069 FX_BOOL bFlags = FALSE;
3133 FX_FLOAT nMount = 0; 3070 FX_FLOAT nMount = 0;
3134 FX_FLOAT nRate = 0; 3071 FX_FLOAT nRate = 0;
3135 FX_FLOAT nFuture = 0; 3072 FX_FLOAT nFuture = 0;
3136 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 3073 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
3137 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 3074 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
3138 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 3075 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
3139 bFlags = 3076 bFlags =
3140 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || 3077 (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) ||
(...skipping 17 matching lines...) Expand all
3158 } else { 3095 } else {
3159 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 3096 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
3160 L"Term"); 3097 L"Term");
3161 } 3098 }
3162 } 3099 }
3163 3100
3164 // static 3101 // static
3165 void CXFA_FM2JSContext::Choose(CFXJSE_Value* pThis, 3102 void CXFA_FM2JSContext::Choose(CFXJSE_Value* pThis,
3166 const CFX_ByteStringC& szFuncName, 3103 const CFX_ByteStringC& szFuncName,
3167 CFXJSE_Arguments& args) { 3104 CFXJSE_Arguments& args) {
3168 CXFA_FM2JSContext* pContext = 3105 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
3169 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
3170 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 3106 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
3171 int32_t argc = args.GetLength(); 3107 int32_t argc = args.GetLength();
3172 if (argc > 1) { 3108 if (argc > 1) {
3173 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 3109 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
3174 FX_BOOL argOneIsNull = FALSE; 3110 FX_BOOL argOneIsNull = FALSE;
3175 int32_t iIndex = 0; 3111 int32_t iIndex = 0;
3176 argOneIsNull = ValueIsNull(pThis, argOne.get()); 3112 argOneIsNull = ValueIsNull(pThis, argOne.get());
3177 if (!argOneIsNull) { 3113 if (!argOneIsNull) {
3178 iIndex = (int32_t)ValueToFloat(pThis, argOne.get()); 3114 iIndex = (int32_t)ValueToFloat(pThis, argOne.get());
3179 } 3115 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
3235 bFound = TRUE; 3171 bFound = TRUE;
3236 } 3172 }
3237 } 3173 }
3238 iArgIndex++; 3174 iArgIndex++;
3239 } 3175 }
3240 if (!bFound) { 3176 if (!bFound) {
3241 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); 3177 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "");
3242 } 3178 }
3243 } 3179 }
3244 } else { 3180 } else {
3245 CXFA_FM2JSContext* pContext =
3246 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
3247 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 3181 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
3248 L"Choose"); 3182 L"Choose");
3249 } 3183 }
3250 } 3184 }
3251 3185
3252 // static 3186 // static
3253 void CXFA_FM2JSContext::Exists(CFXJSE_Value* pThis, 3187 void CXFA_FM2JSContext::Exists(CFXJSE_Value* pThis,
3254 const CFX_ByteStringC& szFuncName, 3188 const CFX_ByteStringC& szFuncName,
3255 CFXJSE_Arguments& args) { 3189 CFXJSE_Arguments& args) {
3256 if (args.GetLength() == 1) { 3190 if (args.GetLength() == 1) {
3257 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 3191 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
3258 FXJSE_Value_SetInteger(args.GetReturnValue(), 3192 FXJSE_Value_SetInteger(args.GetReturnValue(),
3259 FXJSE_Value_IsObject(argOne.get())); 3193 FXJSE_Value_IsObject(argOne.get()));
3260 } else { 3194 } else {
3261 CXFA_FM2JSContext* pContext = 3195 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
3262 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3196 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Exists");
3263 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
3264 L"Exists");
3265 } 3197 }
3266 } 3198 }
3267 3199
3268 // static 3200 // static
3269 void CXFA_FM2JSContext::HasValue(CFXJSE_Value* pThis, 3201 void CXFA_FM2JSContext::HasValue(CFXJSE_Value* pThis,
3270 const CFX_ByteStringC& szFuncName, 3202 const CFX_ByteStringC& szFuncName,
3271 CFXJSE_Arguments& args) { 3203 CFXJSE_Arguments& args) {
3272 if (args.GetLength() == 1) { 3204 if (args.GetLength() == 1) {
3273 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 3205 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
3274 if (FXJSE_Value_IsUTF8String(argOne.get())) { 3206 if (FXJSE_Value_IsUTF8String(argOne.get())) {
3275 CFX_ByteString valueStr; 3207 CFX_ByteString valueStr;
3276 FXJSE_Value_ToUTF8String(argOne.get(), valueStr); 3208 FXJSE_Value_ToUTF8String(argOne.get(), valueStr);
3277 valueStr.TrimLeft(); 3209 valueStr.TrimLeft();
3278 FXJSE_Value_SetInteger(args.GetReturnValue(), (!valueStr.IsEmpty())); 3210 FXJSE_Value_SetInteger(args.GetReturnValue(), (!valueStr.IsEmpty()));
3279 } else if (FXJSE_Value_IsNumber(argOne.get()) || 3211 } else if (FXJSE_Value_IsNumber(argOne.get()) ||
3280 FXJSE_Value_IsBoolean(argOne.get())) { 3212 FXJSE_Value_IsBoolean(argOne.get())) {
3281 FXJSE_Value_SetInteger(args.GetReturnValue(), TRUE); 3213 FXJSE_Value_SetInteger(args.GetReturnValue(), TRUE);
3282 } else { 3214 } else {
3283 FXJSE_Value_SetInteger(args.GetReturnValue(), FALSE); 3215 FXJSE_Value_SetInteger(args.GetReturnValue(), FALSE);
3284 } 3216 }
3285 } else { 3217 } else {
3286 CXFA_FM2JSContext* pContext = 3218 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
3287 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3219 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"HasValue");
3288 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
3289 L"HasValue");
3290 } 3220 }
3291 } 3221 }
3292 3222
3293 // static 3223 // static
3294 void CXFA_FM2JSContext::Oneof(CFXJSE_Value* pThis, 3224 void CXFA_FM2JSContext::Oneof(CFXJSE_Value* pThis,
3295 const CFX_ByteStringC& szFuncName, 3225 const CFX_ByteStringC& szFuncName,
3296 CFXJSE_Arguments& args) { 3226 CFXJSE_Arguments& args) {
3297 if (args.GetLength() > 1) { 3227 if (args.GetLength() > 1) {
3298 FX_BOOL bFlags = FALSE; 3228 FX_BOOL bFlags = FALSE;
3299 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 3229 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
3300 CFXJSE_Value** parametersValue = nullptr; 3230 CFXJSE_Value** parametersValue = nullptr;
3301 int32_t iCount = 0; 3231 int32_t iCount = 0;
3302 unfoldArgs(pThis, args, parametersValue, iCount, 1); 3232 unfoldArgs(pThis, args, parametersValue, iCount, 1);
3303 for (int32_t i = 0; i < iCount; i++) { 3233 for (int32_t i = 0; i < iCount; i++) {
3304 if (simpleValueCompare(pThis, argOne.get(), parametersValue[i])) { 3234 if (simpleValueCompare(pThis, argOne.get(), parametersValue[i])) {
3305 bFlags = TRUE; 3235 bFlags = TRUE;
3306 break; 3236 break;
3307 } 3237 }
3308 } 3238 }
3309 FXJSE_Value_SetInteger(args.GetReturnValue(), bFlags); 3239 FXJSE_Value_SetInteger(args.GetReturnValue(), bFlags);
3310 for (int32_t i = 0; i < iCount; i++) { 3240 for (int32_t i = 0; i < iCount; i++) {
3311 delete parametersValue[i]; 3241 delete parametersValue[i];
3312 } 3242 }
3313 FX_Free(parametersValue); 3243 FX_Free(parametersValue);
3314 } else { 3244 } else {
3315 CXFA_FM2JSContext* pContext = 3245 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
3316 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3246 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Oneof");
3317 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
3318 L"Oneof");
3319 } 3247 }
3320 } 3248 }
3321 3249
3322 // static 3250 // static
3323 void CXFA_FM2JSContext::Within(CFXJSE_Value* pThis, 3251 void CXFA_FM2JSContext::Within(CFXJSE_Value* pThis,
3324 const CFX_ByteStringC& szFuncName, 3252 const CFX_ByteStringC& szFuncName,
3325 CFXJSE_Arguments& args) { 3253 CFXJSE_Arguments& args) {
3326 if (args.GetLength() == 3) { 3254 if (args.GetLength() == 3) {
3327 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 3255 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
3328 if (FXJSE_Value_IsNull(argOne.get())) { 3256 if (FXJSE_Value_IsNull(argOne.get())) {
(...skipping 15 matching lines...) Expand all
3344 ValueToUTF8String(argOne.get(), oneString); 3272 ValueToUTF8String(argOne.get(), oneString);
3345 ValueToUTF8String(argLow.get(), lowString); 3273 ValueToUTF8String(argLow.get(), lowString);
3346 ValueToUTF8String(argHeight.get(), heightString); 3274 ValueToUTF8String(argHeight.get(), heightString);
3347 FXJSE_Value_SetInteger( 3275 FXJSE_Value_SetInteger(
3348 args.GetReturnValue(), 3276 args.GetReturnValue(),
3349 ((oneString.Compare(lowString.AsStringC()) >= 0) && 3277 ((oneString.Compare(lowString.AsStringC()) >= 0) &&
3350 (oneString.Compare(heightString.AsStringC()) <= 0))); 3278 (oneString.Compare(heightString.AsStringC()) <= 0)));
3351 } 3279 }
3352 } 3280 }
3353 } else { 3281 } else {
3354 CXFA_FM2JSContext* pContext = 3282 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
3355 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3283 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Within");
3356 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
3357 L"Within");
3358 } 3284 }
3359 } 3285 }
3360 3286
3361 // static 3287 // static
3362 void CXFA_FM2JSContext::If(CFXJSE_Value* pThis, 3288 void CXFA_FM2JSContext::If(CFXJSE_Value* pThis,
3363 const CFX_ByteStringC& szFuncName, 3289 const CFX_ByteStringC& szFuncName,
3364 CFXJSE_Arguments& args) { 3290 CFXJSE_Arguments& args) {
3365 if (args.GetLength() == 3) { 3291 if (args.GetLength() == 3) {
3366 std::unique_ptr<CFXJSE_Value> argCondition = GetSimpleValue(pThis, args, 0); 3292 std::unique_ptr<CFXJSE_Value> argCondition = GetSimpleValue(pThis, args, 0);
3367 std::unique_ptr<CFXJSE_Value> argFirstValue = 3293 std::unique_ptr<CFXJSE_Value> argFirstValue =
3368 GetSimpleValue(pThis, args, 1); 3294 GetSimpleValue(pThis, args, 1);
3369 std::unique_ptr<CFXJSE_Value> argSecondValue = 3295 std::unique_ptr<CFXJSE_Value> argSecondValue =
3370 GetSimpleValue(pThis, args, 2); 3296 GetSimpleValue(pThis, args, 2);
3371 FX_BOOL bCondition = FXJSE_Value_ToBoolean(argCondition.get()); 3297 FX_BOOL bCondition = FXJSE_Value_ToBoolean(argCondition.get());
3372 FXJSE_Value_Set(args.GetReturnValue(), 3298 FXJSE_Value_Set(args.GetReturnValue(),
3373 bCondition ? argFirstValue.get() : argSecondValue.get()); 3299 bCondition ? argFirstValue.get() : argSecondValue.get());
3374 } else { 3300 } else {
3375 CXFA_FM2JSContext* pContext = 3301 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
3376 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3302 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"If");
3377 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
3378 L"If");
3379 } 3303 }
3380 } 3304 }
3381 3305
3382 // static 3306 // static
3383 void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis, 3307 void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis,
3384 const CFX_ByteStringC& szFuncName, 3308 const CFX_ByteStringC& szFuncName,
3385 CFXJSE_Arguments& args) { 3309 CFXJSE_Arguments& args) {
3386 CXFA_FM2JSContext* pContext = 3310 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
3387 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
3388 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 3311 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
3389 if (args.GetLength() == 1) { 3312 if (args.GetLength() == 1) {
3390 std::unique_ptr<CFXJSE_Value> scriptValue = GetSimpleValue(pThis, args, 0); 3313 std::unique_ptr<CFXJSE_Value> scriptValue = GetSimpleValue(pThis, args, 0);
3391 CFX_ByteString utf8ScriptString; 3314 CFX_ByteString utf8ScriptString;
3392 ValueToUTF8String(scriptValue.get(), utf8ScriptString); 3315 ValueToUTF8String(scriptValue.get(), utf8ScriptString);
3393 if (utf8ScriptString.IsEmpty()) { 3316 if (utf8ScriptString.IsEmpty()) {
3394 FXJSE_Value_SetNull(args.GetReturnValue()); 3317 FXJSE_Value_SetNull(args.GetReturnValue());
3395 } else { 3318 } else {
3396 CFX_WideTextBuf wsJavaScriptBuf; 3319 CFX_WideTextBuf wsJavaScriptBuf;
3397 CFX_WideString javaScript; 3320 CFX_WideString javaScript;
3398 CFX_WideString wsError; 3321 CFX_WideString wsError;
3399 CXFA_FM2JSContext::Translate( 3322 CXFA_FM2JSContext::Translate(
3400 CFX_WideString::FromUTF8(utf8ScriptString.AsStringC()).AsStringC(), 3323 CFX_WideString::FromUTF8(utf8ScriptString.AsStringC()).AsStringC(),
3401 wsJavaScriptBuf, wsError); 3324 wsJavaScriptBuf, wsError);
3402 CFXJSE_Context* pContext = 3325 CFXJSE_Context* pTempContext =
dsinclair 2016/06/01 14:49:33 Shadow'd variable.
3403 FXJSE_Context_Create(pIsolate, nullptr, nullptr); 3326 FXJSE_Context_Create(pIsolate, nullptr, nullptr);
3404 std::unique_ptr<CFXJSE_Value> returnValue(new CFXJSE_Value(pIsolate)); 3327 std::unique_ptr<CFXJSE_Value> returnValue(new CFXJSE_Value(pIsolate));
3405 javaScript = wsJavaScriptBuf.AsStringC(); 3328 javaScript = wsJavaScriptBuf.AsStringC();
3406 FXJSE_ExecuteScript( 3329 FXJSE_ExecuteScript(
3407 pContext, 3330 pTempContext,
3408 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(), 3331 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(),
3409 returnValue.get()); 3332 returnValue.get());
3410 FXJSE_Value_Set(args.GetReturnValue(), returnValue.get()); 3333 FXJSE_Value_Set(args.GetReturnValue(), returnValue.get());
3411 FXJSE_Context_Release(pContext); 3334 FXJSE_Context_Release(pTempContext);
3412 } 3335 }
3413 } else { 3336 } else {
3414 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 3337 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
3415 L"Eval"); 3338 L"Eval");
3416 } 3339 }
3417 } 3340 }
3418 3341
3419 // static 3342 // static
3420 void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis, 3343 void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis,
3421 const CFX_ByteStringC& szFuncName, 3344 const CFX_ByteStringC& szFuncName,
3422 CFXJSE_Arguments& args) { 3345 CFXJSE_Arguments& args) {
3423 CXFA_FM2JSContext* pContext = 3346 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
3424 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
3425 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 3347 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
3426 if (args.GetLength() == 1) { 3348 if (args.GetLength() == 1) {
3427 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 3349 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
3428 if (FXJSE_Value_IsNull(argOne.get())) { 3350 if (FXJSE_Value_IsNull(argOne.get())) {
3429 CFXJSE_Value* rgValues[3]; 3351 CFXJSE_Value* rgValues[3];
3430 for (int32_t i = 0; i < 3; i++) 3352 for (int32_t i = 0; i < 3; i++)
3431 rgValues[i] = new CFXJSE_Value(pIsolate); 3353 rgValues[i] = new CFXJSE_Value(pIsolate);
3432 3354
3433 FXJSE_Value_SetInteger(rgValues[0], 4); 3355 FXJSE_Value_SetInteger(rgValues[0], 4);
3434 FXJSE_Value_SetNull(rgValues[1]); 3356 FXJSE_Value_SetNull(rgValues[1]);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
3594 break; 3516 break;
3595 case VALUETYPE_ISMP: 3517 case VALUETYPE_ISMP:
3596 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "mp"); 3518 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "mp");
3597 break; 3519 break;
3598 default: 3520 default:
3599 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "in"); 3521 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "in");
3600 break; 3522 break;
3601 } 3523 }
3602 } 3524 }
3603 } else { 3525 } else {
3604 CXFA_FM2JSContext* pContext = 3526 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
3605 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3527 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"UnitType");
3606 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
3607 L"UnitType");
3608 } 3528 }
3609 } 3529 }
3610 3530
3611 // static 3531 // static
3612 void CXFA_FM2JSContext::UnitValue(CFXJSE_Value* pThis, 3532 void CXFA_FM2JSContext::UnitValue(CFXJSE_Value* pThis,
3613 const CFX_ByteStringC& szFuncName, 3533 const CFX_ByteStringC& szFuncName,
3614 CFXJSE_Arguments& args) { 3534 CFXJSE_Arguments& args) {
3615 int32_t argc = args.GetLength(); 3535 int32_t argc = args.GetLength();
3616 if ((argc == 1) || (argc == 2)) { 3536 if ((argc == 1) || (argc == 2)) {
3617 std::unique_ptr<CFXJSE_Value> unitspanValue = 3537 std::unique_ptr<CFXJSE_Value> unitspanValue =
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
3752 } else { 3672 } else {
3753 dResult = dFirstNumber / 72000; 3673 dResult = dFirstNumber / 72000;
3754 } 3674 }
3755 } 3675 }
3756 FXJSE_Value_SetDouble(args.GetReturnValue(), dResult); 3676 FXJSE_Value_SetDouble(args.GetReturnValue(), dResult);
3757 } else { 3677 } else {
3758 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); 3678 FXJSE_Value_SetInteger(args.GetReturnValue(), 0);
3759 } 3679 }
3760 } 3680 }
3761 } else { 3681 } else {
3762 CXFA_FM2JSContext* pContext = 3682 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
3763 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3683 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"UnitValue");
3764 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
3765 L"UnitValue");
3766 } 3684 }
3767 } 3685 }
3768 3686
3769 // static 3687 // static
3770 void CXFA_FM2JSContext::At(CFXJSE_Value* pThis, 3688 void CXFA_FM2JSContext::At(CFXJSE_Value* pThis,
3771 const CFX_ByteStringC& szFuncName, 3689 const CFX_ByteStringC& szFuncName,
3772 CFXJSE_Arguments& args) { 3690 CFXJSE_Arguments& args) {
3773 if (args.GetLength() == 2) { 3691 if (args.GetLength() == 2) {
3774 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 3692 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
3775 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 3693 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
3776 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get())) { 3694 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get())) {
3777 FXJSE_Value_SetNull(args.GetReturnValue()); 3695 FXJSE_Value_SetNull(args.GetReturnValue());
3778 } else { 3696 } else {
3779 CFX_ByteString stringTwo; 3697 CFX_ByteString stringTwo;
3780 ValueToUTF8String(argTwo.get(), stringTwo); 3698 ValueToUTF8String(argTwo.get(), stringTwo);
3781 if (stringTwo.IsEmpty()) { 3699 if (stringTwo.IsEmpty()) {
3782 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); 3700 FXJSE_Value_SetInteger(args.GetReturnValue(), 1);
3783 } else { 3701 } else {
3784 CFX_ByteString stringOne; 3702 CFX_ByteString stringOne;
3785 ValueToUTF8String(argOne.get(), stringOne); 3703 ValueToUTF8String(argOne.get(), stringOne);
3786 FX_STRSIZE iPosition = stringOne.Find(stringTwo.AsStringC()); 3704 FX_STRSIZE iPosition = stringOne.Find(stringTwo.AsStringC());
3787 FXJSE_Value_SetInteger(args.GetReturnValue(), iPosition + 1); 3705 FXJSE_Value_SetInteger(args.GetReturnValue(), iPosition + 1);
3788 } 3706 }
3789 } 3707 }
3790 } else { 3708 } else {
3791 CXFA_FM2JSContext* pContext = 3709 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
3792 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3710 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"At");
3793 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
3794 L"At");
3795 } 3711 }
3796 } 3712 }
3797 3713
3798 // static 3714 // static
3799 void CXFA_FM2JSContext::Concat(CFXJSE_Value* pThis, 3715 void CXFA_FM2JSContext::Concat(CFXJSE_Value* pThis,
3800 const CFX_ByteStringC& szFuncName, 3716 const CFX_ByteStringC& szFuncName,
3801 CFXJSE_Arguments& args) { 3717 CFXJSE_Arguments& args) {
3802 int32_t argc = args.GetLength(); 3718 int32_t argc = args.GetLength();
3803 if (argc >= 1) { 3719 if (argc >= 1) {
3804 CFX_ByteString resultString; 3720 CFX_ByteString resultString;
3805 FX_BOOL bAllNull = TRUE; 3721 FX_BOOL bAllNull = TRUE;
3806 3722
3807 for (int32_t i = 0; i < argc; i++) { 3723 for (int32_t i = 0; i < argc; i++) {
3808 std::unique_ptr<CFXJSE_Value> value = GetSimpleValue(pThis, args, i); 3724 std::unique_ptr<CFXJSE_Value> value = GetSimpleValue(pThis, args, i);
3809 if (!ValueIsNull(pThis, value.get())) { 3725 if (!ValueIsNull(pThis, value.get())) {
3810 CFX_ByteString valueStr; 3726 CFX_ByteString valueStr;
3811 ValueToUTF8String(value.get(), valueStr); 3727 ValueToUTF8String(value.get(), valueStr);
3812 resultString += valueStr; 3728 resultString += valueStr;
3813 bAllNull = FALSE; 3729 bAllNull = FALSE;
3814 } 3730 }
3815 } 3731 }
3816 3732
3817 if (bAllNull) { 3733 if (bAllNull) {
3818 FXJSE_Value_SetNull(args.GetReturnValue()); 3734 FXJSE_Value_SetNull(args.GetReturnValue());
3819 } else { 3735 } else {
3820 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 3736 FXJSE_Value_SetUTF8String(args.GetReturnValue(),
3821 resultString.AsStringC()); 3737 resultString.AsStringC());
3822 } 3738 }
3823 } else { 3739 } else {
3824 CXFA_FM2JSContext* pContext = 3740 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
3825 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3741 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Concat");
3826 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
3827 L"Concat");
3828 } 3742 }
3829 } 3743 }
3830 3744
3831 // static 3745 // static
3832 void CXFA_FM2JSContext::Decode(CFXJSE_Value* pThis, 3746 void CXFA_FM2JSContext::Decode(CFXJSE_Value* pThis,
3833 const CFX_ByteStringC& szFuncName, 3747 const CFX_ByteStringC& szFuncName,
3834 CFXJSE_Arguments& args) { 3748 CFXJSE_Arguments& args) {
3835 int32_t argc = args.GetLength(); 3749 int32_t argc = args.GetLength();
3836 if (argc == 1) { 3750 if (argc == 1) {
3837 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 3751 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
(...skipping 20 matching lines...) Expand all
3858 if (identifyString.EqualNoCase("html")) { 3772 if (identifyString.EqualNoCase("html")) {
3859 DecodeHTML(toDecodeString.AsStringC(), resultBuf); 3773 DecodeHTML(toDecodeString.AsStringC(), resultBuf);
3860 } else if (identifyString.EqualNoCase("xml")) { 3774 } else if (identifyString.EqualNoCase("xml")) {
3861 DecodeXML(toDecodeString.AsStringC(), resultBuf); 3775 DecodeXML(toDecodeString.AsStringC(), resultBuf);
3862 } else { 3776 } else {
3863 DecodeURL(toDecodeString.AsStringC(), resultBuf); 3777 DecodeURL(toDecodeString.AsStringC(), resultBuf);
3864 } 3778 }
3865 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); 3779 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC());
3866 } 3780 }
3867 } else { 3781 } else {
3868 CXFA_FM2JSContext* pContext = 3782 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
3869 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 3783 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Decode");
3870 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
3871 L"Decode");
3872 } 3784 }
3873 } 3785 }
3874 3786
3875 // static 3787 // static
3876 void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString, 3788 void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString,
3877 CFX_ByteTextBuf& szResultString) { 3789 CFX_ByteTextBuf& szResultString) {
3878 CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString); 3790 CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString);
3879 const FX_WCHAR* pData = wsURLString.c_str(); 3791 const FX_WCHAR* pData = wsURLString.c_str();
3880 int32_t iLen = wsURLString.GetLength(); 3792 int32_t iLen = wsURLString.GetLength();
3881 int32_t i = 0; 3793 int32_t i = 0;
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
4134 if (identifyString.EqualNoCase("html")) { 4046 if (identifyString.EqualNoCase("html")) {
4135 EncodeHTML(toEncodeString.AsStringC(), resultBuf); 4047 EncodeHTML(toEncodeString.AsStringC(), resultBuf);
4136 } else if (identifyString.EqualNoCase("xml")) { 4048 } else if (identifyString.EqualNoCase("xml")) {
4137 EncodeXML(toEncodeString.AsStringC(), resultBuf); 4049 EncodeXML(toEncodeString.AsStringC(), resultBuf);
4138 } else { 4050 } else {
4139 EncodeURL(toEncodeString.AsStringC(), resultBuf); 4051 EncodeURL(toEncodeString.AsStringC(), resultBuf);
4140 } 4052 }
4141 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); 4053 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC());
4142 } 4054 }
4143 } else { 4055 } else {
4144 CXFA_FM2JSContext* pContext = 4056 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
4145 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 4057 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Encode");
4146 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
4147 L"Encode");
4148 } 4058 }
4149 } 4059 }
4150 4060
4151 // static 4061 // static
4152 void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString, 4062 void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString,
4153 CFX_ByteTextBuf& szResultBuf) { 4063 CFX_ByteTextBuf& szResultBuf) {
4154 CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString); 4064 CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString);
4155 CFX_WideTextBuf wsResultBuf; 4065 CFX_WideTextBuf wsResultBuf;
4156 FX_WCHAR ch = 0; 4066 FX_WCHAR ch = 0;
4157 int32_t iLength = wsURLString.GetLength(); 4067 int32_t iLength = wsURLString.GetLength();
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
4437 iStart = iMid + 1; 4347 iStart = iMid + 1;
4438 } 4348 }
4439 } while (iStart <= iEnd); 4349 } while (iStart <= iEnd);
4440 return FALSE; 4350 return FALSE;
4441 } 4351 }
4442 4352
4443 // static 4353 // static
4444 void CXFA_FM2JSContext::Format(CFXJSE_Value* pThis, 4354 void CXFA_FM2JSContext::Format(CFXJSE_Value* pThis,
4445 const CFX_ByteStringC& szFuncName, 4355 const CFX_ByteStringC& szFuncName,
4446 CFXJSE_Arguments& args) { 4356 CFXJSE_Arguments& args) {
4447 CXFA_FM2JSContext* pContext = 4357 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
4448 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
4449 if (args.GetLength() >= 2) { 4358 if (args.GetLength() >= 2) {
4450 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 4359 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
4451 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 4360 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
4452 CFX_ByteString szPattern; 4361 CFX_ByteString szPattern;
4453 ValueToUTF8String(argOne.get(), szPattern); 4362 ValueToUTF8String(argOne.get(), szPattern);
4454 CFX_ByteString szValue; 4363 CFX_ByteString szValue;
4455 ValueToUTF8String(argTwo.get(), szValue); 4364 ValueToUTF8String(argTwo.get(), szValue);
4456 CXFA_Document* pDoc = pContext->GetDocument(); 4365 CXFA_Document* pDoc = pContext->GetDocument();
4457 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); 4366 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr();
4458 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); 4367 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
4543 CFX_ByteString sourceString; 4452 CFX_ByteString sourceString;
4544 ValueToUTF8String(argOne.get(), sourceString); 4453 ValueToUTF8String(argOne.get(), sourceString);
4545 int32_t count = ValueToInteger(pThis, argTwo.get()); 4454 int32_t count = ValueToInteger(pThis, argTwo.get());
4546 if (count < 0) { 4455 if (count < 0) {
4547 count = 0; 4456 count = 0;
4548 } 4457 }
4549 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 4458 FXJSE_Value_SetUTF8String(args.GetReturnValue(),
4550 sourceString.Left(count).AsStringC()); 4459 sourceString.Left(count).AsStringC());
4551 } 4460 }
4552 } else { 4461 } else {
4553 CXFA_FM2JSContext* pContext = 4462 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
4554 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 4463 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Left");
4555 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
4556 L"Left");
4557 } 4464 }
4558 } 4465 }
4559 4466
4560 // static 4467 // static
4561 void CXFA_FM2JSContext::Len(CFXJSE_Value* pThis, 4468 void CXFA_FM2JSContext::Len(CFXJSE_Value* pThis,
4562 const CFX_ByteStringC& szFuncName, 4469 const CFX_ByteStringC& szFuncName,
4563 CFXJSE_Arguments& args) { 4470 CFXJSE_Arguments& args) {
4564 if (args.GetLength() == 1) { 4471 if (args.GetLength() == 1) {
4565 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 4472 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
4566 if (ValueIsNull(pThis, argOne.get())) { 4473 if (ValueIsNull(pThis, argOne.get())) {
4567 FXJSE_Value_SetNull(args.GetReturnValue()); 4474 FXJSE_Value_SetNull(args.GetReturnValue());
4568 } else { 4475 } else {
4569 CFX_ByteString sourceString; 4476 CFX_ByteString sourceString;
4570 ValueToUTF8String(argOne.get(), sourceString); 4477 ValueToUTF8String(argOne.get(), sourceString);
4571 FXJSE_Value_SetInteger(args.GetReturnValue(), sourceString.GetLength()); 4478 FXJSE_Value_SetInteger(args.GetReturnValue(), sourceString.GetLength());
4572 } 4479 }
4573 } else { 4480 } else {
4574 CXFA_FM2JSContext* pContext = 4481 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
4575 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 4482 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Len");
4576 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
4577 L"Len");
4578 } 4483 }
4579 } 4484 }
4580 4485
4581 // static 4486 // static
4582 void CXFA_FM2JSContext::Lower(CFXJSE_Value* pThis, 4487 void CXFA_FM2JSContext::Lower(CFXJSE_Value* pThis,
4583 const CFX_ByteStringC& szFuncName, 4488 const CFX_ByteStringC& szFuncName,
4584 CFXJSE_Arguments& args) { 4489 CFXJSE_Arguments& args) {
4585 int32_t argc = args.GetLength(); 4490 int32_t argc = args.GetLength();
4586 if ((argc > 0) && (argc < 3)) { 4491 if ((argc > 0) && (argc < 3)) {
4587 CFX_ByteString argString; 4492 CFX_ByteString argString;
(...skipping 21 matching lines...) Expand all
4609 lowStringBuf.AppendChar(ch); 4514 lowStringBuf.AppendChar(ch);
4610 ++i; 4515 ++i;
4611 } 4516 }
4612 lowStringBuf.AppendChar(0); 4517 lowStringBuf.AppendChar(0);
4613 FXJSE_Value_SetUTF8String( 4518 FXJSE_Value_SetUTF8String(
4614 args.GetReturnValue(), 4519 args.GetReturnValue(),
4615 FX_UTF8Encode(lowStringBuf.GetBuffer(), lowStringBuf.GetLength()) 4520 FX_UTF8Encode(lowStringBuf.GetBuffer(), lowStringBuf.GetLength())
4616 .AsStringC()); 4521 .AsStringC());
4617 } 4522 }
4618 } else { 4523 } else {
4619 CXFA_FM2JSContext* pContext = 4524 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
4620 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 4525 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Lower");
4621 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
4622 L"Lower");
4623 } 4526 }
4624 } 4527 }
4625 4528
4626 // static 4529 // static
4627 void CXFA_FM2JSContext::Ltrim(CFXJSE_Value* pThis, 4530 void CXFA_FM2JSContext::Ltrim(CFXJSE_Value* pThis,
4628 const CFX_ByteStringC& szFuncName, 4531 const CFX_ByteStringC& szFuncName,
4629 CFXJSE_Arguments& args) { 4532 CFXJSE_Arguments& args) {
4630 if (args.GetLength() == 1) { 4533 if (args.GetLength() == 1) {
4631 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 4534 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
4632 if (ValueIsNull(pThis, argOne.get())) { 4535 if (ValueIsNull(pThis, argOne.get())) {
4633 FXJSE_Value_SetNull(args.GetReturnValue()); 4536 FXJSE_Value_SetNull(args.GetReturnValue());
4634 } else { 4537 } else {
4635 CFX_ByteString sourceString; 4538 CFX_ByteString sourceString;
4636 ValueToUTF8String(argOne.get(), sourceString); 4539 ValueToUTF8String(argOne.get(), sourceString);
4637 sourceString.TrimLeft(); 4540 sourceString.TrimLeft();
4638 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 4541 FXJSE_Value_SetUTF8String(args.GetReturnValue(),
4639 sourceString.AsStringC()); 4542 sourceString.AsStringC());
4640 } 4543 }
4641 } else { 4544 } else {
4642 CXFA_FM2JSContext* pContext = 4545 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
4643 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 4546 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Ltrim");
4644 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
4645 L"Ltrim");
4646 } 4547 }
4647 } 4548 }
4648 4549
4649 // static 4550 // static
4650 void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis, 4551 void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis,
4651 const CFX_ByteStringC& szFuncName, 4552 const CFX_ByteStringC& szFuncName,
4652 CFXJSE_Arguments& args) { 4553 CFXJSE_Arguments& args) {
4653 CXFA_FM2JSContext* pContext = 4554 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
4654 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
4655 if (args.GetLength() == 2) { 4555 if (args.GetLength() == 2) {
4656 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 4556 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
4657 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 4557 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
4658 if (ValueIsNull(pThis, argTwo.get())) { 4558 if (ValueIsNull(pThis, argTwo.get())) {
4659 FXJSE_Value_SetNull(args.GetReturnValue()); 4559 FXJSE_Value_SetNull(args.GetReturnValue());
4660 } else { 4560 } else {
4661 CFX_ByteString szPattern; 4561 CFX_ByteString szPattern;
4662 ValueToUTF8String(argOne.get(), szPattern); 4562 ValueToUTF8String(argOne.get(), szPattern);
4663 CFX_ByteString szValue; 4563 CFX_ByteString szValue;
4664 ValueToUTF8String(argTwo.get(), szValue); 4564 ValueToUTF8String(argTwo.get(), szValue);
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
4835 } else { 4735 } else {
4836 resultString.AppendChar(ch); 4736 resultString.AppendChar(ch);
4837 } 4737 }
4838 } else { 4738 } else {
4839 resultString.AppendChar(ch); 4739 resultString.AppendChar(ch);
4840 } 4740 }
4841 } 4741 }
4842 resultString.AppendChar(0); 4742 resultString.AppendChar(0);
4843 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); 4743 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC());
4844 } else { 4744 } else {
4845 CXFA_FM2JSContext* pContext = 4745 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
4846 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 4746 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Replace");
4847 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
4848 L"Replace");
4849 } 4747 }
4850 } 4748 }
4851 4749
4852 // static 4750 // static
4853 void CXFA_FM2JSContext::Right(CFXJSE_Value* pThis, 4751 void CXFA_FM2JSContext::Right(CFXJSE_Value* pThis,
4854 const CFX_ByteStringC& szFuncName, 4752 const CFX_ByteStringC& szFuncName,
4855 CFXJSE_Arguments& args) { 4753 CFXJSE_Arguments& args) {
4856 if (args.GetLength() == 2) { 4754 if (args.GetLength() == 2) {
4857 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 4755 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
4858 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 4756 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
4859 FX_BOOL argIsNull = FALSE; 4757 FX_BOOL argIsNull = FALSE;
4860 if ((ValueIsNull(pThis, argOne.get())) || 4758 if ((ValueIsNull(pThis, argOne.get())) ||
4861 (ValueIsNull(pThis, argTwo.get()))) { 4759 (ValueIsNull(pThis, argTwo.get()))) {
4862 argIsNull = TRUE; 4760 argIsNull = TRUE;
4863 } 4761 }
4864 if (argIsNull) { 4762 if (argIsNull) {
4865 FXJSE_Value_SetNull(args.GetReturnValue()); 4763 FXJSE_Value_SetNull(args.GetReturnValue());
4866 } else { 4764 } else {
4867 CFX_ByteString sourceString; 4765 CFX_ByteString sourceString;
4868 ValueToUTF8String(argOne.get(), sourceString); 4766 ValueToUTF8String(argOne.get(), sourceString);
4869 int32_t count = ValueToInteger(pThis, argTwo.get()); 4767 int32_t count = ValueToInteger(pThis, argTwo.get());
4870 if (count < 0) { 4768 if (count < 0) {
4871 count = 0; 4769 count = 0;
4872 } 4770 }
4873 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 4771 FXJSE_Value_SetUTF8String(args.GetReturnValue(),
4874 sourceString.Right(count).AsStringC()); 4772 sourceString.Right(count).AsStringC());
4875 } 4773 }
4876 } else { 4774 } else {
4877 CXFA_FM2JSContext* pContext = 4775 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
4878 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 4776 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Right");
4879 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
4880 L"Right");
4881 } 4777 }
4882 } 4778 }
4883 4779
4884 // static 4780 // static
4885 void CXFA_FM2JSContext::Rtrim(CFXJSE_Value* pThis, 4781 void CXFA_FM2JSContext::Rtrim(CFXJSE_Value* pThis,
4886 const CFX_ByteStringC& szFuncName, 4782 const CFX_ByteStringC& szFuncName,
4887 CFXJSE_Arguments& args) { 4783 CFXJSE_Arguments& args) {
4888 if (args.GetLength() == 1) { 4784 if (args.GetLength() == 1) {
4889 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 4785 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
4890 if (ValueIsNull(pThis, argOne.get())) { 4786 if (ValueIsNull(pThis, argOne.get())) {
4891 FXJSE_Value_SetNull(args.GetReturnValue()); 4787 FXJSE_Value_SetNull(args.GetReturnValue());
4892 } else { 4788 } else {
4893 CFX_ByteString sourceString; 4789 CFX_ByteString sourceString;
4894 ValueToUTF8String(argOne.get(), sourceString); 4790 ValueToUTF8String(argOne.get(), sourceString);
4895 sourceString.TrimRight(); 4791 sourceString.TrimRight();
4896 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 4792 FXJSE_Value_SetUTF8String(args.GetReturnValue(),
4897 sourceString.AsStringC()); 4793 sourceString.AsStringC());
4898 } 4794 }
4899 } else { 4795 } else {
4900 CXFA_FM2JSContext* pContext = 4796 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
4901 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 4797 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Rtrim");
4902 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
4903 L"Rtrim");
4904 } 4798 }
4905 } 4799 }
4906 4800
4907 // static 4801 // static
4908 void CXFA_FM2JSContext::Space(CFXJSE_Value* pThis, 4802 void CXFA_FM2JSContext::Space(CFXJSE_Value* pThis,
4909 const CFX_ByteStringC& szFuncName, 4803 const CFX_ByteStringC& szFuncName,
4910 CFXJSE_Arguments& args) { 4804 CFXJSE_Arguments& args) {
4911 if (args.GetLength() == 1) { 4805 if (args.GetLength() == 1) {
4912 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 4806 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
4913 if (FXJSE_Value_IsNull(argOne.get())) { 4807 if (FXJSE_Value_IsNull(argOne.get())) {
4914 FXJSE_Value_SetNull(args.GetReturnValue()); 4808 FXJSE_Value_SetNull(args.GetReturnValue());
4915 } else { 4809 } else {
4916 int32_t count = 0; 4810 int32_t count = 0;
4917 count = ValueToInteger(pThis, argOne.get()); 4811 count = ValueToInteger(pThis, argOne.get());
4918 count = (count < 0) ? 0 : count; 4812 count = (count < 0) ? 0 : count;
4919 CFX_ByteTextBuf spaceString; 4813 CFX_ByteTextBuf spaceString;
4920 int32_t index = 0; 4814 int32_t index = 0;
4921 while (index < count) { 4815 while (index < count) {
4922 spaceString.AppendByte(' '); 4816 spaceString.AppendByte(' ');
4923 index++; 4817 index++;
4924 } 4818 }
4925 spaceString.AppendByte(0); 4819 spaceString.AppendByte(0);
4926 FXJSE_Value_SetUTF8String(args.GetReturnValue(), spaceString.AsStringC()); 4820 FXJSE_Value_SetUTF8String(args.GetReturnValue(), spaceString.AsStringC());
4927 } 4821 }
4928 } else { 4822 } else {
4929 CXFA_FM2JSContext* pContext = 4823 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
4930 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 4824 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Space");
4931 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
4932 L"Space");
4933 } 4825 }
4934 } 4826 }
4935 4827
4936 // static 4828 // static
4937 void CXFA_FM2JSContext::Str(CFXJSE_Value* pThis, 4829 void CXFA_FM2JSContext::Str(CFXJSE_Value* pThis,
4938 const CFX_ByteStringC& szFuncName, 4830 const CFX_ByteStringC& szFuncName,
4939 CFXJSE_Arguments& args) { 4831 CFXJSE_Arguments& args) {
4940 int32_t argc = args.GetLength(); 4832 int32_t argc = args.GetLength();
4941 if ((argc > 0) && (argc < 4)) { 4833 if ((argc > 0) && (argc < 4)) {
4942 FX_BOOL bFlags = FALSE; 4834 FX_BOOL bFlags = FALSE;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
5039 ++i; 4931 ++i;
5040 } 4932 }
5041 resultBuf.AppendChar(0); 4933 resultBuf.AppendChar(0);
5042 } 4934 }
5043 } 4935 }
5044 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); 4936 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC());
5045 } else { 4937 } else {
5046 FXJSE_Value_SetNull(args.GetReturnValue()); 4938 FXJSE_Value_SetNull(args.GetReturnValue());
5047 } 4939 }
5048 } else { 4940 } else {
5049 CXFA_FM2JSContext* pContext = 4941 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
5050 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 4942 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Str");
5051 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
5052 L"Str");
5053 } 4943 }
5054 } 4944 }
5055 4945
5056 // static 4946 // static
5057 void CXFA_FM2JSContext::Stuff(CFXJSE_Value* pThis, 4947 void CXFA_FM2JSContext::Stuff(CFXJSE_Value* pThis,
5058 const CFX_ByteStringC& szFuncName, 4948 const CFX_ByteStringC& szFuncName,
5059 CFXJSE_Arguments& args) { 4949 CFXJSE_Arguments& args) {
5060 int32_t argc = args.GetLength(); 4950 int32_t argc = args.GetLength();
5061 if ((argc == 3) || (argc == 4)) { 4951 if ((argc == 3) || (argc == 4)) {
5062 CFX_ByteString sourceString; 4952 CFX_ByteString sourceString;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
5098 } 4988 }
5099 resultString << insertString.AsStringC(); 4989 resultString << insertString.AsStringC();
5100 i = iStart + iDelete; 4990 i = iStart + iDelete;
5101 while (i < iLength) { 4991 while (i < iLength) {
5102 resultString.AppendChar(sourceString.GetAt(i)); 4992 resultString.AppendChar(sourceString.GetAt(i));
5103 ++i; 4993 ++i;
5104 } 4994 }
5105 resultString.AppendChar(0); 4995 resultString.AppendChar(0);
5106 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); 4996 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC());
5107 } else { 4997 } else {
5108 CXFA_FM2JSContext* pContext = 4998 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
5109 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 4999 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Stuff");
5110 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
5111 L"Stuff");
5112 } 5000 }
5113 } 5001 }
5114 5002
5115 // static 5003 // static
5116 void CXFA_FM2JSContext::Substr(CFXJSE_Value* pThis, 5004 void CXFA_FM2JSContext::Substr(CFXJSE_Value* pThis,
5117 const CFX_ByteStringC& szFuncName, 5005 const CFX_ByteStringC& szFuncName,
5118 CFXJSE_Arguments& args) { 5006 CFXJSE_Arguments& args) {
5119 if (args.GetLength() == 3) { 5007 if (args.GetLength() == 3) {
5120 std::unique_ptr<CFXJSE_Value> stringValue = GetSimpleValue(pThis, args, 0); 5008 std::unique_ptr<CFXJSE_Value> stringValue = GetSimpleValue(pThis, args, 0);
5121 std::unique_ptr<CFXJSE_Value> startValue = GetSimpleValue(pThis, args, 1); 5009 std::unique_ptr<CFXJSE_Value> startValue = GetSimpleValue(pThis, args, 1);
(...skipping 21 matching lines...) Expand all
5143 } 5031 }
5144 if (iCount <= 0) { 5032 if (iCount <= 0) {
5145 iCount = 0; 5033 iCount = 0;
5146 } 5034 }
5147 iStart -= 1; 5035 iStart -= 1;
5148 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 5036 FXJSE_Value_SetUTF8String(args.GetReturnValue(),
5149 szSourceStr.Mid(iStart, iCount).AsStringC()); 5037 szSourceStr.Mid(iStart, iCount).AsStringC());
5150 } 5038 }
5151 } 5039 }
5152 } else { 5040 } else {
5153 CXFA_FM2JSContext* pContext = 5041 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
5154 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5042 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Substr");
5155 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
5156 L"Substr");
5157 } 5043 }
5158 } 5044 }
5159 5045
5160 // static 5046 // static
5161 void CXFA_FM2JSContext::Uuid(CFXJSE_Value* pThis, 5047 void CXFA_FM2JSContext::Uuid(CFXJSE_Value* pThis,
5162 const CFX_ByteStringC& szFuncName, 5048 const CFX_ByteStringC& szFuncName,
5163 CFXJSE_Arguments& args) { 5049 CFXJSE_Arguments& args) {
5164 int32_t argc = args.GetLength(); 5050 int32_t argc = args.GetLength();
5165 if ((argc == 0) || (argc == 1)) { 5051 if ((argc == 0) || (argc == 1)) {
5166 int32_t iNum = 0; 5052 int32_t iNum = 0;
5167 if (argc == 1) { 5053 if (argc == 1) {
5168 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 5054 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
5169 iNum = (int32_t)ValueToFloat(pThis, argOne.get()); 5055 iNum = (int32_t)ValueToFloat(pThis, argOne.get());
5170 } 5056 }
5171 FX_GUID guid; 5057 FX_GUID guid;
5172 FX_GUID_CreateV4(&guid); 5058 FX_GUID_CreateV4(&guid);
5173 CFX_ByteString bsUId; 5059 CFX_ByteString bsUId;
5174 FX_GUID_ToString(&guid, bsUId, iNum); 5060 FX_GUID_ToString(&guid, bsUId, iNum);
5175 FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsUId.AsStringC()); 5061 FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsUId.AsStringC());
5176 } else { 5062 } else {
5177 CXFA_FM2JSContext* pContext = 5063 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
5178 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5064 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Uuid");
5179 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
5180 L"Uuid");
5181 } 5065 }
5182 } 5066 }
5183 5067
5184 // static 5068 // static
5185 void CXFA_FM2JSContext::Upper(CFXJSE_Value* pThis, 5069 void CXFA_FM2JSContext::Upper(CFXJSE_Value* pThis,
5186 const CFX_ByteStringC& szFuncName, 5070 const CFX_ByteStringC& szFuncName,
5187 CFXJSE_Arguments& args) { 5071 CFXJSE_Arguments& args) {
5188 int32_t argc = args.GetLength(); 5072 int32_t argc = args.GetLength();
5189 if ((argc > 0) && (argc < 3)) { 5073 if ((argc > 0) && (argc < 3)) {
5190 CFX_ByteString argString; 5074 CFX_ByteString argString;
(...skipping 21 matching lines...) Expand all
5212 upperStringBuf.AppendChar(ch); 5096 upperStringBuf.AppendChar(ch);
5213 ++i; 5097 ++i;
5214 } 5098 }
5215 upperStringBuf.AppendChar(0); 5099 upperStringBuf.AppendChar(0);
5216 FXJSE_Value_SetUTF8String( 5100 FXJSE_Value_SetUTF8String(
5217 args.GetReturnValue(), 5101 args.GetReturnValue(),
5218 FX_UTF8Encode(upperStringBuf.GetBuffer(), upperStringBuf.GetLength()) 5102 FX_UTF8Encode(upperStringBuf.GetBuffer(), upperStringBuf.GetLength())
5219 .AsStringC()); 5103 .AsStringC());
5220 } 5104 }
5221 } else { 5105 } else {
5222 CXFA_FM2JSContext* pContext = 5106 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
5223 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5107 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Upper");
5224 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
5225 L"Upper");
5226 } 5108 }
5227 } 5109 }
5228 5110
5229 // static 5111 // static
5230 void CXFA_FM2JSContext::WordNum(CFXJSE_Value* pThis, 5112 void CXFA_FM2JSContext::WordNum(CFXJSE_Value* pThis,
5231 const CFX_ByteStringC& szFuncName, 5113 const CFX_ByteStringC& szFuncName,
5232 CFXJSE_Arguments& args) { 5114 CFXJSE_Arguments& args) {
5233 int32_t argc = args.GetLength(); 5115 int32_t argc = args.GetLength();
5234 if ((argc > 0) && (argc < 4)) { 5116 if ((argc > 0) && (argc < 4)) {
5235 FX_BOOL bFlags = FALSE; 5117 FX_BOOL bFlags = FALSE;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
5267 CFX_ByteTextBuf resultBuf; 5149 CFX_ByteTextBuf resultBuf;
5268 CFX_ByteString numberString; 5150 CFX_ByteString numberString;
5269 numberString.Format("%.2f", fNumber); 5151 numberString.Format("%.2f", fNumber);
5270 WordUS(numberString.AsStringC(), iIdentifier, resultBuf); 5152 WordUS(numberString.AsStringC(), iIdentifier, resultBuf);
5271 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); 5153 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC());
5272 } 5154 }
5273 } else { 5155 } else {
5274 FXJSE_Value_SetNull(args.GetReturnValue()); 5156 FXJSE_Value_SetNull(args.GetReturnValue());
5275 } 5157 }
5276 } else { 5158 } else {
5277 CXFA_FM2JSContext* pContext = 5159 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
5278 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5160 XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"WordNum");
5279 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
5280 L"WordNum");
5281 } 5161 }
5282 } 5162 }
5283 5163
5284 // static 5164 // static
5285 void CXFA_FM2JSContext::TrillionUS(const CFX_ByteStringC& szData, 5165 void CXFA_FM2JSContext::TrillionUS(const CFX_ByteStringC& szData,
5286 CFX_ByteTextBuf& strBuf) { 5166 CFX_ByteTextBuf& strBuf) {
5287 CFX_ByteStringC pUnits[] = {"zero", "one", "two", "three", "four", 5167 CFX_ByteStringC pUnits[] = {"zero", "one", "two", "three", "four",
5288 "five", "six", "seven", "eight", "nine"}; 5168 "five", "six", "seven", "eight", "nine"};
5289 CFX_ByteStringC pCapUnits[] = {"Zero", "One", "Two", "Three", "Four", 5169 CFX_ByteStringC pCapUnits[] = {"Zero", "One", "Two", "Three", "Four",
5290 "Five", "Six", "Seven", "Eight", "Nine"}; 5170 "Five", "Six", "Seven", "Eight", "Nine"};
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
5477 } break; 5357 } break;
5478 default: 5358 default:
5479 break; 5359 break;
5480 } 5360 }
5481 } 5361 }
5482 5362
5483 // static 5363 // static
5484 void CXFA_FM2JSContext::Get(CFXJSE_Value* pThis, 5364 void CXFA_FM2JSContext::Get(CFXJSE_Value* pThis,
5485 const CFX_ByteStringC& szFuncName, 5365 const CFX_ByteStringC& szFuncName,
5486 CFXJSE_Arguments& args) { 5366 CFXJSE_Arguments& args) {
5487 CXFA_FM2JSContext* pContext = 5367 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
5488 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5489 if (args.GetLength() == 1) { 5368 if (args.GetLength() == 1) {
5490 CXFA_Document* pDoc = pContext->GetDocument(); 5369 CXFA_Document* pDoc = pContext->GetDocument();
5491 if (!pDoc) { 5370 if (!pDoc) {
5492 return; 5371 return;
5493 } 5372 }
5494 IXFA_AppProvider* pAppProvider = 5373 IXFA_AppProvider* pAppProvider =
5495 pDoc->GetParser()->GetNotify()->GetAppProvider(); 5374 pDoc->GetParser()->GetNotify()->GetAppProvider();
5496 if (!pAppProvider) { 5375 if (!pAppProvider) {
5497 return; 5376 return;
5498 } 5377 }
(...skipping 14 matching lines...) Expand all
5513 } else { 5392 } else {
5514 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 5393 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
5515 L"Get"); 5394 L"Get");
5516 } 5395 }
5517 } 5396 }
5518 5397
5519 // static 5398 // static
5520 void CXFA_FM2JSContext::Post(CFXJSE_Value* pThis, 5399 void CXFA_FM2JSContext::Post(CFXJSE_Value* pThis,
5521 const CFX_ByteStringC& szFuncName, 5400 const CFX_ByteStringC& szFuncName,
5522 CFXJSE_Arguments& args) { 5401 CFXJSE_Arguments& args) {
5523 CXFA_FM2JSContext* pContext = 5402 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
5524 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5525 int32_t argc = args.GetLength(); 5403 int32_t argc = args.GetLength();
5526 if ((argc >= 2) && (argc <= 5)) { 5404 if ((argc >= 2) && (argc <= 5)) {
5527 CXFA_Document* pDoc = pContext->GetDocument(); 5405 CXFA_Document* pDoc = pContext->GetDocument();
5528 if (!pDoc) { 5406 if (!pDoc) {
5529 return; 5407 return;
5530 } 5408 }
5531 IXFA_AppProvider* pAppProvider = 5409 IXFA_AppProvider* pAppProvider =
5532 pDoc->GetParser()->GetNotify()->GetAppProvider(); 5410 pDoc->GetParser()->GetNotify()->GetAppProvider();
5533 if (!pAppProvider) { 5411 if (!pAppProvider) {
5534 return; 5412 return;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
5572 } else { 5450 } else {
5573 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 5451 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
5574 L"Post"); 5452 L"Post");
5575 } 5453 }
5576 } 5454 }
5577 5455
5578 // static 5456 // static
5579 void CXFA_FM2JSContext::Put(CFXJSE_Value* pThis, 5457 void CXFA_FM2JSContext::Put(CFXJSE_Value* pThis,
5580 const CFX_ByteStringC& szFuncName, 5458 const CFX_ByteStringC& szFuncName,
5581 CFXJSE_Arguments& args) { 5459 CFXJSE_Arguments& args) {
5582 CXFA_FM2JSContext* pContext = 5460 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
5583 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5584 int32_t argc = args.GetLength(); 5461 int32_t argc = args.GetLength();
5585 if ((argc == 2) || (argc == 3)) { 5462 if ((argc == 2) || (argc == 3)) {
5586 CXFA_Document* pDoc = pContext->GetDocument(); 5463 CXFA_Document* pDoc = pContext->GetDocument();
5587 if (!pDoc) { 5464 if (!pDoc) {
5588 return; 5465 return;
5589 } 5466 }
5590 IXFA_AppProvider* pAppProvider = 5467 IXFA_AppProvider* pAppProvider =
5591 pDoc->GetParser()->GetNotify()->GetAppProvider(); 5468 pDoc->GetParser()->GetNotify()->GetAppProvider();
5592 if (!pAppProvider) { 5469 if (!pAppProvider) {
5593 return; 5470 return;
(...skipping 21 matching lines...) Expand all
5615 } else { 5492 } else {
5616 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 5493 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
5617 L"Put"); 5494 L"Put");
5618 } 5495 }
5619 } 5496 }
5620 5497
5621 // static 5498 // static
5622 void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis, 5499 void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis,
5623 const CFX_ByteStringC& szFuncName, 5500 const CFX_ByteStringC& szFuncName,
5624 CFXJSE_Arguments& args) { 5501 CFXJSE_Arguments& args) {
5625 CXFA_FM2JSContext* pContext = 5502 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
5626 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5627 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 5503 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
5628 if (args.GetLength() == 2) { 5504 if (args.GetLength() == 2) {
5629 std::unique_ptr<CFXJSE_Value> lValue = args.GetValue(0); 5505 std::unique_ptr<CFXJSE_Value> lValue = args.GetValue(0);
5630 std::unique_ptr<CFXJSE_Value> rValue = GetSimpleValue(pThis, args, 1); 5506 std::unique_ptr<CFXJSE_Value> rValue = GetSimpleValue(pThis, args, 1);
5631 FX_BOOL bSetStatus = TRUE; 5507 FX_BOOL bSetStatus = TRUE;
5632 if (FXJSE_Value_IsArray(lValue.get())) { 5508 if (FXJSE_Value_IsArray(lValue.get())) {
5633 std::unique_ptr<CFXJSE_Value> leftLengthValue(new CFXJSE_Value(pIsolate)); 5509 std::unique_ptr<CFXJSE_Value> leftLengthValue(new CFXJSE_Value(pIsolate));
5634 FXJSE_Value_GetObjectProp(lValue.get(), "length", leftLengthValue.get()); 5510 FXJSE_Value_GetObjectProp(lValue.get(), "length", leftLengthValue.get());
5635 int32_t iLeftLength = FXJSE_Value_ToInteger(leftLengthValue.get()); 5511 int32_t iLeftLength = FXJSE_Value_ToInteger(leftLengthValue.get());
5636 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 5512 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
5675 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5551 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
5676 if (FXJSE_Value_IsNull(argFirst.get()) && 5552 if (FXJSE_Value_IsNull(argFirst.get()) &&
5677 FXJSE_Value_IsNull(argSecond.get())) { 5553 FXJSE_Value_IsNull(argSecond.get())) {
5678 FXJSE_Value_SetNull(args.GetReturnValue()); 5554 FXJSE_Value_SetNull(args.GetReturnValue());
5679 } else { 5555 } else {
5680 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); 5556 FX_FLOAT first = ValueToFloat(pThis, argFirst.get());
5681 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); 5557 FX_FLOAT second = ValueToFloat(pThis, argSecond.get());
5682 FXJSE_Value_SetInteger(args.GetReturnValue(), (first || second) ? 1 : 0); 5558 FXJSE_Value_SetInteger(args.GetReturnValue(), (first || second) ? 1 : 0);
5683 } 5559 }
5684 } else { 5560 } else {
5685 CXFA_FM2JSContext* pContext = 5561 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
5686 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5562 XFA_IDS_COMPILER_ERROR);
5687 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR);
5688 } 5563 }
5689 } 5564 }
5690 5565
5691 // static 5566 // static
5692 void CXFA_FM2JSContext::logical_and_operator(CFXJSE_Value* pThis, 5567 void CXFA_FM2JSContext::logical_and_operator(CFXJSE_Value* pThis,
5693 const CFX_ByteStringC& szFuncName, 5568 const CFX_ByteStringC& szFuncName,
5694 CFXJSE_Arguments& args) { 5569 CFXJSE_Arguments& args) {
5695 if (args.GetLength() == 2) { 5570 if (args.GetLength() == 2) {
5696 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5571 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
5697 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5572 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
5698 if (FXJSE_Value_IsNull(argFirst.get()) && 5573 if (FXJSE_Value_IsNull(argFirst.get()) &&
5699 FXJSE_Value_IsNull(argSecond.get())) { 5574 FXJSE_Value_IsNull(argSecond.get())) {
5700 FXJSE_Value_SetNull(args.GetReturnValue()); 5575 FXJSE_Value_SetNull(args.GetReturnValue());
5701 } else { 5576 } else {
5702 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); 5577 FX_FLOAT first = ValueToFloat(pThis, argFirst.get());
5703 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); 5578 FX_FLOAT second = ValueToFloat(pThis, argSecond.get());
5704 FXJSE_Value_SetInteger(args.GetReturnValue(), (first && second) ? 1 : 0); 5579 FXJSE_Value_SetInteger(args.GetReturnValue(), (first && second) ? 1 : 0);
5705 } 5580 }
5706 } else { 5581 } else {
5707 CXFA_FM2JSContext* pContext = 5582 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
5708 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5583 XFA_IDS_COMPILER_ERROR);
5709 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR);
5710 } 5584 }
5711 } 5585 }
5712 5586
5713 // static 5587 // static
5714 void CXFA_FM2JSContext::equality_operator(CFXJSE_Value* pThis, 5588 void CXFA_FM2JSContext::equality_operator(CFXJSE_Value* pThis,
5715 const CFX_ByteStringC& szFuncName, 5589 const CFX_ByteStringC& szFuncName,
5716 CFXJSE_Arguments& args) { 5590 CFXJSE_Arguments& args) {
5717 if (args.GetLength() == 2) { 5591 if (args.GetLength() == 2) {
5718 if (fm_ref_equal(pThis, args)) { 5592 if (fm_ref_equal(pThis, args)) {
5719 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); 5593 FXJSE_Value_SetInteger(args.GetReturnValue(), 1);
(...skipping 16 matching lines...) Expand all
5736 FXJSE_Value_SetInteger(args.GetReturnValue(), 5610 FXJSE_Value_SetInteger(args.GetReturnValue(),
5737 firstOutput == secondOutput); 5611 firstOutput == secondOutput);
5738 } else { 5612 } else {
5739 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5613 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5740 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5614 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5741 FXJSE_Value_SetInteger(args.GetReturnValue(), 5615 FXJSE_Value_SetInteger(args.GetReturnValue(),
5742 (first == second) ? 1 : 0); 5616 (first == second) ? 1 : 0);
5743 } 5617 }
5744 } 5618 }
5745 } else { 5619 } else {
5746 CXFA_FM2JSContext* pContext = 5620 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
5747 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5621 XFA_IDS_COMPILER_ERROR);
5748 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR);
5749 } 5622 }
5750 } 5623 }
5751 5624
5752 // static 5625 // static
5753 void CXFA_FM2JSContext::notequality_operator(CFXJSE_Value* pThis, 5626 void CXFA_FM2JSContext::notequality_operator(CFXJSE_Value* pThis,
5754 const CFX_ByteStringC& szFuncName, 5627 const CFX_ByteStringC& szFuncName,
5755 CFXJSE_Arguments& args) { 5628 CFXJSE_Arguments& args) {
5756 if (args.GetLength() == 2) { 5629 if (args.GetLength() == 2) {
5757 if (fm_ref_equal(pThis, args)) { 5630 if (fm_ref_equal(pThis, args)) {
5758 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); 5631 FXJSE_Value_SetInteger(args.GetReturnValue(), 0);
(...skipping 15 matching lines...) Expand all
5774 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); 5647 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput);
5775 FXJSE_Value_SetInteger(args.GetReturnValue(), 5648 FXJSE_Value_SetInteger(args.GetReturnValue(),
5776 firstOutput != secondOutput); 5649 firstOutput != secondOutput);
5777 } else { 5650 } else {
5778 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5651 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5779 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5652 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5780 FXJSE_Value_SetInteger(args.GetReturnValue(), first != second); 5653 FXJSE_Value_SetInteger(args.GetReturnValue(), first != second);
5781 } 5654 }
5782 } 5655 }
5783 } else { 5656 } else {
5784 CXFA_FM2JSContext* pContext = 5657 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
5785 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5658 XFA_IDS_COMPILER_ERROR);
5786 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR);
5787 } 5659 }
5788 } 5660 }
5789 5661
5790 // static 5662 // static
5791 FX_BOOL CXFA_FM2JSContext::fm_ref_equal(CFXJSE_Value* pThis, 5663 FX_BOOL CXFA_FM2JSContext::fm_ref_equal(CFXJSE_Value* pThis,
5792 CFXJSE_Arguments& args) { 5664 CFXJSE_Arguments& args) {
5793 FX_BOOL bRet = FALSE; 5665 FX_BOOL bRet = FALSE;
5794 CXFA_FM2JSContext* pContext = 5666 v8::Isolate* pIsolate = pThis->ToJSContext(nullptr)->GetScriptRuntime();
5795 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
5796 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
5797 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0); 5667 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0);
5798 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1); 5668 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1);
5799 if (FXJSE_Value_IsArray(argFirst.get()) && 5669 if (FXJSE_Value_IsArray(argFirst.get()) &&
5800 FXJSE_Value_IsArray(argSecond.get())) { 5670 FXJSE_Value_IsArray(argSecond.get())) {
5801 std::unique_ptr<CFXJSE_Value> firstFlagValue(new CFXJSE_Value(pIsolate)); 5671 std::unique_ptr<CFXJSE_Value> firstFlagValue(new CFXJSE_Value(pIsolate));
5802 std::unique_ptr<CFXJSE_Value> secondFlagValue(new CFXJSE_Value(pIsolate)); 5672 std::unique_ptr<CFXJSE_Value> secondFlagValue(new CFXJSE_Value(pIsolate));
5803 FXJSE_Value_GetObjectPropByIdx(argFirst.get(), 0, firstFlagValue.get()); 5673 FXJSE_Value_GetObjectPropByIdx(argFirst.get(), 0, firstFlagValue.get());
5804 FXJSE_Value_GetObjectPropByIdx(argSecond.get(), 0, secondFlagValue.get()); 5674 FXJSE_Value_GetObjectPropByIdx(argSecond.get(), 0, secondFlagValue.get());
5805 if ((FXJSE_Value_ToInteger(firstFlagValue.get()) == 3) && 5675 if ((FXJSE_Value_ToInteger(firstFlagValue.get()) == 3) &&
5806 (FXJSE_Value_ToInteger(secondFlagValue.get()) == 3)) { 5676 (FXJSE_Value_ToInteger(secondFlagValue.get()) == 3)) {
5807 std::unique_ptr<CFXJSE_Value> firstJSObject(new CFXJSE_Value(pIsolate)); 5677 std::unique_ptr<CFXJSE_Value> firstJSObject(new CFXJSE_Value(pIsolate));
5808 std::unique_ptr<CFXJSE_Value> secondJSObject(new CFXJSE_Value(pIsolate)); 5678 std::unique_ptr<CFXJSE_Value> secondJSObject(new CFXJSE_Value(pIsolate));
5809 FXJSE_Value_GetObjectPropByIdx(argFirst.get(), 2, firstJSObject.get()); 5679 FXJSE_Value_GetObjectPropByIdx(argFirst.get(), 2, firstJSObject.get());
5810 FXJSE_Value_GetObjectPropByIdx(argSecond.get(), 2, secondJSObject.get()); 5680 FXJSE_Value_GetObjectPropByIdx(argSecond.get(), 2, secondJSObject.get());
5811 if (!FXJSE_Value_IsNull(firstJSObject.get()) && 5681 if (!FXJSE_Value_IsNull(firstJSObject.get()) &&
5812 !FXJSE_Value_IsNull(secondJSObject.get())) { 5682 !FXJSE_Value_IsNull(secondJSObject.get())) {
5813 bRet = (FXJSE_Value_ToObject(firstJSObject.get(), nullptr) == 5683 bRet = (firstJSObject.get()->ToHostObject(nullptr) ==
5814 FXJSE_Value_ToObject(secondJSObject.get(), nullptr)); 5684 secondJSObject.get()->ToHostObject(nullptr));
5815 } 5685 }
5816 } 5686 }
5817 } 5687 }
5818 return bRet; 5688 return bRet;
5819 } 5689 }
5820 5690
5821 // static 5691 // static
5822 void CXFA_FM2JSContext::less_operator(CFXJSE_Value* pThis, 5692 void CXFA_FM2JSContext::less_operator(CFXJSE_Value* pThis,
5823 const CFX_ByteStringC& szFuncName, 5693 const CFX_ByteStringC& szFuncName,
5824 CFXJSE_Arguments& args) { 5694 CFXJSE_Arguments& args) {
(...skipping 11 matching lines...) Expand all
5836 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); 5706 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput);
5837 FXJSE_Value_SetInteger( 5707 FXJSE_Value_SetInteger(
5838 args.GetReturnValue(), 5708 args.GetReturnValue(),
5839 firstOutput.Compare(secondOutput.AsStringC()) == -1); 5709 firstOutput.Compare(secondOutput.AsStringC()) == -1);
5840 } else { 5710 } else {
5841 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5711 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5842 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5712 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5843 FXJSE_Value_SetInteger(args.GetReturnValue(), (first < second) ? 1 : 0); 5713 FXJSE_Value_SetInteger(args.GetReturnValue(), (first < second) ? 1 : 0);
5844 } 5714 }
5845 } else { 5715 } else {
5846 CXFA_FM2JSContext* pContext = 5716 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
5847 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5717 XFA_IDS_COMPILER_ERROR);
5848 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR);
5849 } 5718 }
5850 } 5719 }
5851 5720
5852 // static 5721 // static
5853 void CXFA_FM2JSContext::lessequal_operator(CFXJSE_Value* pThis, 5722 void CXFA_FM2JSContext::lessequal_operator(CFXJSE_Value* pThis,
5854 const CFX_ByteStringC& szFuncName, 5723 const CFX_ByteStringC& szFuncName,
5855 CFXJSE_Arguments& args) { 5724 CFXJSE_Arguments& args) {
5856 if (args.GetLength() == 2) { 5725 if (args.GetLength() == 2) {
5857 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5726 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
5858 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5727 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
(...skipping 12 matching lines...) Expand all
5871 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); 5740 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput);
5872 FXJSE_Value_SetInteger( 5741 FXJSE_Value_SetInteger(
5873 args.GetReturnValue(), 5742 args.GetReturnValue(),
5874 firstOutput.Compare(secondOutput.AsStringC()) != 1); 5743 firstOutput.Compare(secondOutput.AsStringC()) != 1);
5875 } else { 5744 } else {
5876 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5745 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5877 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5746 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5878 FXJSE_Value_SetInteger(args.GetReturnValue(), (first <= second) ? 1 : 0); 5747 FXJSE_Value_SetInteger(args.GetReturnValue(), (first <= second) ? 1 : 0);
5879 } 5748 }
5880 } else { 5749 } else {
5881 CXFA_FM2JSContext* pContext = 5750 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
5882 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5751 XFA_IDS_COMPILER_ERROR);
5883 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR);
5884 } 5752 }
5885 } 5753 }
5886 5754
5887 // static 5755 // static
5888 void CXFA_FM2JSContext::greater_operator(CFXJSE_Value* pThis, 5756 void CXFA_FM2JSContext::greater_operator(CFXJSE_Value* pThis,
5889 const CFX_ByteStringC& szFuncName, 5757 const CFX_ByteStringC& szFuncName,
5890 CFXJSE_Arguments& args) { 5758 CFXJSE_Arguments& args) {
5891 if (args.GetLength() == 2) { 5759 if (args.GetLength() == 2) {
5892 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5760 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
5893 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5761 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
5894 if (FXJSE_Value_IsNull(argFirst.get()) || 5762 if (FXJSE_Value_IsNull(argFirst.get()) ||
5895 FXJSE_Value_IsNull(argSecond.get())) { 5763 FXJSE_Value_IsNull(argSecond.get())) {
5896 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); 5764 FXJSE_Value_SetInteger(args.GetReturnValue(), 0);
5897 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) && 5765 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) &&
5898 FXJSE_Value_IsUTF8String(argSecond.get())) { 5766 FXJSE_Value_IsUTF8String(argSecond.get())) {
5899 CFX_ByteString firstOutput; 5767 CFX_ByteString firstOutput;
5900 CFX_ByteString secondOutput; 5768 CFX_ByteString secondOutput;
5901 FXJSE_Value_ToUTF8String(argFirst.get(), firstOutput); 5769 FXJSE_Value_ToUTF8String(argFirst.get(), firstOutput);
5902 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); 5770 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput);
5903 FXJSE_Value_SetInteger( 5771 FXJSE_Value_SetInteger(
5904 args.GetReturnValue(), 5772 args.GetReturnValue(),
5905 firstOutput.Compare(secondOutput.AsStringC()) == 1); 5773 firstOutput.Compare(secondOutput.AsStringC()) == 1);
5906 } else { 5774 } else {
5907 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5775 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5908 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5776 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5909 FXJSE_Value_SetInteger(args.GetReturnValue(), (first > second) ? 1 : 0); 5777 FXJSE_Value_SetInteger(args.GetReturnValue(), (first > second) ? 1 : 0);
5910 } 5778 }
5911 } else { 5779 } else {
5912 CXFA_FM2JSContext* pContext = 5780 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
5913 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5781 XFA_IDS_COMPILER_ERROR);
5914 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR);
5915 } 5782 }
5916 } 5783 }
5917 5784
5918 // static 5785 // static
5919 void CXFA_FM2JSContext::greaterequal_operator(CFXJSE_Value* pThis, 5786 void CXFA_FM2JSContext::greaterequal_operator(CFXJSE_Value* pThis,
5920 const CFX_ByteStringC& szFuncName, 5787 const CFX_ByteStringC& szFuncName,
5921 CFXJSE_Arguments& args) { 5788 CFXJSE_Arguments& args) {
5922 if (args.GetLength() == 2) { 5789 if (args.GetLength() == 2) {
5923 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5790 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
5924 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5791 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
(...skipping 12 matching lines...) Expand all
5937 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); 5804 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput);
5938 FXJSE_Value_SetInteger( 5805 FXJSE_Value_SetInteger(
5939 args.GetReturnValue(), 5806 args.GetReturnValue(),
5940 firstOutput.Compare(secondOutput.AsStringC()) != -1); 5807 firstOutput.Compare(secondOutput.AsStringC()) != -1);
5941 } else { 5808 } else {
5942 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5809 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5943 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5810 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5944 FXJSE_Value_SetInteger(args.GetReturnValue(), (first >= second) ? 1 : 0); 5811 FXJSE_Value_SetInteger(args.GetReturnValue(), (first >= second) ? 1 : 0);
5945 } 5812 }
5946 } else { 5813 } else {
5947 CXFA_FM2JSContext* pContext = 5814 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
5948 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5815 XFA_IDS_COMPILER_ERROR);
5949 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR);
5950 } 5816 }
5951 } 5817 }
5952 5818
5953 // static 5819 // static
5954 void CXFA_FM2JSContext::plus_operator(CFXJSE_Value* pThis, 5820 void CXFA_FM2JSContext::plus_operator(CFXJSE_Value* pThis,
5955 const CFX_ByteStringC& szFuncName, 5821 const CFX_ByteStringC& szFuncName,
5956 CFXJSE_Arguments& args) { 5822 CFXJSE_Arguments& args) {
5957 if (args.GetLength() == 2) { 5823 if (args.GetLength() == 2) {
5958 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0); 5824 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0);
5959 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1); 5825 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1);
5960 if (ValueIsNull(pThis, argFirst.get()) && 5826 if (ValueIsNull(pThis, argFirst.get()) &&
5961 ValueIsNull(pThis, argSecond.get())) { 5827 ValueIsNull(pThis, argSecond.get())) {
5962 FXJSE_Value_SetNull(args.GetReturnValue()); 5828 FXJSE_Value_SetNull(args.GetReturnValue());
5963 } else { 5829 } else {
5964 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5830 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5965 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5831 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5966 FXJSE_Value_SetDouble(args.GetReturnValue(), first + second); 5832 FXJSE_Value_SetDouble(args.GetReturnValue(), first + second);
5967 } 5833 }
5968 } else { 5834 } else {
5969 CXFA_FM2JSContext* pContext = 5835 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
5970 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5836 XFA_IDS_COMPILER_ERROR);
5971 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR);
5972 } 5837 }
5973 } 5838 }
5974 5839
5975 // static 5840 // static
5976 void CXFA_FM2JSContext::minus_operator(CFXJSE_Value* pThis, 5841 void CXFA_FM2JSContext::minus_operator(CFXJSE_Value* pThis,
5977 const CFX_ByteStringC& szFuncName, 5842 const CFX_ByteStringC& szFuncName,
5978 CFXJSE_Arguments& args) { 5843 CFXJSE_Arguments& args) {
5979 if (args.GetLength() == 2) { 5844 if (args.GetLength() == 2) {
5980 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5845 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
5981 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5846 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
5982 if (FXJSE_Value_IsNull(argFirst.get()) && 5847 if (FXJSE_Value_IsNull(argFirst.get()) &&
5983 FXJSE_Value_IsNull(argSecond.get())) { 5848 FXJSE_Value_IsNull(argSecond.get())) {
5984 FXJSE_Value_SetNull(args.GetReturnValue()); 5849 FXJSE_Value_SetNull(args.GetReturnValue());
5985 } else { 5850 } else {
5986 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5851 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5987 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5852 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5988 FXJSE_Value_SetDouble(args.GetReturnValue(), first - second); 5853 FXJSE_Value_SetDouble(args.GetReturnValue(), first - second);
5989 } 5854 }
5990 } else { 5855 } else {
5991 CXFA_FM2JSContext* pContext = 5856 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
5992 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5857 XFA_IDS_COMPILER_ERROR);
5993 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR);
5994 } 5858 }
5995 } 5859 }
5996 5860
5997 // static 5861 // static
5998 void CXFA_FM2JSContext::multiple_operator(CFXJSE_Value* pThis, 5862 void CXFA_FM2JSContext::multiple_operator(CFXJSE_Value* pThis,
5999 const CFX_ByteStringC& szFuncName, 5863 const CFX_ByteStringC& szFuncName,
6000 CFXJSE_Arguments& args) { 5864 CFXJSE_Arguments& args) {
6001 if (args.GetLength() == 2) { 5865 if (args.GetLength() == 2) {
6002 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5866 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
6003 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5867 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
6004 if (FXJSE_Value_IsNull(argFirst.get()) && 5868 if (FXJSE_Value_IsNull(argFirst.get()) &&
6005 FXJSE_Value_IsNull(argSecond.get())) { 5869 FXJSE_Value_IsNull(argSecond.get())) {
6006 FXJSE_Value_SetNull(args.GetReturnValue()); 5870 FXJSE_Value_SetNull(args.GetReturnValue());
6007 } else { 5871 } else {
6008 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5872 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
6009 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5873 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
6010 FXJSE_Value_SetDouble(args.GetReturnValue(), first * second); 5874 FXJSE_Value_SetDouble(args.GetReturnValue(), first * second);
6011 } 5875 }
6012 } else { 5876 } else {
6013 CXFA_FM2JSContext* pContext = 5877 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
6014 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5878 XFA_IDS_COMPILER_ERROR);
6015 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR);
6016 } 5879 }
6017 } 5880 }
6018 5881
6019 // static 5882 // static
6020 void CXFA_FM2JSContext::divide_operator(CFXJSE_Value* pThis, 5883 void CXFA_FM2JSContext::divide_operator(CFXJSE_Value* pThis,
6021 const CFX_ByteStringC& szFuncName, 5884 const CFX_ByteStringC& szFuncName,
6022 CFXJSE_Arguments& args) { 5885 CFXJSE_Arguments& args) {
6023 CXFA_FM2JSContext* pContext = 5886 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
6024 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
6025 if (args.GetLength() == 2) { 5887 if (args.GetLength() == 2) {
6026 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5888 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
6027 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5889 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
6028 if (FXJSE_Value_IsNull(argFirst.get()) && 5890 if (FXJSE_Value_IsNull(argFirst.get()) &&
6029 FXJSE_Value_IsNull(argSecond.get())) { 5891 FXJSE_Value_IsNull(argSecond.get())) {
6030 FXJSE_Value_SetNull(args.GetReturnValue()); 5892 FXJSE_Value_SetNull(args.GetReturnValue());
6031 } else { 5893 } else {
6032 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5894 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
6033 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5895 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
6034 if (second == 0.0) { 5896 if (second == 0.0) {
(...skipping 13 matching lines...) Expand all
6048 CFXJSE_Arguments& args) { 5910 CFXJSE_Arguments& args) {
6049 if (args.GetLength() == 1) { 5911 if (args.GetLength() == 1) {
6050 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 5912 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
6051 if (FXJSE_Value_IsNull(argOne.get())) { 5913 if (FXJSE_Value_IsNull(argOne.get())) {
6052 FXJSE_Value_SetNull(args.GetReturnValue()); 5914 FXJSE_Value_SetNull(args.GetReturnValue());
6053 } else { 5915 } else {
6054 FXJSE_Value_SetDouble(args.GetReturnValue(), 5916 FXJSE_Value_SetDouble(args.GetReturnValue(),
6055 0.0 + ValueToDouble(pThis, argOne.get())); 5917 0.0 + ValueToDouble(pThis, argOne.get()));
6056 } 5918 }
6057 } else { 5919 } else {
6058 CXFA_FM2JSContext* pContext = 5920 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
6059 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5921 XFA_IDS_COMPILER_ERROR);
6060 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR);
6061 } 5922 }
6062 } 5923 }
6063 5924
6064 // static 5925 // static
6065 void CXFA_FM2JSContext::negative_operator(CFXJSE_Value* pThis, 5926 void CXFA_FM2JSContext::negative_operator(CFXJSE_Value* pThis,
6066 const CFX_ByteStringC& szFuncName, 5927 const CFX_ByteStringC& szFuncName,
6067 CFXJSE_Arguments& args) { 5928 CFXJSE_Arguments& args) {
6068 if (args.GetLength() == 1) { 5929 if (args.GetLength() == 1) {
6069 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 5930 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
6070 if (FXJSE_Value_IsNull(argOne.get())) { 5931 if (FXJSE_Value_IsNull(argOne.get())) {
6071 FXJSE_Value_SetNull(args.GetReturnValue()); 5932 FXJSE_Value_SetNull(args.GetReturnValue());
6072 } else { 5933 } else {
6073 FXJSE_Value_SetDouble(args.GetReturnValue(), 5934 FXJSE_Value_SetDouble(args.GetReturnValue(),
6074 0.0 - ValueToDouble(pThis, argOne.get())); 5935 0.0 - ValueToDouble(pThis, argOne.get()));
6075 } 5936 }
6076 } else { 5937 } else {
6077 CXFA_FM2JSContext* pContext = 5938 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
6078 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5939 XFA_IDS_COMPILER_ERROR);
6079 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR);
6080 } 5940 }
6081 } 5941 }
6082 5942
6083 // static 5943 // static
6084 void CXFA_FM2JSContext::logical_not_operator(CFXJSE_Value* pThis, 5944 void CXFA_FM2JSContext::logical_not_operator(CFXJSE_Value* pThis,
6085 const CFX_ByteStringC& szFuncName, 5945 const CFX_ByteStringC& szFuncName,
6086 CFXJSE_Arguments& args) { 5946 CFXJSE_Arguments& args) {
6087 if (args.GetLength() == 1) { 5947 if (args.GetLength() == 1) {
6088 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 5948 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
6089 if (FXJSE_Value_IsNull(argOne.get())) { 5949 if (FXJSE_Value_IsNull(argOne.get())) {
6090 FXJSE_Value_SetNull(args.GetReturnValue()); 5950 FXJSE_Value_SetNull(args.GetReturnValue());
6091 } else { 5951 } else {
6092 FX_DOUBLE first = ValueToDouble(pThis, argOne.get()); 5952 FX_DOUBLE first = ValueToDouble(pThis, argOne.get());
6093 FXJSE_Value_SetInteger(args.GetReturnValue(), (first == 0.0) ? 1 : 0); 5953 FXJSE_Value_SetInteger(args.GetReturnValue(), (first == 0.0) ? 1 : 0);
6094 } 5954 }
6095 } else { 5955 } else {
6096 CXFA_FM2JSContext* pContext = 5956 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
6097 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 5957 XFA_IDS_COMPILER_ERROR);
6098 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR);
6099 } 5958 }
6100 } 5959 }
6101 5960
6102 // static 5961 // static
6103 void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis, 5962 void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis,
6104 const CFX_ByteStringC& szFuncName, 5963 const CFX_ByteStringC& szFuncName,
6105 CFXJSE_Arguments& args) { 5964 CFXJSE_Arguments& args) {
6106 CXFA_FM2JSContext* pContext = 5965 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
6107 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
6108 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 5966 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
6109 int32_t argc = args.GetLength(); 5967 int32_t argc = args.GetLength();
6110 if ((argc == 4) || (argc == 5)) { 5968 if ((argc == 4) || (argc == 5)) {
6111 FX_BOOL bIsStar = TRUE; 5969 FX_BOOL bIsStar = TRUE;
6112 std::unique_ptr<CFXJSE_Value> argAccessor = args.GetValue(0); 5970 std::unique_ptr<CFXJSE_Value> argAccessor = args.GetValue(0);
6113 CFX_ByteString bsAccessorName = args.GetUTF8String(1); 5971 CFX_ByteString bsAccessorName = args.GetUTF8String(1);
6114 CFX_ByteString szName = args.GetUTF8String(2); 5972 CFX_ByteString szName = args.GetUTF8String(2);
6115 int32_t iIndexFlags = args.GetInt32(3); 5973 int32_t iIndexFlags = args.GetInt32(3);
6116 int32_t iIndexValue = 0; 5974 int32_t iIndexValue = 0;
6117 if (argc == 5) { 5975 if (argc == 5) {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
6245 } 6103 }
6246 } else { 6104 } else {
6247 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 6105 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR);
6248 } 6106 }
6249 } 6107 }
6250 6108
6251 // static 6109 // static
6252 void CXFA_FM2JSContext::dotdot_accessor(CFXJSE_Value* pThis, 6110 void CXFA_FM2JSContext::dotdot_accessor(CFXJSE_Value* pThis,
6253 const CFX_ByteStringC& szFuncName, 6111 const CFX_ByteStringC& szFuncName,
6254 CFXJSE_Arguments& args) { 6112 CFXJSE_Arguments& args) {
6255 CXFA_FM2JSContext* pContext = 6113 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
6256 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
6257 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 6114 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
6258 int32_t argc = args.GetLength(); 6115 int32_t argc = args.GetLength();
6259 if ((argc == 4) || (argc == 5)) { 6116 if ((argc == 4) || (argc == 5)) {
6260 FX_BOOL bIsStar = TRUE; 6117 FX_BOOL bIsStar = TRUE;
6261 std::unique_ptr<CFXJSE_Value> argAccessor = args.GetValue(0); 6118 std::unique_ptr<CFXJSE_Value> argAccessor = args.GetValue(0);
6262 CFX_ByteString bsAccessorName = args.GetUTF8String(1); 6119 CFX_ByteString bsAccessorName = args.GetUTF8String(1);
6263 CFX_ByteString szName = args.GetUTF8String(2); 6120 CFX_ByteString szName = args.GetUTF8String(2);
6264 int32_t iIndexFlags = args.GetInt32(3); 6121 int32_t iIndexFlags = args.GetInt32(3);
6265 int32_t iIndexValue = 0; 6122 int32_t iIndexValue = 0;
6266 if (argc == 5) { 6123 if (argc == 5) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
6389 } 6246 }
6390 } else { 6247 } else {
6391 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 6248 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR);
6392 } 6249 }
6393 } 6250 }
6394 6251
6395 // static 6252 // static
6396 void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis, 6253 void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis,
6397 const CFX_ByteStringC& szFuncName, 6254 const CFX_ByteStringC& szFuncName,
6398 CFXJSE_Arguments& args) { 6255 CFXJSE_Arguments& args) {
6399 CXFA_FM2JSContext* pContext = 6256 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
6400 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
6401 if (args.GetLength() == 1) { 6257 if (args.GetLength() == 1) {
6402 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 6258 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
6403 CFX_ByteString argString; 6259 CFX_ByteString argString;
6404 ValueToUTF8String(argOne.get(), argString); 6260 ValueToUTF8String(argOne.get(), argString);
6405 if (argString.IsEmpty()) { 6261 if (argString.IsEmpty()) {
6406 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); 6262 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH);
6407 } else { 6263 } else {
6408 CFX_WideString scriptString = 6264 CFX_WideString scriptString =
6409 CFX_WideString::FromUTF8(argString.AsStringC()); 6265 CFX_WideString::FromUTF8(argString.AsStringC());
6410 CFX_WideTextBuf wsJavaScriptBuf; 6266 CFX_WideTextBuf wsJavaScriptBuf;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
6450 FXJSE_Value_SetBoolean(args.GetReturnValue(), bIsArray); 6306 FXJSE_Value_SetBoolean(args.GetReturnValue(), bIsArray);
6451 } else { 6307 } else {
6452 FXJSE_Value_SetBoolean(args.GetReturnValue(), FALSE); 6308 FXJSE_Value_SetBoolean(args.GetReturnValue(), FALSE);
6453 } 6309 }
6454 } 6310 }
6455 6311
6456 // static 6312 // static
6457 void CXFA_FM2JSContext::get_fm_value(CFXJSE_Value* pThis, 6313 void CXFA_FM2JSContext::get_fm_value(CFXJSE_Value* pThis,
6458 const CFX_ByteStringC& szFuncName, 6314 const CFX_ByteStringC& szFuncName,
6459 CFXJSE_Arguments& args) { 6315 CFXJSE_Arguments& args) {
6460 CXFA_FM2JSContext* pContext = 6316 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
6461 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
6462 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 6317 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
6463 if (args.GetLength() == 1) { 6318 if (args.GetLength() == 1) {
6464 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 6319 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
6465 if (FXJSE_Value_IsArray(argOne.get())) { 6320 if (FXJSE_Value_IsArray(argOne.get())) {
6466 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 6321 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
6467 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 6322 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
6468 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 1, propertyValue.get()); 6323 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 1, propertyValue.get());
6469 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, jsObjectValue.get()); 6324 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, jsObjectValue.get());
6470 if (FXJSE_Value_IsNull(propertyValue.get())) { 6325 if (FXJSE_Value_IsNull(propertyValue.get())) {
6471 GetObjectDefaultValue(jsObjectValue.get(), args.GetReturnValue()); 6326 GetObjectDefaultValue(jsObjectValue.get(), args.GetReturnValue());
(...skipping 14 matching lines...) Expand all
6486 } 6341 }
6487 6342
6488 // static 6343 // static
6489 void CXFA_FM2JSContext::get_fm_jsobj(CFXJSE_Value* pThis, 6344 void CXFA_FM2JSContext::get_fm_jsobj(CFXJSE_Value* pThis,
6490 const CFX_ByteStringC& szFuncName, 6345 const CFX_ByteStringC& szFuncName,
6491 CFXJSE_Arguments& args) { 6346 CFXJSE_Arguments& args) {
6492 if (args.GetLength() == 1) { 6347 if (args.GetLength() == 1) {
6493 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 6348 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
6494 if (FXJSE_Value_IsArray(argOne.get())) { 6349 if (FXJSE_Value_IsArray(argOne.get())) {
6495 #ifndef NDEBUG 6350 #ifndef NDEBUG
6496 CXFA_FM2JSContext* pContext = 6351 v8::Isolate* pIsolate = pThis->ToJSContext(nullptr)->GetScriptRuntime();
6497 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
6498 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
6499 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 6352 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
6500 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get()); 6353 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get());
6501 ASSERT(FXJSE_Value_ToInteger(lengthValue.get()) >= 3); 6354 ASSERT(FXJSE_Value_ToInteger(lengthValue.get()) >= 3);
6502 #endif 6355 #endif
6503 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, args.GetReturnValue()); 6356 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, args.GetReturnValue());
6504 } else { 6357 } else {
6505 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); 6358 FXJSE_Value_Set(args.GetReturnValue(), argOne.get());
6506 } 6359 }
6507 } else { 6360 } else {
6508 CXFA_FM2JSContext* pContext = 6361 pThis->ToJSContext(nullptr)->ThrowScriptErrorMessage(
6509 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); 6362 XFA_IDS_COMPILER_ERROR);
6510 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR);
6511 } 6363 }
6512 } 6364 }
6513 6365
6514 // static 6366 // static
6515 void CXFA_FM2JSContext::fm_var_filter(CFXJSE_Value* pThis, 6367 void CXFA_FM2JSContext::fm_var_filter(CFXJSE_Value* pThis,
6516 const CFX_ByteStringC& szFuncName, 6368 const CFX_ByteStringC& szFuncName,
6517 CFXJSE_Arguments& args) { 6369 CFXJSE_Arguments& args) {
6518 CXFA_FM2JSContext* pContext = 6370 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
6519 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
6520 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 6371 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
6521 if (args.GetLength() == 1) { 6372 if (args.GetLength() == 1) {
6522 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 6373 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
6523 if (FXJSE_Value_IsArray(argOne.get())) { 6374 if (FXJSE_Value_IsArray(argOne.get())) {
6524 #ifndef NDEBUG 6375 #ifndef NDEBUG
6525 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 6376 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
6526 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get()); 6377 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get());
6527 ASSERT(FXJSE_Value_ToInteger(lengthValue.get()) >= 3); 6378 ASSERT(FXJSE_Value_ToInteger(lengthValue.get()) >= 3);
6528 #endif 6379 #endif
6529 std::unique_ptr<CFXJSE_Value> flagsValue(new CFXJSE_Value(pIsolate)); 6380 std::unique_ptr<CFXJSE_Value> flagsValue(new CFXJSE_Value(pIsolate));
(...skipping 30 matching lines...) Expand all
6560 } 6411 }
6561 } else { 6412 } else {
6562 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); 6413 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR);
6563 } 6414 }
6564 } 6415 }
6565 6416
6566 // static 6417 // static
6567 void CXFA_FM2JSContext::concat_fm_object(CFXJSE_Value* pThis, 6418 void CXFA_FM2JSContext::concat_fm_object(CFXJSE_Value* pThis,
6568 const CFX_ByteStringC& szFuncName, 6419 const CFX_ByteStringC& szFuncName,
6569 CFXJSE_Arguments& args) { 6420 CFXJSE_Arguments& args) {
6570 CXFA_FM2JSContext* pContext = 6421 v8::Isolate* pIsolate = pThis->ToJSContext(nullptr)->GetScriptRuntime();
6571 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
6572 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
6573 uint32_t iLength = 0; 6422 uint32_t iLength = 0;
6574 int32_t argc = args.GetLength(); 6423 int32_t argc = args.GetLength();
6575 std::vector<std::unique_ptr<CFXJSE_Value>> argValues; 6424 std::vector<std::unique_ptr<CFXJSE_Value>> argValues;
6576 for (int32_t i = 0; i < argc; i++) { 6425 for (int32_t i = 0; i < argc; i++) {
6577 argValues.push_back(args.GetValue(i)); 6426 argValues.push_back(args.GetValue(i));
6578 if (FXJSE_Value_IsArray(argValues[i].get())) { 6427 if (FXJSE_Value_IsArray(argValues[i].get())) {
6579 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 6428 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
6580 FXJSE_Value_GetObjectProp(argValues[i].get(), "length", 6429 FXJSE_Value_GetObjectProp(argValues[i].get(), "length",
6581 lengthValue.get()); 6430 lengthValue.get());
6582 int32_t length = FXJSE_Value_ToInteger(lengthValue.get()); 6431 int32_t length = FXJSE_Value_ToInteger(lengthValue.get());
(...skipping 26 matching lines...) Expand all
6609 delete returnValues[i]; 6458 delete returnValues[i];
6610 6459
6611 FX_Free(returnValues); 6460 FX_Free(returnValues);
6612 } 6461 }
6613 6462
6614 // static 6463 // static
6615 std::unique_ptr<CFXJSE_Value> CXFA_FM2JSContext::GetSimpleValue( 6464 std::unique_ptr<CFXJSE_Value> CXFA_FM2JSContext::GetSimpleValue(
6616 CFXJSE_Value* pThis, 6465 CFXJSE_Value* pThis,
6617 CFXJSE_Arguments& args, 6466 CFXJSE_Arguments& args,
6618 uint32_t index) { 6467 uint32_t index) {
6619 CXFA_FM2JSContext* pContext = 6468 v8::Isolate* pIsolate = pThis->ToJSContext(nullptr)->GetScriptRuntime();
6620 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
6621 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
6622 ASSERT(index < (uint32_t)args.GetLength()); 6469 ASSERT(index < (uint32_t)args.GetLength());
6623 std::unique_ptr<CFXJSE_Value> argIndex = args.GetValue(index); 6470 std::unique_ptr<CFXJSE_Value> argIndex = args.GetValue(index);
6624 if (FXJSE_Value_IsArray(argIndex.get())) { 6471 if (FXJSE_Value_IsArray(argIndex.get())) {
6625 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 6472 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
6626 FXJSE_Value_GetObjectProp(argIndex.get(), "length", lengthValue.get()); 6473 FXJSE_Value_GetObjectProp(argIndex.get(), "length", lengthValue.get());
6627 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); 6474 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get());
6628 std::unique_ptr<CFXJSE_Value> simpleValue(new CFXJSE_Value(pIsolate)); 6475 std::unique_ptr<CFXJSE_Value> simpleValue(new CFXJSE_Value(pIsolate));
6629 if (iLength > 2) { 6476 if (iLength > 2) {
6630 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 6477 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
6631 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 6478 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
(...skipping 15 matching lines...) Expand all
6647 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); 6494 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate));
6648 GetObjectDefaultValue(argIndex.get(), defaultValue.get()); 6495 GetObjectDefaultValue(argIndex.get(), defaultValue.get());
6649 return defaultValue; 6496 return defaultValue;
6650 } else { 6497 } else {
6651 return argIndex; 6498 return argIndex;
6652 } 6499 }
6653 } 6500 }
6654 6501
6655 // static 6502 // static
6656 FX_BOOL CXFA_FM2JSContext::ValueIsNull(CFXJSE_Value* pThis, CFXJSE_Value* arg) { 6503 FX_BOOL CXFA_FM2JSContext::ValueIsNull(CFXJSE_Value* pThis, CFXJSE_Value* arg) {
6657 CXFA_FM2JSContext* pContext = 6504 v8::Isolate* pIsolate = pThis->ToJSContext(nullptr)->GetScriptRuntime();
6658 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
6659 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
6660 FX_BOOL isNull = FALSE; 6505 FX_BOOL isNull = FALSE;
6661 if (FXJSE_Value_IsNull(arg)) { 6506 if (FXJSE_Value_IsNull(arg)) {
6662 isNull = TRUE; 6507 isNull = TRUE;
6663 } else if (FXJSE_Value_IsArray(arg)) { 6508 } else if (FXJSE_Value_IsArray(arg)) {
6664 int32_t iLength = hvalue_get_array_length(pThis, arg); 6509 int32_t iLength = hvalue_get_array_length(pThis, arg);
6665 if (iLength > 2) { 6510 if (iLength > 2) {
6666 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 6511 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
6667 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 6512 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
6668 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue.get()); 6513 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue.get());
6669 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsObjectValue.get()); 6514 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsObjectValue.get());
(...skipping 23 matching lines...) Expand all
6693 if (FXJSE_Value_IsNull(defaultValue.get())) { 6538 if (FXJSE_Value_IsNull(defaultValue.get())) {
6694 isNull = TRUE; 6539 isNull = TRUE;
6695 } 6540 }
6696 } 6541 }
6697 return isNull; 6542 return isNull;
6698 } 6543 }
6699 6544
6700 // static 6545 // static
6701 int32_t CXFA_FM2JSContext::hvalue_get_array_length(CFXJSE_Value* pThis, 6546 int32_t CXFA_FM2JSContext::hvalue_get_array_length(CFXJSE_Value* pThis,
6702 CFXJSE_Value* arg) { 6547 CFXJSE_Value* arg) {
6703 CXFA_FM2JSContext* pContext = 6548 v8::Isolate* pIsolate = pThis->ToJSContext(nullptr)->GetScriptRuntime();
6704 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
6705 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
6706 int32_t iLength = 0; 6549 int32_t iLength = 0;
6707 if (FXJSE_Value_IsArray(arg)) { 6550 if (FXJSE_Value_IsArray(arg)) {
6708 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 6551 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
6709 FXJSE_Value_GetObjectProp(arg, "length", lengthValue.get()); 6552 FXJSE_Value_GetObjectProp(arg, "length", lengthValue.get());
6710 iLength = FXJSE_Value_ToInteger(lengthValue.get()); 6553 iLength = FXJSE_Value_ToInteger(lengthValue.get());
6711 } 6554 }
6712 return iLength; 6555 return iLength;
6713 } 6556 }
6714 6557
6715 // static 6558 // static
(...skipping 19 matching lines...) Expand all
6735 } 6578 }
6736 return bReturn; 6579 return bReturn;
6737 } 6580 }
6738 6581
6739 // static 6582 // static
6740 void CXFA_FM2JSContext::unfoldArgs(CFXJSE_Value* pThis, 6583 void CXFA_FM2JSContext::unfoldArgs(CFXJSE_Value* pThis,
6741 CFXJSE_Arguments& args, 6584 CFXJSE_Arguments& args,
6742 CFXJSE_Value**& resultValues, 6585 CFXJSE_Value**& resultValues,
6743 int32_t& iCount, 6586 int32_t& iCount,
6744 int32_t iStart) { 6587 int32_t iStart) {
6745 CXFA_FM2JSContext* pContext = 6588 v8::Isolate* pIsolate = pThis->ToJSContext(nullptr)->GetScriptRuntime();
6746 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
6747 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
6748 iCount = 0; 6589 iCount = 0;
6749 int32_t argc = args.GetLength(); 6590 int32_t argc = args.GetLength();
6750 std::vector<std::unique_ptr<CFXJSE_Value>> argsValue; 6591 std::vector<std::unique_ptr<CFXJSE_Value>> argsValue;
6751 for (int32_t i = 0; i < argc - iStart; i++) { 6592 for (int32_t i = 0; i < argc - iStart; i++) {
6752 argsValue.push_back(args.GetValue(i + iStart)); 6593 argsValue.push_back(args.GetValue(i + iStart));
6753 if (FXJSE_Value_IsArray(argsValue[i].get())) { 6594 if (FXJSE_Value_IsArray(argsValue[i].get())) {
6754 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 6595 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
6755 FXJSE_Value_GetObjectProp(argsValue[i].get(), "length", 6596 FXJSE_Value_GetObjectProp(argsValue[i].get(), "length",
6756 lengthValue.get()); 6597 lengthValue.get());
6757 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); 6598 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
6802 } else { 6643 } else {
6803 FXJSE_Value_Set(resultValues[index], argsValue[i].get()); 6644 FXJSE_Value_Set(resultValues[index], argsValue[i].get());
6804 index++; 6645 index++;
6805 } 6646 }
6806 } 6647 }
6807 } 6648 }
6808 6649
6809 // static 6650 // static
6810 void CXFA_FM2JSContext::GetObjectDefaultValue(CFXJSE_Value* pObjectValue, 6651 void CXFA_FM2JSContext::GetObjectDefaultValue(CFXJSE_Value* pObjectValue,
6811 CFXJSE_Value* pDefaultValue) { 6652 CFXJSE_Value* pDefaultValue) {
6812 CXFA_Node* pNode = 6653 CXFA_Node* pNode = ToNode(pObjectValue->ToObject(nullptr));
6813 ToNode((CXFA_Object*)FXJSE_Value_ToObject(pObjectValue, nullptr));
6814 if (pNode) { 6654 if (pNode) {
6815 pNode->Script_Som_DefaultValue(pDefaultValue, FALSE, (XFA_ATTRIBUTE)-1); 6655 pNode->Script_Som_DefaultValue(pDefaultValue, FALSE, (XFA_ATTRIBUTE)-1);
6816 } else { 6656 } else {
6817 FXJSE_Value_SetNull(pDefaultValue); 6657 FXJSE_Value_SetNull(pDefaultValue);
6818 } 6658 }
6819 } 6659 }
6820 6660
6821 // static 6661 // static
6822 FX_BOOL CXFA_FM2JSContext::SetObjectDefaultValue(CFXJSE_Value* pObjectValue, 6662 FX_BOOL CXFA_FM2JSContext::SetObjectDefaultValue(CFXJSE_Value* pObjectValue,
6823 CFXJSE_Value* hNewValue) { 6663 CFXJSE_Value* hNewValue) {
6824 CXFA_Node* pNode = 6664 CXFA_Node* pNode = ToNode(pObjectValue->ToObject(nullptr));
6825 ToNode((CXFA_Object*)FXJSE_Value_ToObject(pObjectValue, nullptr));
6826 if (pNode) { 6665 if (pNode) {
6827 pNode->Script_Som_DefaultValue(hNewValue, TRUE, (XFA_ATTRIBUTE)-1); 6666 pNode->Script_Som_DefaultValue(hNewValue, TRUE, (XFA_ATTRIBUTE)-1);
6828 return TRUE; 6667 return TRUE;
6829 } 6668 }
6830 return FALSE; 6669 return FALSE;
6831 } 6670 }
6832 6671
6833 // static 6672 // static
6834 void CXFA_FM2JSContext::GenerateSomExpression(const CFX_ByteStringC& szName, 6673 void CXFA_FM2JSContext::GenerateSomExpression(const CFX_ByteStringC& szName,
6835 int32_t iIndexFlags, 6674 int32_t iIndexFlags,
(...skipping 24 matching lines...) Expand all
6860 szSomExp += "]"; 6699 szSomExp += "]";
6861 } 6700 }
6862 } 6701 }
6863 6702
6864 // static 6703 // static
6865 FX_BOOL CXFA_FM2JSContext::GetObjectByName( 6704 FX_BOOL CXFA_FM2JSContext::GetObjectByName(
6866 CFXJSE_Value* pThis, 6705 CFXJSE_Value* pThis,
6867 CFXJSE_Value* accessorValue, 6706 CFXJSE_Value* accessorValue,
6868 const CFX_ByteStringC& szAccessorName) { 6707 const CFX_ByteStringC& szAccessorName) {
6869 FX_BOOL bFlags = FALSE; 6708 FX_BOOL bFlags = FALSE;
6870 CXFA_FM2JSContext* pContext = 6709 CXFA_Document* pDoc = pThis->ToJSContext(nullptr)->GetDocument();
6871 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
6872 CXFA_Document* pDoc = pContext->GetDocument();
6873 if (!pDoc) { 6710 if (!pDoc) {
6874 return bFlags; 6711 return bFlags;
6875 } 6712 }
6876 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); 6713 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext();
6877 XFA_RESOLVENODE_RS resoveNodeRS; 6714 XFA_RESOLVENODE_RS resoveNodeRS;
6878 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | 6715 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
6879 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; 6716 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent;
6880 int32_t iRet = pScriptContext->ResolveObjects( 6717 int32_t iRet = pScriptContext->ResolveObjects(
6881 pScriptContext->GetThisObject(), 6718 pScriptContext->GetThisObject(),
6882 CFX_WideString::FromUTF8(szAccessorName).AsStringC(), resoveNodeRS, 6719 CFX_WideString::FromUTF8(szAccessorName).AsStringC(), resoveNodeRS,
6883 dwFlags); 6720 dwFlags);
6884 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { 6721 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) {
6885 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( 6722 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap(
6886 resoveNodeRS.nodes.GetAt(0))); 6723 resoveNodeRS.nodes.GetAt(0)));
6887 bFlags = TRUE; 6724 bFlags = TRUE;
6888 } 6725 }
6889 return bFlags; 6726 return bFlags;
6890 } 6727 }
6891 6728
6892 // static 6729 // static
6893 int32_t CXFA_FM2JSContext::ResolveObjects(CFXJSE_Value* pThis, 6730 int32_t CXFA_FM2JSContext::ResolveObjects(CFXJSE_Value* pThis,
6894 CFXJSE_Value* pRefValue, 6731 CFXJSE_Value* pRefValue,
6895 const CFX_ByteStringC& bsSomExp, 6732 const CFX_ByteStringC& bsSomExp,
6896 XFA_RESOLVENODE_RS& resoveNodeRS, 6733 XFA_RESOLVENODE_RS& resoveNodeRS,
6897 FX_BOOL bdotAccessor, 6734 FX_BOOL bdotAccessor,
6898 FX_BOOL bHasNoResolveName) { 6735 FX_BOOL bHasNoResolveName) {
6899 CFX_WideString wsSomExpression = CFX_WideString::FromUTF8(bsSomExp); 6736 CFX_WideString wsSomExpression = CFX_WideString::FromUTF8(bsSomExp);
6900 int32_t iRet = -1; 6737 int32_t iRet = -1;
6901 CXFA_FM2JSContext* pContext = 6738 CXFA_Document* pDoc = pThis->ToJSContext(nullptr)->GetDocument();
6902 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
6903 CXFA_Document* pDoc = pContext->GetDocument();
6904 if (!pDoc) { 6739 if (!pDoc) {
6905 return iRet; 6740 return iRet;
6906 } 6741 }
6907 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); 6742 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext();
6908 CXFA_Object* pNode = nullptr; 6743 CXFA_Object* pNode = nullptr;
6909 uint32_t dFlags = 0UL; 6744 uint32_t dFlags = 0UL;
6910 if (bdotAccessor) { 6745 if (bdotAccessor) {
6911 if (FXJSE_Value_IsNull(pRefValue)) { 6746 if (FXJSE_Value_IsNull(pRefValue)) {
6912 pNode = pScriptContext->GetThisObject(); 6747 pNode = pScriptContext->GetThisObject();
6913 dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; 6748 dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent;
6914 } else { 6749 } else {
6915 pNode = (CXFA_Object*)FXJSE_Value_ToObject(pRefValue, nullptr); 6750 pNode = pRefValue->ToObject(nullptr);
6916 ASSERT(pNode); 6751 ASSERT(pNode);
6917 if (bHasNoResolveName) { 6752 if (bHasNoResolveName) {
6918 CFX_WideString wsName; 6753 CFX_WideString wsName;
6919 if (CXFA_Node* pXFANode = pNode->AsNode()) { 6754 if (CXFA_Node* pXFANode = pNode->AsNode()) {
6920 pXFANode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE); 6755 pXFANode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, FALSE);
6921 } 6756 }
6922 if (wsName.IsEmpty()) { 6757 if (wsName.IsEmpty()) {
6923 CFX_WideStringC className; 6758 CFX_WideStringC className;
6924 pNode->GetClassName(className); 6759 pNode->GetClassName(className);
6925 wsName = FX_WSTRC(L"#") + className; 6760 wsName = FX_WSTRC(L"#") + className;
6926 } 6761 }
6927 wsSomExpression = wsName + wsSomExpression; 6762 wsSomExpression = wsName + wsSomExpression;
6928 dFlags = XFA_RESOLVENODE_Siblings; 6763 dFlags = XFA_RESOLVENODE_Siblings;
6929 } else { 6764 } else {
6930 dFlags = (bsSomExp == "*") 6765 dFlags = (bsSomExp == "*")
6931 ? (XFA_RESOLVENODE_Children) 6766 ? (XFA_RESOLVENODE_Children)
6932 : (XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | 6767 : (XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes |
6933 XFA_RESOLVENODE_Properties); 6768 XFA_RESOLVENODE_Properties);
6934 } 6769 }
6935 } 6770 }
6936 } else { 6771 } else {
6937 pNode = (CXFA_Object*)FXJSE_Value_ToObject(pRefValue, nullptr); 6772 pNode = pRefValue->ToObject(nullptr);
6938 dFlags = XFA_RESOLVENODE_AnyChild; 6773 dFlags = XFA_RESOLVENODE_AnyChild;
6939 } 6774 }
6940 iRet = pScriptContext->ResolveObjects(pNode, wsSomExpression.AsStringC(), 6775 iRet = pScriptContext->ResolveObjects(pNode, wsSomExpression.AsStringC(),
6941 resoveNodeRS, dFlags); 6776 resoveNodeRS, dFlags);
6942 return iRet; 6777 return iRet;
6943 } 6778 }
6944 6779
6945 // static 6780 // static
6946 void CXFA_FM2JSContext::ParseResolveResult( 6781 void CXFA_FM2JSContext::ParseResolveResult(
6947 CFXJSE_Value* pThis, 6782 CFXJSE_Value* pThis,
6948 const XFA_RESOLVENODE_RS& resoveNodeRS, 6783 const XFA_RESOLVENODE_RS& resoveNodeRS,
6949 CFXJSE_Value* pParentValue, 6784 CFXJSE_Value* pParentValue,
6950 CFXJSE_Value**& resultValues, 6785 CFXJSE_Value**& resultValues,
6951 int32_t& iSize, 6786 int32_t& iSize,
6952 FX_BOOL& bAttribute) { 6787 FX_BOOL& bAttribute) {
6953 CXFA_FM2JSContext* pContext = 6788 CXFA_FM2JSContext* pContext = pThis->ToJSContext(nullptr);
6954 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
6955 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 6789 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
6956 iSize = 0; 6790 iSize = 0;
6957 resultValues = nullptr; 6791 resultValues = nullptr;
6958 if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { 6792 if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) {
6959 bAttribute = FALSE; 6793 bAttribute = FALSE;
6960 iSize = resoveNodeRS.nodes.GetSize(); 6794 iSize = resoveNodeRS.nodes.GetSize();
6961 resultValues = FX_Alloc(CFXJSE_Value*, iSize); 6795 resultValues = FX_Alloc(CFXJSE_Value*, iSize);
6962 for (int32_t i = 0; i < iSize; i++) { 6796 for (int32_t i = 0; i < iSize; i++) {
6963 resultValues[i] = new CFXJSE_Value(pIsolate); 6797 resultValues[i] = new CFXJSE_Value(pIsolate);
6964 FXJSE_Value_Set( 6798 FXJSE_Value_Set(
(...skipping 19 matching lines...) Expand all
6984 resultValues[i] = new CFXJSE_Value(pIsolate); 6818 resultValues[i] = new CFXJSE_Value(pIsolate);
6985 FXJSE_Value_Set(resultValues[i], objectProperties[i]); 6819 FXJSE_Value_Set(resultValues[i], objectProperties[i]);
6986 } 6820 }
6987 } 6821 }
6988 } 6822 }
6989 } 6823 }
6990 6824
6991 // static 6825 // static
6992 int32_t CXFA_FM2JSContext::ValueToInteger(CFXJSE_Value* pThis, 6826 int32_t CXFA_FM2JSContext::ValueToInteger(CFXJSE_Value* pThis,
6993 CFXJSE_Value* pValue) { 6827 CFXJSE_Value* pValue) {
6994 CXFA_FM2JSContext* pContext = 6828 v8::Isolate* pIsolate = pThis->ToJSContext(nullptr)->GetScriptRuntime();
6995 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
6996 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
6997 int32_t iValue = 0; 6829 int32_t iValue = 0;
6998 if (FXJSE_Value_IsArray(pValue)) { 6830 if (FXJSE_Value_IsArray(pValue)) {
6999 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 6831 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
7000 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 6832 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
7001 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); 6833 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate));
7002 FXJSE_Value_GetObjectPropByIdx(pValue, 1, propertyValue.get()); 6834 FXJSE_Value_GetObjectPropByIdx(pValue, 1, propertyValue.get());
7003 FXJSE_Value_GetObjectPropByIdx(pValue, 2, jsObjectValue.get()); 6835 FXJSE_Value_GetObjectPropByIdx(pValue, 2, jsObjectValue.get());
7004 if (FXJSE_Value_IsNull(propertyValue.get())) { 6836 if (FXJSE_Value_IsNull(propertyValue.get())) {
7005 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); 6837 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get());
7006 } else { 6838 } else {
(...skipping 15 matching lines...) Expand all
7022 iValue = FXSYS_atoi(szValue.c_str()); 6854 iValue = FXSYS_atoi(szValue.c_str());
7023 } else { 6855 } else {
7024 iValue = FXJSE_Value_ToInteger(pValue); 6856 iValue = FXJSE_Value_ToInteger(pValue);
7025 } 6857 }
7026 return iValue; 6858 return iValue;
7027 } 6859 }
7028 6860
7029 // static 6861 // static
7030 FX_FLOAT CXFA_FM2JSContext::ValueToFloat(CFXJSE_Value* pThis, 6862 FX_FLOAT CXFA_FM2JSContext::ValueToFloat(CFXJSE_Value* pThis,
7031 CFXJSE_Value* arg) { 6863 CFXJSE_Value* arg) {
7032 CXFA_FM2JSContext* pContext = 6864 v8::Isolate* pIsolate = pThis->ToJSContext(nullptr)->GetScriptRuntime();
7033 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
7034 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
7035 FX_FLOAT fRet = 0.0f; 6865 FX_FLOAT fRet = 0.0f;
7036 if (FXJSE_Value_IsArray(arg)) { 6866 if (FXJSE_Value_IsArray(arg)) {
7037 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 6867 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
7038 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 6868 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
7039 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); 6869 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate));
7040 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue.get()); 6870 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue.get());
7041 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsObjectValue.get()); 6871 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsObjectValue.get());
7042 if (FXJSE_Value_IsNull(propertyValue.get())) { 6872 if (FXJSE_Value_IsNull(propertyValue.get())) {
7043 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); 6873 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get());
7044 } else { 6874 } else {
(...skipping 15 matching lines...) Expand all
7060 fRet = 0; 6890 fRet = 0;
7061 } else { 6891 } else {
7062 fRet = FXJSE_Value_ToFloat(arg); 6892 fRet = FXJSE_Value_ToFloat(arg);
7063 } 6893 }
7064 return fRet; 6894 return fRet;
7065 } 6895 }
7066 6896
7067 // static 6897 // static
7068 FX_DOUBLE CXFA_FM2JSContext::ValueToDouble(CFXJSE_Value* pThis, 6898 FX_DOUBLE CXFA_FM2JSContext::ValueToDouble(CFXJSE_Value* pThis,
7069 CFXJSE_Value* arg) { 6899 CFXJSE_Value* arg) {
7070 CXFA_FM2JSContext* pContext = 6900 v8::Isolate* pIsolate = pThis->ToJSContext(nullptr)->GetScriptRuntime();
7071 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr));
7072 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
7073 FX_DOUBLE dRet = 0; 6901 FX_DOUBLE dRet = 0;
7074 if (FXJSE_Value_IsArray(arg)) { 6902 if (FXJSE_Value_IsArray(arg)) {
7075 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 6903 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
7076 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 6904 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
7077 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); 6905 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate));
7078 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue.get()); 6906 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue.get());
7079 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsObjectValue.get()); 6907 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsObjectValue.get());
7080 if (FXJSE_Value_IsNull(propertyValue.get())) { 6908 if (FXJSE_Value_IsNull(propertyValue.get())) {
7081 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); 6909 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get());
7082 } else { 6910 } else {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
7163 CFX_WideString wsFormat; 6991 CFX_WideString wsFormat;
7164 pAppProvider->LoadString(iStringID, wsFormat); 6992 pAppProvider->LoadString(iStringID, wsFormat);
7165 CFX_WideString wsMessage; 6993 CFX_WideString wsMessage;
7166 va_list arg_ptr; 6994 va_list arg_ptr;
7167 va_start(arg_ptr, iStringID); 6995 va_start(arg_ptr, iStringID);
7168 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); 6996 wsMessage.FormatV(wsFormat.c_str(), arg_ptr);
7169 va_end(arg_ptr); 6997 va_end(arg_ptr);
7170 FXJSE_ThrowMessage( 6998 FXJSE_ThrowMessage(
7171 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); 6999 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC());
7172 } 7000 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698