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

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

Issue 2043153002: Remove various FXJSE Value methods. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/app/xfa_ffwidgetacc.cpp ('k') | xfa/fxfa/parser/xfa_object_imp.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" 7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h"
8 8
9 #include <time.h> 9 #include <time.h>
10 10
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 const CFX_ByteStringC& szFuncName, 510 const CFX_ByteStringC& szFuncName,
511 CFXJSE_Arguments& args) { 511 CFXJSE_Arguments& args) {
512 if (args.GetLength() != 1) { 512 if (args.GetLength() != 1) {
513 ToJSContext(pThis, nullptr) 513 ToJSContext(pThis, nullptr)
514 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Abs"); 514 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Abs");
515 return; 515 return;
516 } 516 }
517 517
518 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 518 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
519 if (ValueIsNull(pThis, argOne.get())) { 519 if (ValueIsNull(pThis, argOne.get())) {
520 FXJSE_Value_SetNull(args.GetReturnValue()); 520 args.GetReturnValue()->SetNull();
521 return; 521 return;
522 } 522 }
523 523
524 FX_DOUBLE dValue = ValueToDouble(pThis, argOne.get()); 524 FX_DOUBLE dValue = ValueToDouble(pThis, argOne.get());
525 if (dValue < 0) 525 if (dValue < 0)
526 dValue = -dValue; 526 dValue = -dValue;
527 527
528 FXJSE_Value_SetDouble(args.GetReturnValue(), dValue); 528 args.GetReturnValue()->SetDouble(dValue);
529 } 529 }
530 530
531 // static 531 // static
532 void CXFA_FM2JSContext::Avg(CFXJSE_Value* pThis, 532 void CXFA_FM2JSContext::Avg(CFXJSE_Value* pThis,
533 const CFX_ByteStringC& szFuncName, 533 const CFX_ByteStringC& szFuncName,
534 CFXJSE_Arguments& args) { 534 CFXJSE_Arguments& args) {
535 int32_t argc = args.GetLength(); 535 int32_t argc = args.GetLength();
536 if (argc < 1) { 536 if (argc < 1) {
537 FXJSE_Value_SetNull(args.GetReturnValue()); 537 args.GetReturnValue()->SetNull();
538 return; 538 return;
539 } 539 }
540 540
541 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); 541 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime();
542 uint32_t uCount = 0; 542 uint32_t uCount = 0;
543 FX_DOUBLE dSum = 0.0; 543 FX_DOUBLE dSum = 0.0;
544 for (int32_t i = 0; i < argc; i++) { 544 for (int32_t i = 0; i < argc; i++) {
545 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); 545 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i);
546 if (FXJSE_Value_IsNull(argValue.get())) 546 if (FXJSE_Value_IsNull(argValue.get()))
547 continue; 547 continue;
548 548
549 if (!FXJSE_Value_IsArray(argValue.get())) { 549 if (!FXJSE_Value_IsArray(argValue.get())) {
550 dSum += ValueToDouble(pThis, argValue.get()); 550 dSum += ValueToDouble(pThis, argValue.get());
551 uCount++; 551 uCount++;
552 continue; 552 continue;
553 } 553 }
554 554
555 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 555 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
556 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); 556 argValue->GetObjectProperty("length", lengthValue.get());
557 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); 557 int32_t iLength = lengthValue->ToInteger();
558 558
559 if (iLength > 2) { 559 if (iLength > 2) {
560 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 560 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
561 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); 561 argValue->GetObjectPropertyByIdx(1, propertyValue.get());
562 562
563 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 563 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
564 if (FXJSE_Value_IsNull(propertyValue.get())) { 564 if (FXJSE_Value_IsNull(propertyValue.get())) {
565 for (int32_t j = 2; j < iLength; j++) { 565 for (int32_t j = 2; j < iLength; j++) {
566 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, 566 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get());
567 jsObjectValue.get());
568 std::unique_ptr<CFXJSE_Value> defaultPropValue( 567 std::unique_ptr<CFXJSE_Value> defaultPropValue(
569 new CFXJSE_Value(pIsolate)); 568 new CFXJSE_Value(pIsolate));
570 GetObjectDefaultValue(jsObjectValue.get(), defaultPropValue.get()); 569 GetObjectDefaultValue(jsObjectValue.get(), defaultPropValue.get());
571 if (FXJSE_Value_IsNull(defaultPropValue.get())) 570 if (FXJSE_Value_IsNull(defaultPropValue.get()))
572 continue; 571 continue;
573 572
574 dSum += ValueToDouble(pThis, defaultPropValue.get()); 573 dSum += ValueToDouble(pThis, defaultPropValue.get());
575 uCount++; 574 uCount++;
576 } 575 }
577 } else { 576 } else {
578 CFX_ByteString propertyStr; 577 CFX_ByteString propertyStr;
579 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); 578 propertyValue->ToString(propertyStr);
580 for (int32_t j = 2; j < iLength; j++) { 579 for (int32_t j = 2; j < iLength; j++) {
581 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, 580 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get());
582 jsObjectValue.get());
583 std::unique_ptr<CFXJSE_Value> newPropertyValue( 581 std::unique_ptr<CFXJSE_Value> newPropertyValue(
584 new CFXJSE_Value(pIsolate)); 582 new CFXJSE_Value(pIsolate));
585 FXJSE_Value_GetObjectProp(jsObjectValue.get(), 583 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
586 propertyStr.AsStringC(), 584 newPropertyValue.get());
587 newPropertyValue.get());
588 if (FXJSE_Value_IsNull(newPropertyValue.get())) 585 if (FXJSE_Value_IsNull(newPropertyValue.get()))
589 continue; 586 continue;
590 587
591 dSum += ValueToDouble(pThis, newPropertyValue.get()); 588 dSum += ValueToDouble(pThis, newPropertyValue.get());
592 uCount++; 589 uCount++;
593 } 590 }
594 } 591 }
595 } 592 }
596 } 593 }
597 if (uCount == 0) { 594 if (uCount == 0) {
598 FXJSE_Value_SetNull(args.GetReturnValue()); 595 args.GetReturnValue()->SetNull();
599 return; 596 return;
600 } 597 }
601 598
602 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum / uCount); 599 args.GetReturnValue()->SetDouble(dSum / uCount);
603 } 600 }
604 601
605 // static 602 // static
606 void CXFA_FM2JSContext::Ceil(CFXJSE_Value* pThis, 603 void CXFA_FM2JSContext::Ceil(CFXJSE_Value* pThis,
607 const CFX_ByteStringC& szFuncName, 604 const CFX_ByteStringC& szFuncName,
608 CFXJSE_Arguments& args) { 605 CFXJSE_Arguments& args) {
609 if (args.GetLength() != 1) { 606 if (args.GetLength() != 1) {
610 ToJSContext(pThis, nullptr) 607 ToJSContext(pThis, nullptr)
611 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Ceil"); 608 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Ceil");
612 return; 609 return;
613 } 610 }
614 611
615 std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, args, 0); 612 std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, args, 0);
616 if (ValueIsNull(pThis, argValue.get())) { 613 if (ValueIsNull(pThis, argValue.get())) {
617 FXJSE_Value_SetNull(args.GetReturnValue()); 614 args.GetReturnValue()->SetNull();
618 return; 615 return;
619 } 616 }
620 617
621 FXJSE_Value_SetFloat(args.GetReturnValue(), 618 args.GetReturnValue()->SetFloat(
622 FXSYS_ceil(ValueToFloat(pThis, argValue.get()))); 619 FXSYS_ceil(ValueToFloat(pThis, argValue.get())));
623 } 620 }
624 621
625 // static 622 // static
626 void CXFA_FM2JSContext::Count(CFXJSE_Value* pThis, 623 void CXFA_FM2JSContext::Count(CFXJSE_Value* pThis,
627 const CFX_ByteStringC& szFuncName, 624 const CFX_ByteStringC& szFuncName,
628 CFXJSE_Arguments& args) { 625 CFXJSE_Arguments& args) {
629 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 626 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
630 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 627 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
631 int32_t iCount = 0; 628 int32_t iCount = 0;
632 for (int32_t i = 0; i < args.GetLength(); i++) { 629 for (int32_t i = 0; i < args.GetLength(); i++) {
633 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); 630 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i);
634 if (FXJSE_Value_IsNull(argValue.get())) 631 if (FXJSE_Value_IsNull(argValue.get()))
635 continue; 632 continue;
636 633
637 if (FXJSE_Value_IsArray(argValue.get())) { 634 if (FXJSE_Value_IsArray(argValue.get())) {
638 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 635 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
639 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); 636 argValue->GetObjectProperty("length", lengthValue.get());
640 637
641 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); 638 int32_t iLength = lengthValue->ToInteger();
642 if (iLength <= 2) { 639 if (iLength <= 2) {
643 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); 640 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
644 return; 641 return;
645 } 642 }
646 643
647 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 644 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
648 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 645 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
649 std::unique_ptr<CFXJSE_Value> newPropertyValue( 646 std::unique_ptr<CFXJSE_Value> newPropertyValue(
650 new CFXJSE_Value(pIsolate)); 647 new CFXJSE_Value(pIsolate));
651 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); 648 argValue->GetObjectPropertyByIdx(1, propertyValue.get());
652 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); 649 argValue->GetObjectPropertyByIdx(2, jsObjectValue.get());
653 if (FXJSE_Value_IsNull(propertyValue.get())) { 650 if (FXJSE_Value_IsNull(propertyValue.get())) {
654 for (int32_t j = 2; j < iLength; j++) { 651 for (int32_t j = 2; j < iLength; j++) {
655 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, 652 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get());
656 jsObjectValue.get());
657 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); 653 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get());
658 if (!FXJSE_Value_IsNull(newPropertyValue.get())) 654 if (!FXJSE_Value_IsNull(newPropertyValue.get()))
659 iCount++; 655 iCount++;
660 } 656 }
661 } else { 657 } else {
662 CFX_ByteString propertyStr; 658 CFX_ByteString propertyStr;
663 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); 659 propertyValue->ToString(propertyStr);
664 for (int32_t j = 2; j < iLength; j++) { 660 for (int32_t j = 2; j < iLength; j++) {
665 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, 661 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get());
666 jsObjectValue.get()); 662 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
667 FXJSE_Value_GetObjectProp(jsObjectValue.get(), 663 newPropertyValue.get());
668 propertyStr.AsStringC(),
669 newPropertyValue.get());
670 iCount += (FXJSE_Value_IsNull(newPropertyValue.get()) ? 0 : 1); 664 iCount += (FXJSE_Value_IsNull(newPropertyValue.get()) ? 0 : 1);
671 } 665 }
672 } 666 }
673 } else if (FXJSE_Value_IsObject(argValue.get())) { 667 } else if (FXJSE_Value_IsObject(argValue.get())) {
674 std::unique_ptr<CFXJSE_Value> newPropertyValue( 668 std::unique_ptr<CFXJSE_Value> newPropertyValue(
675 new CFXJSE_Value(pIsolate)); 669 new CFXJSE_Value(pIsolate));
676 GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); 670 GetObjectDefaultValue(argValue.get(), newPropertyValue.get());
677 if (!FXJSE_Value_IsNull(newPropertyValue.get())) 671 if (!FXJSE_Value_IsNull(newPropertyValue.get()))
678 iCount++; 672 iCount++;
679 } else { 673 } else {
680 iCount++; 674 iCount++;
681 } 675 }
682 } 676 }
683 FXJSE_Value_SetInteger(args.GetReturnValue(), iCount); 677 args.GetReturnValue()->SetInteger(iCount);
684 } 678 }
685 679
686 // static 680 // static
687 void CXFA_FM2JSContext::Floor(CFXJSE_Value* pThis, 681 void CXFA_FM2JSContext::Floor(CFXJSE_Value* pThis,
688 const CFX_ByteStringC& szFuncName, 682 const CFX_ByteStringC& szFuncName,
689 CFXJSE_Arguments& args) { 683 CFXJSE_Arguments& args) {
690 if (args.GetLength() != 1) { 684 if (args.GetLength() != 1) {
691 ToJSContext(pThis, nullptr) 685 ToJSContext(pThis, nullptr)
692 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Floor"); 686 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Floor");
693 return; 687 return;
694 } 688 }
695 689
696 std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, args, 0); 690 std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, args, 0);
697 if (ValueIsNull(pThis, argValue.get())) { 691 if (ValueIsNull(pThis, argValue.get())) {
698 FXJSE_Value_SetNull(args.GetReturnValue()); 692 args.GetReturnValue()->SetNull();
699 return; 693 return;
700 } 694 }
701 695
702 FXJSE_Value_SetFloat(args.GetReturnValue(), 696 args.GetReturnValue()->SetFloat(
703 FXSYS_floor(ValueToFloat(pThis, argValue.get()))); 697 FXSYS_floor(ValueToFloat(pThis, argValue.get())));
704 } 698 }
705 699
706 // static 700 // static
707 void CXFA_FM2JSContext::Max(CFXJSE_Value* pThis, 701 void CXFA_FM2JSContext::Max(CFXJSE_Value* pThis,
708 const CFX_ByteStringC& szFuncName, 702 const CFX_ByteStringC& szFuncName,
709 CFXJSE_Arguments& args) { 703 CFXJSE_Arguments& args) {
710 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 704 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
711 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 705 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
712 uint32_t uCount = 0; 706 uint32_t uCount = 0;
713 FX_DOUBLE dMaxValue = 0.0; 707 FX_DOUBLE dMaxValue = 0.0;
714 for (int32_t i = 0; i < args.GetLength(); i++) { 708 for (int32_t i = 0; i < args.GetLength(); i++) {
715 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); 709 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i);
716 if (FXJSE_Value_IsNull(argValue.get())) 710 if (FXJSE_Value_IsNull(argValue.get()))
717 continue; 711 continue;
718 712
719 if (FXJSE_Value_IsArray(argValue.get())) { 713 if (FXJSE_Value_IsArray(argValue.get())) {
720 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 714 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
721 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); 715 argValue->GetObjectProperty("length", lengthValue.get());
722 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); 716 int32_t iLength = lengthValue->ToInteger();
723 if (iLength <= 2) { 717 if (iLength <= 2) {
724 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); 718 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
725 return; 719 return;
726 } 720 }
727 721
728 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 722 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
729 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 723 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
730 std::unique_ptr<CFXJSE_Value> newPropertyValue( 724 std::unique_ptr<CFXJSE_Value> newPropertyValue(
731 new CFXJSE_Value(pIsolate)); 725 new CFXJSE_Value(pIsolate));
732 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); 726 argValue->GetObjectPropertyByIdx(1, propertyValue.get());
733 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); 727 argValue->GetObjectPropertyByIdx(2, jsObjectValue.get());
734 if (FXJSE_Value_IsNull(propertyValue.get())) { 728 if (FXJSE_Value_IsNull(propertyValue.get())) {
735 for (int32_t j = 2; j < iLength; j++) { 729 for (int32_t j = 2; j < iLength; j++) {
736 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, 730 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get());
737 jsObjectValue.get());
738 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); 731 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get());
739 if (FXJSE_Value_IsNull(newPropertyValue.get())) 732 if (FXJSE_Value_IsNull(newPropertyValue.get()))
740 continue; 733 continue;
741 734
742 uCount++; 735 uCount++;
743 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); 736 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get());
744 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); 737 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue);
745 } 738 }
746 } else { 739 } else {
747 CFX_ByteString propertyStr; 740 CFX_ByteString propertyStr;
748 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); 741 propertyValue->ToString(propertyStr);
749 for (int32_t j = 2; j < iLength; j++) { 742 for (int32_t j = 2; j < iLength; j++) {
750 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, 743 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get());
751 jsObjectValue.get()); 744 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
752 FXJSE_Value_GetObjectProp(jsObjectValue.get(), 745 newPropertyValue.get());
753 propertyStr.AsStringC(),
754 newPropertyValue.get());
755 if (FXJSE_Value_IsNull(newPropertyValue.get())) 746 if (FXJSE_Value_IsNull(newPropertyValue.get()))
756 continue; 747 continue;
757 748
758 uCount++; 749 uCount++;
759 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); 750 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get());
760 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); 751 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue);
761 } 752 }
762 } 753 }
763 } else if (FXJSE_Value_IsObject(argValue.get())) { 754 } else if (FXJSE_Value_IsObject(argValue.get())) {
764 std::unique_ptr<CFXJSE_Value> newPropertyValue( 755 std::unique_ptr<CFXJSE_Value> newPropertyValue(
765 new CFXJSE_Value(pIsolate)); 756 new CFXJSE_Value(pIsolate));
766 GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); 757 GetObjectDefaultValue(argValue.get(), newPropertyValue.get());
767 if (FXJSE_Value_IsNull(newPropertyValue.get())) 758 if (FXJSE_Value_IsNull(newPropertyValue.get()))
768 continue; 759 continue;
769 760
770 uCount++; 761 uCount++;
771 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); 762 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get());
772 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); 763 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue);
773 } else { 764 } else {
774 uCount++; 765 uCount++;
775 FX_DOUBLE dValue = ValueToDouble(pThis, argValue.get()); 766 FX_DOUBLE dValue = ValueToDouble(pThis, argValue.get());
776 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); 767 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue);
777 } 768 }
778 } 769 }
779 if (uCount == 0) { 770 if (uCount == 0) {
780 FXJSE_Value_SetNull(args.GetReturnValue()); 771 args.GetReturnValue()->SetNull();
781 return; 772 return;
782 } 773 }
783 774
784 FXJSE_Value_SetDouble(args.GetReturnValue(), dMaxValue); 775 args.GetReturnValue()->SetDouble(dMaxValue);
785 } 776 }
786 777
787 // static 778 // static
788 void CXFA_FM2JSContext::Min(CFXJSE_Value* pThis, 779 void CXFA_FM2JSContext::Min(CFXJSE_Value* pThis,
789 const CFX_ByteStringC& szFuncName, 780 const CFX_ByteStringC& szFuncName,
790 CFXJSE_Arguments& args) { 781 CFXJSE_Arguments& args) {
791 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 782 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
792 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 783 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
793 uint32_t uCount = 0; 784 uint32_t uCount = 0;
794 FX_DOUBLE dMinValue = 0.0; 785 FX_DOUBLE dMinValue = 0.0;
795 for (int32_t i = 0; i < args.GetLength(); i++) { 786 for (int32_t i = 0; i < args.GetLength(); i++) {
796 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); 787 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i);
797 if (FXJSE_Value_IsNull(argValue.get())) 788 if (FXJSE_Value_IsNull(argValue.get()))
798 continue; 789 continue;
799 790
800 if (FXJSE_Value_IsArray(argValue.get())) { 791 if (FXJSE_Value_IsArray(argValue.get())) {
801 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 792 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
802 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); 793 argValue->GetObjectProperty("length", lengthValue.get());
803 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); 794 int32_t iLength = lengthValue->ToInteger();
804 if (iLength <= 2) { 795 if (iLength <= 2) {
805 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); 796 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
806 return; 797 return;
807 } 798 }
808 799
809 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 800 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
810 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 801 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
811 std::unique_ptr<CFXJSE_Value> newPropertyValue( 802 std::unique_ptr<CFXJSE_Value> newPropertyValue(
812 new CFXJSE_Value(pIsolate)); 803 new CFXJSE_Value(pIsolate));
813 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); 804 argValue->GetObjectPropertyByIdx(1, propertyValue.get());
814 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); 805 argValue->GetObjectPropertyByIdx(2, jsObjectValue.get());
815 if (FXJSE_Value_IsNull(propertyValue.get())) { 806 if (FXJSE_Value_IsNull(propertyValue.get())) {
816 for (int32_t j = 2; j < iLength; j++) { 807 for (int32_t j = 2; j < iLength; j++) {
817 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, 808 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get());
818 jsObjectValue.get());
819 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); 809 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get());
820 if (FXJSE_Value_IsNull(newPropertyValue.get())) 810 if (FXJSE_Value_IsNull(newPropertyValue.get()))
821 continue; 811 continue;
822 812
823 uCount++; 813 uCount++;
824 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); 814 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get());
825 dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue); 815 dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue);
826 } 816 }
827 } else { 817 } else {
828 CFX_ByteString propertyStr; 818 CFX_ByteString propertyStr;
829 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); 819 propertyValue->ToString(propertyStr);
830 for (int32_t j = 2; j < iLength; j++) { 820 for (int32_t j = 2; j < iLength; j++) {
831 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, 821 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get());
832 jsObjectValue.get()); 822 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
833 FXJSE_Value_GetObjectProp(jsObjectValue.get(), 823 newPropertyValue.get());
834 propertyStr.AsStringC(),
835 newPropertyValue.get());
836 if (FXJSE_Value_IsNull(newPropertyValue.get())) 824 if (FXJSE_Value_IsNull(newPropertyValue.get()))
837 continue; 825 continue;
838 826
839 uCount++; 827 uCount++;
840 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); 828 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get());
841 dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue); 829 dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue);
842 } 830 }
843 } 831 }
844 } else if (FXJSE_Value_IsObject(argValue.get())) { 832 } else if (FXJSE_Value_IsObject(argValue.get())) {
845 std::unique_ptr<CFXJSE_Value> newPropertyValue( 833 std::unique_ptr<CFXJSE_Value> newPropertyValue(
846 new CFXJSE_Value(pIsolate)); 834 new CFXJSE_Value(pIsolate));
847 GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); 835 GetObjectDefaultValue(argValue.get(), newPropertyValue.get());
848 if (FXJSE_Value_IsNull(newPropertyValue.get())) 836 if (FXJSE_Value_IsNull(newPropertyValue.get()))
849 continue; 837 continue;
850 838
851 uCount++; 839 uCount++;
852 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); 840 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get());
853 dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue); 841 dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue);
854 } else { 842 } else {
855 uCount++; 843 uCount++;
856 FX_DOUBLE dValue = ValueToDouble(pThis, argValue.get()); 844 FX_DOUBLE dValue = ValueToDouble(pThis, argValue.get());
857 dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue); 845 dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue);
858 } 846 }
859 } 847 }
860 if (uCount == 0) { 848 if (uCount == 0) {
861 FXJSE_Value_SetNull(args.GetReturnValue()); 849 args.GetReturnValue()->SetNull();
862 return; 850 return;
863 } 851 }
864 852
865 FXJSE_Value_SetDouble(args.GetReturnValue(), dMinValue); 853 args.GetReturnValue()->SetDouble(dMinValue);
866 } 854 }
867 855
868 // static 856 // static
869 void CXFA_FM2JSContext::Mod(CFXJSE_Value* pThis, 857 void CXFA_FM2JSContext::Mod(CFXJSE_Value* pThis,
870 const CFX_ByteStringC& szFuncName, 858 const CFX_ByteStringC& szFuncName,
871 CFXJSE_Arguments& args) { 859 CFXJSE_Arguments& args) {
872 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 860 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
873 if (args.GetLength() != 2) { 861 if (args.GetLength() != 2) {
874 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Mod"); 862 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Mod");
875 return; 863 return;
876 } 864 }
877 865
878 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 866 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
879 std::unique_ptr<CFXJSE_Value> argTwo = args.GetValue(1); 867 std::unique_ptr<CFXJSE_Value> argTwo = args.GetValue(1);
880 if (FXJSE_Value_IsNull(argOne.get()) || FXJSE_Value_IsNull(argTwo.get())) { 868 if (FXJSE_Value_IsNull(argOne.get()) || FXJSE_Value_IsNull(argTwo.get())) {
881 FXJSE_Value_SetNull(args.GetReturnValue()); 869 args.GetReturnValue()->SetNull();
882 return; 870 return;
883 } 871 }
884 872
885 bool argOneResult; 873 bool argOneResult;
886 FX_DOUBLE dDividend = ExtractDouble(pThis, argOne.get(), &argOneResult); 874 FX_DOUBLE dDividend = ExtractDouble(pThis, argOne.get(), &argOneResult);
887 bool argTwoResult; 875 bool argTwoResult;
888 FX_DOUBLE dDivisor = ExtractDouble(pThis, argTwo.get(), &argTwoResult); 876 FX_DOUBLE dDivisor = ExtractDouble(pThis, argTwo.get(), &argTwoResult);
889 if (!argOneResult || !argTwoResult) { 877 if (!argOneResult || !argTwoResult) {
890 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); 878 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
891 return; 879 return;
892 } 880 }
893 881
894 if (dDivisor == 0.0) { 882 if (dDivisor == 0.0) {
895 pContext->ThrowException(XFA_IDS_DIVIDE_ZERO); 883 pContext->ThrowException(XFA_IDS_DIVIDE_ZERO);
896 return; 884 return;
897 } 885 }
898 886
899 FXJSE_Value_SetDouble(args.GetReturnValue(), 887 args.GetReturnValue()->SetDouble(dDividend -
900 dDividend - dDivisor * (int32_t)(dDividend / dDivisor)); 888 dDivisor * (int32_t)(dDividend / dDivisor));
901 } 889 }
902 890
903 // static 891 // static
904 void CXFA_FM2JSContext::Round(CFXJSE_Value* pThis, 892 void CXFA_FM2JSContext::Round(CFXJSE_Value* pThis,
905 const CFX_ByteStringC& szFuncName, 893 const CFX_ByteStringC& szFuncName,
906 CFXJSE_Arguments& args) { 894 CFXJSE_Arguments& args) {
907 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 895 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
908 int32_t argc = args.GetLength(); 896 int32_t argc = args.GetLength();
909 if (argc < 1 || argc > 2) { 897 if (argc < 1 || argc > 2) {
910 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Round"); 898 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Round");
911 return; 899 return;
912 } 900 }
913 901
914 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 902 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
915 if (FXJSE_Value_IsNull(argOne.get())) { 903 if (FXJSE_Value_IsNull(argOne.get())) {
916 FXJSE_Value_SetNull(args.GetReturnValue()); 904 args.GetReturnValue()->SetNull();
917 return; 905 return;
918 } 906 }
919 907
920 bool dValueRet; 908 bool dValueRet;
921 FX_DOUBLE dValue = ExtractDouble(pThis, argOne.get(), &dValueRet); 909 FX_DOUBLE dValue = ExtractDouble(pThis, argOne.get(), &dValueRet);
922 if (!dValueRet) { 910 if (!dValueRet) {
923 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); 911 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
924 return; 912 return;
925 } 913 }
926 914
927 uint8_t uPrecision = 0; 915 uint8_t uPrecision = 0;
928 if (argc > 1) { 916 if (argc > 1) {
929 std::unique_ptr<CFXJSE_Value> argTwo = args.GetValue(1); 917 std::unique_ptr<CFXJSE_Value> argTwo = args.GetValue(1);
930 if (FXJSE_Value_IsNull(argTwo.get())) { 918 if (FXJSE_Value_IsNull(argTwo.get())) {
931 FXJSE_Value_SetNull(args.GetReturnValue()); 919 args.GetReturnValue()->SetNull();
932 return; 920 return;
933 } 921 }
934 922
935 bool dPrecisionRet; 923 bool dPrecisionRet;
936 FX_DOUBLE dPrecision = ExtractDouble(pThis, argTwo.get(), &dPrecisionRet); 924 FX_DOUBLE dPrecision = ExtractDouble(pThis, argTwo.get(), &dPrecisionRet);
937 if (!dPrecisionRet) { 925 if (!dPrecisionRet) {
938 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); 926 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
939 return; 927 return;
940 } 928 }
941 929
942 uPrecision = 930 uPrecision =
943 static_cast<uint8_t>(std::min(std::max(dPrecision, 0.0), 12.0)); 931 static_cast<uint8_t>(std::min(std::max(dPrecision, 0.0), 12.0));
944 } 932 }
945 933
946 CFX_Decimal decimalValue((FX_FLOAT)dValue, uPrecision); 934 CFX_Decimal decimalValue((FX_FLOAT)dValue, uPrecision);
947 CFX_WideString wsValue = decimalValue; 935 CFX_WideString wsValue = decimalValue;
948 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 936 args.GetReturnValue()->SetString(wsValue.UTF8Encode().AsStringC());
949 wsValue.UTF8Encode().AsStringC());
950 } 937 }
951 938
952 // static 939 // static
953 void CXFA_FM2JSContext::Sum(CFXJSE_Value* pThis, 940 void CXFA_FM2JSContext::Sum(CFXJSE_Value* pThis,
954 const CFX_ByteStringC& szFuncName, 941 const CFX_ByteStringC& szFuncName,
955 CFXJSE_Arguments& args) { 942 CFXJSE_Arguments& args) {
956 int32_t argc = args.GetLength(); 943 int32_t argc = args.GetLength();
957 if (argc == 0) { 944 if (argc == 0) {
958 FXJSE_Value_SetNull(args.GetReturnValue()); 945 args.GetReturnValue()->SetNull();
959 return; 946 return;
960 } 947 }
961 948
962 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 949 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
963 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 950 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
964 uint32_t uCount = 0; 951 uint32_t uCount = 0;
965 FX_DOUBLE dSum = 0.0; 952 FX_DOUBLE dSum = 0.0;
966 for (int32_t i = 0; i < argc; i++) { 953 for (int32_t i = 0; i < argc; i++) {
967 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); 954 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i);
968 if (FXJSE_Value_IsNull(argValue.get())) 955 if (FXJSE_Value_IsNull(argValue.get()))
969 continue; 956 continue;
970 957
971 if (FXJSE_Value_IsArray(argValue.get())) { 958 if (FXJSE_Value_IsArray(argValue.get())) {
972 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 959 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
973 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); 960 argValue->GetObjectProperty("length", lengthValue.get());
974 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); 961 int32_t iLength = lengthValue->ToInteger();
975 if (iLength <= 2) { 962 if (iLength <= 2) {
976 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); 963 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
977 return; 964 return;
978 } 965 }
979 966
980 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 967 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
981 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); 968 argValue->GetObjectPropertyByIdx(1, propertyValue.get());
982 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 969 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
983 std::unique_ptr<CFXJSE_Value> newPropertyValue( 970 std::unique_ptr<CFXJSE_Value> newPropertyValue(
984 new CFXJSE_Value(pIsolate)); 971 new CFXJSE_Value(pIsolate));
985 if (FXJSE_Value_IsNull(propertyValue.get())) { 972 if (FXJSE_Value_IsNull(propertyValue.get())) {
986 for (int32_t j = 2; j < iLength; j++) { 973 for (int32_t j = 2; j < iLength; j++) {
987 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, 974 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get());
988 jsObjectValue.get());
989 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); 975 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get());
990 if (FXJSE_Value_IsNull(newPropertyValue.get())) 976 if (FXJSE_Value_IsNull(newPropertyValue.get()))
991 continue; 977 continue;
992 978
993 dSum += ValueToDouble(pThis, jsObjectValue.get()); 979 dSum += ValueToDouble(pThis, jsObjectValue.get());
994 uCount++; 980 uCount++;
995 } 981 }
996 } else { 982 } else {
997 CFX_ByteString propertyStr; 983 CFX_ByteString propertyStr;
998 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); 984 propertyValue->ToString(propertyStr);
999 for (int32_t j = 2; j < iLength; j++) { 985 for (int32_t j = 2; j < iLength; j++) {
1000 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, 986 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get());
1001 jsObjectValue.get()); 987 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
1002 FXJSE_Value_GetObjectProp(jsObjectValue.get(), 988 newPropertyValue.get());
1003 propertyStr.AsStringC(),
1004 newPropertyValue.get());
1005 if (FXJSE_Value_IsNull(newPropertyValue.get())) 989 if (FXJSE_Value_IsNull(newPropertyValue.get()))
1006 continue; 990 continue;
1007 991
1008 dSum += ValueToDouble(pThis, newPropertyValue.get()); 992 dSum += ValueToDouble(pThis, newPropertyValue.get());
1009 uCount++; 993 uCount++;
1010 } 994 }
1011 } 995 }
1012 } else if (FXJSE_Value_IsObject(argValue.get())) { 996 } else if (FXJSE_Value_IsObject(argValue.get())) {
1013 std::unique_ptr<CFXJSE_Value> newPropertyValue( 997 std::unique_ptr<CFXJSE_Value> newPropertyValue(
1014 new CFXJSE_Value(pIsolate)); 998 new CFXJSE_Value(pIsolate));
1015 GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); 999 GetObjectDefaultValue(argValue.get(), newPropertyValue.get());
1016 if (FXJSE_Value_IsNull(newPropertyValue.get())) 1000 if (FXJSE_Value_IsNull(newPropertyValue.get()))
1017 continue; 1001 continue;
1018 1002
1019 dSum += ValueToDouble(pThis, argValue.get()); 1003 dSum += ValueToDouble(pThis, argValue.get());
1020 uCount++; 1004 uCount++;
1021 } else { 1005 } else {
1022 dSum += ValueToDouble(pThis, argValue.get()); 1006 dSum += ValueToDouble(pThis, argValue.get());
1023 uCount++; 1007 uCount++;
1024 } 1008 }
1025 } 1009 }
1026 if (uCount == 0) { 1010 if (uCount == 0) {
1027 FXJSE_Value_SetNull(args.GetReturnValue()); 1011 args.GetReturnValue()->SetNull();
1028 return; 1012 return;
1029 } 1013 }
1030 1014
1031 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum); 1015 args.GetReturnValue()->SetDouble(dSum);
1032 } 1016 }
1033 1017
1034 // static 1018 // static
1035 void CXFA_FM2JSContext::Date(CFXJSE_Value* pThis, 1019 void CXFA_FM2JSContext::Date(CFXJSE_Value* pThis,
1036 const CFX_ByteStringC& szFuncName, 1020 const CFX_ByteStringC& szFuncName,
1037 CFXJSE_Arguments& args) { 1021 CFXJSE_Arguments& args) {
1038 if (args.GetLength() != 0) { 1022 if (args.GetLength() != 0) {
1039 ToJSContext(pThis, nullptr) 1023 ToJSContext(pThis, nullptr)
1040 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Date"); 1024 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Date");
1041 return; 1025 return;
1042 } 1026 }
1043 1027
1044 time_t currentTime; 1028 time_t currentTime;
1045 time(&currentTime); 1029 time(&currentTime);
1046 struct tm* pTmStruct = gmtime(&currentTime); 1030 struct tm* pTmStruct = gmtime(&currentTime);
1047 1031
1048 CFX_ByteString bufferYear; 1032 CFX_ByteString bufferYear;
1049 CFX_ByteString bufferMon; 1033 CFX_ByteString bufferMon;
1050 CFX_ByteString bufferDay; 1034 CFX_ByteString bufferDay;
1051 bufferYear.Format("%d", pTmStruct->tm_year + 1900); 1035 bufferYear.Format("%d", pTmStruct->tm_year + 1900);
1052 bufferMon.Format("%02d", pTmStruct->tm_mon + 1); 1036 bufferMon.Format("%02d", pTmStruct->tm_mon + 1);
1053 bufferDay.Format("%02d", pTmStruct->tm_mday); 1037 bufferDay.Format("%02d", pTmStruct->tm_mday);
1054 1038
1055 CFX_ByteString bufferCurrent = bufferYear + bufferMon + bufferDay; 1039 CFX_ByteString bufferCurrent = bufferYear + bufferMon + bufferDay;
1056 FXJSE_Value_SetInteger(args.GetReturnValue(), 1040 args.GetReturnValue()->SetInteger(DateString2Num(bufferCurrent.AsStringC()));
1057 DateString2Num(bufferCurrent.AsStringC()));
1058 } 1041 }
1059 1042
1060 // static 1043 // static
1061 void CXFA_FM2JSContext::Date2Num(CFXJSE_Value* pThis, 1044 void CXFA_FM2JSContext::Date2Num(CFXJSE_Value* pThis,
1062 const CFX_ByteStringC& szFuncName, 1045 const CFX_ByteStringC& szFuncName,
1063 CFXJSE_Arguments& args) { 1046 CFXJSE_Arguments& args) {
1064 int32_t argc = args.GetLength(); 1047 int32_t argc = args.GetLength();
1065 if (argc < 1 || argc > 3) { 1048 if (argc < 1 || argc > 3) {
1066 ToJSContext(pThis, nullptr) 1049 ToJSContext(pThis, nullptr)
1067 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Date2Num"); 1050 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Date2Num");
1068 return; 1051 return;
1069 } 1052 }
1070 1053
1071 std::unique_ptr<CFXJSE_Value> dateValue = GetSimpleValue(pThis, args, 0); 1054 std::unique_ptr<CFXJSE_Value> dateValue = GetSimpleValue(pThis, args, 0);
1072 if (ValueIsNull(pThis, dateValue.get())) { 1055 if (ValueIsNull(pThis, dateValue.get())) {
1073 FXJSE_Value_SetNull(args.GetReturnValue()); 1056 args.GetReturnValue()->SetNull();
1074 return; 1057 return;
1075 } 1058 }
1076 1059
1077 CFX_ByteString dateString; 1060 CFX_ByteString dateString;
1078 ValueToUTF8String(dateValue.get(), dateString); 1061 ValueToUTF8String(dateValue.get(), dateString);
1079 1062
1080 CFX_ByteString formatString; 1063 CFX_ByteString formatString;
1081 if (argc > 1) { 1064 if (argc > 1) {
1082 std::unique_ptr<CFXJSE_Value> formatValue = GetSimpleValue(pThis, args, 1); 1065 std::unique_ptr<CFXJSE_Value> formatValue = GetSimpleValue(pThis, args, 1);
1083 if (ValueIsNull(pThis, formatValue.get())) { 1066 if (ValueIsNull(pThis, formatValue.get())) {
1084 FXJSE_Value_SetNull(args.GetReturnValue()); 1067 args.GetReturnValue()->SetNull();
1085 return; 1068 return;
1086 } 1069 }
1087 ValueToUTF8String(formatValue.get(), formatString); 1070 ValueToUTF8String(formatValue.get(), formatString);
1088 } 1071 }
1089 1072
1090 CFX_ByteString localString; 1073 CFX_ByteString localString;
1091 if (argc > 2) { 1074 if (argc > 2) {
1092 std::unique_ptr<CFXJSE_Value> localValue = GetSimpleValue(pThis, args, 2); 1075 std::unique_ptr<CFXJSE_Value> localValue = GetSimpleValue(pThis, args, 2);
1093 if (ValueIsNull(pThis, localValue.get())) { 1076 if (ValueIsNull(pThis, localValue.get())) {
1094 FXJSE_Value_SetNull(args.GetReturnValue()); 1077 args.GetReturnValue()->SetNull();
1095 return; 1078 return;
1096 } 1079 }
1097 ValueToUTF8String(localValue.get(), localString); 1080 ValueToUTF8String(localValue.get(), localString);
1098 } 1081 }
1099 1082
1100 CFX_ByteString szIsoDateString; 1083 CFX_ByteString szIsoDateString;
1101 if (!Local2IsoDate(pThis, dateString.AsStringC(), formatString.AsStringC(), 1084 if (!Local2IsoDate(pThis, dateString.AsStringC(), formatString.AsStringC(),
1102 localString.AsStringC(), szIsoDateString)) { 1085 localString.AsStringC(), szIsoDateString)) {
1103 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); 1086 args.GetReturnValue()->SetInteger(0);
1104 return; 1087 return;
1105 } 1088 }
1106 1089
1107 FXJSE_Value_SetInteger(args.GetReturnValue(), 1090 args.GetReturnValue()->SetInteger(
1108 DateString2Num(szIsoDateString.AsStringC())); 1091 DateString2Num(szIsoDateString.AsStringC()));
1109 } 1092 }
1110 1093
1111 // static 1094 // static
1112 void CXFA_FM2JSContext::DateFmt(CFXJSE_Value* pThis, 1095 void CXFA_FM2JSContext::DateFmt(CFXJSE_Value* pThis,
1113 const CFX_ByteStringC& szFuncName, 1096 const CFX_ByteStringC& szFuncName,
1114 CFXJSE_Arguments& args) { 1097 CFXJSE_Arguments& args) {
1115 int32_t argc = args.GetLength(); 1098 int32_t argc = args.GetLength();
1116 if (argc > 2) { 1099 if (argc > 2) {
1117 ToJSContext(pThis, nullptr) 1100 ToJSContext(pThis, nullptr)
1118 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Date2Num"); 1101 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Date2Num");
1119 return; 1102 return;
1120 } 1103 }
1121 1104
1122 int32_t iStyle = 0; 1105 int32_t iStyle = 0;
1123 if (argc > 0) { 1106 if (argc > 0) {
1124 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0); 1107 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0);
1125 if (FXJSE_Value_IsNull(argStyle.get())) { 1108 if (FXJSE_Value_IsNull(argStyle.get())) {
1126 FXJSE_Value_SetNull(args.GetReturnValue()); 1109 args.GetReturnValue()->SetNull();
1127 return; 1110 return;
1128 } 1111 }
1129 1112
1130 iStyle = (int32_t)ValueToFloat(pThis, argStyle.get()); 1113 iStyle = (int32_t)ValueToFloat(pThis, argStyle.get());
1131 if (iStyle < 0 || iStyle > 4) 1114 if (iStyle < 0 || iStyle > 4)
1132 iStyle = 0; 1115 iStyle = 0;
1133 } 1116 }
1134 1117
1135 CFX_ByteString szLocal; 1118 CFX_ByteString szLocal;
1136 if (argc > 1) { 1119 if (argc > 1) {
1137 std::unique_ptr<CFXJSE_Value> argLocal = GetSimpleValue(pThis, args, 1); 1120 std::unique_ptr<CFXJSE_Value> argLocal = GetSimpleValue(pThis, args, 1);
1138 if (FXJSE_Value_IsNull(argLocal.get())) { 1121 if (FXJSE_Value_IsNull(argLocal.get())) {
1139 FXJSE_Value_SetNull(args.GetReturnValue()); 1122 args.GetReturnValue()->SetNull();
1140 return; 1123 return;
1141 } 1124 }
1142 ValueToUTF8String(argLocal.get(), szLocal); 1125 ValueToUTF8String(argLocal.get(), szLocal);
1143 } 1126 }
1144 1127
1145 CFX_ByteString formatStr; 1128 CFX_ByteString formatStr;
1146 GetStandardDateFormat(pThis, iStyle, szLocal.AsStringC(), formatStr); 1129 GetStandardDateFormat(pThis, iStyle, szLocal.AsStringC(), formatStr);
1147 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); 1130 args.GetReturnValue()->SetString(formatStr.AsStringC());
1148 } 1131 }
1149 1132
1150 // static 1133 // static
1151 void CXFA_FM2JSContext::IsoDate2Num(CFXJSE_Value* pThis, 1134 void CXFA_FM2JSContext::IsoDate2Num(CFXJSE_Value* pThis,
1152 const CFX_ByteStringC& szFuncName, 1135 const CFX_ByteStringC& szFuncName,
1153 CFXJSE_Arguments& args) { 1136 CFXJSE_Arguments& args) {
1154 if (args.GetLength() != 1) { 1137 if (args.GetLength() != 1) {
1155 ToJSContext(pThis, nullptr) 1138 ToJSContext(pThis, nullptr)
1156 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"IsoDate2Num"); 1139 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"IsoDate2Num");
1157 return; 1140 return;
1158 } 1141 }
1159 1142
1160 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 1143 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
1161 if (FXJSE_Value_IsNull(argOne.get())) { 1144 if (FXJSE_Value_IsNull(argOne.get())) {
1162 FXJSE_Value_SetNull(args.GetReturnValue()); 1145 args.GetReturnValue()->SetNull();
1163 return; 1146 return;
1164 } 1147 }
1165 1148
1166 CFX_ByteString szArgString; 1149 CFX_ByteString szArgString;
1167 ValueToUTF8String(argOne.get(), szArgString); 1150 ValueToUTF8String(argOne.get(), szArgString);
1168 FXJSE_Value_SetInteger(args.GetReturnValue(), 1151 args.GetReturnValue()->SetInteger(DateString2Num(szArgString.AsStringC()));
1169 DateString2Num(szArgString.AsStringC()));
1170 } 1152 }
1171 1153
1172 // static 1154 // static
1173 void CXFA_FM2JSContext::IsoTime2Num(CFXJSE_Value* pThis, 1155 void CXFA_FM2JSContext::IsoTime2Num(CFXJSE_Value* pThis,
1174 const CFX_ByteStringC& szFuncName, 1156 const CFX_ByteStringC& szFuncName,
1175 CFXJSE_Arguments& args) { 1157 CFXJSE_Arguments& args) {
1176 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 1158 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
1177 if (args.GetLength() != 1) { 1159 if (args.GetLength() != 1) {
1178 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, 1160 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD,
1179 L"IsoTime2Num"); 1161 L"IsoTime2Num");
1180 return; 1162 return;
1181 } 1163 }
1182 1164
1183 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 1165 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
1184 if (ValueIsNull(pThis, argOne.get())) { 1166 if (ValueIsNull(pThis, argOne.get())) {
1185 FXJSE_Value_SetNull(args.GetReturnValue()); 1167 args.GetReturnValue()->SetNull();
1186 return; 1168 return;
1187 } 1169 }
1188 1170
1189 CXFA_Document* pDoc = pContext->GetDocument(); 1171 CXFA_Document* pDoc = pContext->GetDocument();
1190 CXFA_LocaleMgr* pMgr = pDoc->GetLocalMgr(); 1172 CXFA_LocaleMgr* pMgr = pDoc->GetLocalMgr();
1191 1173
1192 CFX_ByteString szArgString; 1174 CFX_ByteString szArgString;
1193 ValueToUTF8String(argOne.get(), szArgString); 1175 ValueToUTF8String(argOne.get(), szArgString);
1194 szArgString = szArgString.Mid(szArgString.Find('T', 0) + 1); 1176 szArgString = szArgString.Mid(szArgString.Find('T', 0) + 1);
1195 if (szArgString.IsEmpty()) { 1177 if (szArgString.IsEmpty()) {
1196 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); 1178 args.GetReturnValue()->SetInteger(0);
1197 return; 1179 return;
1198 } 1180 }
1199 1181
1200 CXFA_LocaleValue timeValue( 1182 CXFA_LocaleValue timeValue(
1201 XFA_VT_TIME, CFX_WideString::FromUTF8(szArgString.AsStringC()), pMgr); 1183 XFA_VT_TIME, CFX_WideString::FromUTF8(szArgString.AsStringC()), pMgr);
1202 if (!timeValue.IsValid()) { 1184 if (!timeValue.IsValid()) {
1203 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); 1185 args.GetReturnValue()->SetInteger(0);
1204 return; 1186 return;
1205 } 1187 }
1206 1188
1207 CFX_Unitime uniTime = timeValue.GetTime(); 1189 CFX_Unitime uniTime = timeValue.GetTime();
1208 int32_t hour = uniTime.GetHour(); 1190 int32_t hour = uniTime.GetHour();
1209 int32_t min = uniTime.GetMinute(); 1191 int32_t min = uniTime.GetMinute();
1210 int32_t second = uniTime.GetSecond(); 1192 int32_t second = uniTime.GetSecond();
1211 int32_t milSecond = uniTime.GetMillisecond(); 1193 int32_t milSecond = uniTime.GetMillisecond();
1212 1194
1213 FX_TIMEZONE tzLocale; 1195 FX_TIMEZONE tzLocale;
1214 pMgr->GetDefLocale()->GetTimeZone(tzLocale); 1196 pMgr->GetDefLocale()->GetTimeZone(tzLocale);
1215 1197
1216 // TODO(dsinclair): See if there is other time conversion code in pdfium and 1198 // TODO(dsinclair): See if there is other time conversion code in pdfium and
1217 // consolidate. 1199 // consolidate.
1218 int32_t mins = hour * 60 + min; 1200 int32_t mins = hour * 60 + min;
1219 mins -= (tzLocale.tzHour * 60); 1201 mins -= (tzLocale.tzHour * 60);
1220 while (mins > 1440) 1202 while (mins > 1440)
1221 mins -= 1440; 1203 mins -= 1440;
1222 while (mins < 0) 1204 while (mins < 0)
1223 mins += 1440; 1205 mins += 1440;
1224 hour = mins / 60; 1206 hour = mins / 60;
1225 min = mins % 60; 1207 min = mins % 60;
1226 int32_t iResult = 1208
1227 hour * 3600000 + min * 60000 + second * 1000 + milSecond + 1; 1209 args.GetReturnValue()->SetInteger(hour * 3600000 + min * 60000 +
1228 FXJSE_Value_SetInteger(args.GetReturnValue(), iResult); 1210 second * 1000 + milSecond + 1);
1229 } 1211 }
1230 1212
1231 // static 1213 // static
1232 void CXFA_FM2JSContext::LocalDateFmt(CFXJSE_Value* pThis, 1214 void CXFA_FM2JSContext::LocalDateFmt(CFXJSE_Value* pThis,
1233 const CFX_ByteStringC& szFuncName, 1215 const CFX_ByteStringC& szFuncName,
1234 CFXJSE_Arguments& args) { 1216 CFXJSE_Arguments& args) {
1235 int32_t argc = args.GetLength(); 1217 int32_t argc = args.GetLength();
1236 if (argc > 2) { 1218 if (argc > 2) {
1237 ToJSContext(pThis, nullptr) 1219 ToJSContext(pThis, nullptr)
1238 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"LocalDateFmt"); 1220 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"LocalDateFmt");
1239 return; 1221 return;
1240 } 1222 }
1241 1223
1242 int32_t iStyle = 0; 1224 int32_t iStyle = 0;
1243 if (argc > 0) { 1225 if (argc > 0) {
1244 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0); 1226 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0);
1245 if (FXJSE_Value_IsNull(argStyle.get())) { 1227 if (FXJSE_Value_IsNull(argStyle.get())) {
1246 FXJSE_Value_SetNull(args.GetReturnValue()); 1228 args.GetReturnValue()->SetNull();
1247 return; 1229 return;
1248 } 1230 }
1249 iStyle = (int32_t)ValueToFloat(pThis, argStyle.get()); 1231 iStyle = (int32_t)ValueToFloat(pThis, argStyle.get());
1250 if (iStyle > 4 || iStyle < 0) 1232 if (iStyle > 4 || iStyle < 0)
1251 iStyle = 0; 1233 iStyle = 0;
1252 } 1234 }
1253 1235
1254 CFX_ByteString szLocal; 1236 CFX_ByteString szLocal;
1255 if (argc > 1) { 1237 if (argc > 1) {
1256 std::unique_ptr<CFXJSE_Value> argLocal = GetSimpleValue(pThis, args, 1); 1238 std::unique_ptr<CFXJSE_Value> argLocal = GetSimpleValue(pThis, args, 1);
1257 if (FXJSE_Value_IsNull(argLocal.get())) { 1239 if (FXJSE_Value_IsNull(argLocal.get())) {
1258 FXJSE_Value_SetNull(args.GetReturnValue()); 1240 args.GetReturnValue()->SetNull();
1259 return; 1241 return;
1260 } 1242 }
1261 ValueToUTF8String(argLocal.get(), szLocal); 1243 ValueToUTF8String(argLocal.get(), szLocal);
1262 } 1244 }
1263 1245
1264 CFX_ByteString formatStr; 1246 CFX_ByteString formatStr;
1265 GetLocalDateFormat(pThis, iStyle, szLocal.AsStringC(), formatStr, FALSE); 1247 GetLocalDateFormat(pThis, iStyle, szLocal.AsStringC(), formatStr, FALSE);
1266 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); 1248 args.GetReturnValue()->SetString(formatStr.AsStringC());
1267 } 1249 }
1268 1250
1269 // static 1251 // static
1270 void CXFA_FM2JSContext::LocalTimeFmt(CFXJSE_Value* pThis, 1252 void CXFA_FM2JSContext::LocalTimeFmt(CFXJSE_Value* pThis,
1271 const CFX_ByteStringC& szFuncName, 1253 const CFX_ByteStringC& szFuncName,
1272 CFXJSE_Arguments& args) { 1254 CFXJSE_Arguments& args) {
1273 int32_t argc = args.GetLength(); 1255 int32_t argc = args.GetLength();
1274 if (argc > 2) { 1256 if (argc > 2) {
1275 ToJSContext(pThis, nullptr) 1257 ToJSContext(pThis, nullptr)
1276 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"LocalTimeFmt"); 1258 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"LocalTimeFmt");
1277 return; 1259 return;
1278 } 1260 }
1279 1261
1280 int32_t iStyle = 0; 1262 int32_t iStyle = 0;
1281 if (argc > 0) { 1263 if (argc > 0) {
1282 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0); 1264 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0);
1283 if (FXJSE_Value_IsNull(argStyle.get())) { 1265 if (FXJSE_Value_IsNull(argStyle.get())) {
1284 FXJSE_Value_SetNull(args.GetReturnValue()); 1266 args.GetReturnValue()->SetNull();
1285 return; 1267 return;
1286 } 1268 }
1287 iStyle = (int32_t)ValueToFloat(pThis, argStyle.get()); 1269 iStyle = (int32_t)ValueToFloat(pThis, argStyle.get());
1288 if (iStyle > 4 || iStyle < 0) 1270 if (iStyle > 4 || iStyle < 0)
1289 iStyle = 0; 1271 iStyle = 0;
1290 } 1272 }
1291 1273
1292 CFX_ByteString szLocal; 1274 CFX_ByteString szLocal;
1293 if (argc > 1) { 1275 if (argc > 1) {
1294 std::unique_ptr<CFXJSE_Value> argLocal = GetSimpleValue(pThis, args, 1); 1276 std::unique_ptr<CFXJSE_Value> argLocal = GetSimpleValue(pThis, args, 1);
1295 if (FXJSE_Value_IsNull(argLocal.get())) { 1277 if (FXJSE_Value_IsNull(argLocal.get())) {
1296 FXJSE_Value_SetNull(args.GetReturnValue()); 1278 args.GetReturnValue()->SetNull();
1297 return; 1279 return;
1298 } 1280 }
1299 ValueToUTF8String(argLocal.get(), szLocal); 1281 ValueToUTF8String(argLocal.get(), szLocal);
1300 } 1282 }
1301 1283
1302 CFX_ByteString formatStr; 1284 CFX_ByteString formatStr;
1303 GetLocalTimeFormat(pThis, iStyle, szLocal.AsStringC(), formatStr, FALSE); 1285 GetLocalTimeFormat(pThis, iStyle, szLocal.AsStringC(), formatStr, FALSE);
1304 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); 1286 args.GetReturnValue()->SetString(formatStr.AsStringC());
1305 } 1287 }
1306 1288
1307 // static 1289 // static
1308 void CXFA_FM2JSContext::Num2Date(CFXJSE_Value* pThis, 1290 void CXFA_FM2JSContext::Num2Date(CFXJSE_Value* pThis,
1309 const CFX_ByteStringC& szFuncName, 1291 const CFX_ByteStringC& szFuncName,
1310 CFXJSE_Arguments& args) { 1292 CFXJSE_Arguments& args) {
1311 int32_t argc = args.GetLength(); 1293 int32_t argc = args.GetLength();
1312 if (argc < 1 || argc > 3) { 1294 if (argc < 1 || argc > 3) {
1313 ToJSContext(pThis, nullptr) 1295 ToJSContext(pThis, nullptr)
1314 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2Date"); 1296 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2Date");
1315 return; 1297 return;
1316 } 1298 }
1317 1299
1318 std::unique_ptr<CFXJSE_Value> dateValue = GetSimpleValue(pThis, args, 0); 1300 std::unique_ptr<CFXJSE_Value> dateValue = GetSimpleValue(pThis, args, 0);
1319 if (ValueIsNull(pThis, dateValue.get())) { 1301 if (ValueIsNull(pThis, dateValue.get())) {
1320 FXJSE_Value_SetNull(args.GetReturnValue()); 1302 args.GetReturnValue()->SetNull();
1321 return; 1303 return;
1322 } 1304 }
1323 int32_t dDate = (int32_t)ValueToFloat(pThis, dateValue.get()); 1305 int32_t dDate = (int32_t)ValueToFloat(pThis, dateValue.get());
1324 if (dDate < 1) { 1306 if (dDate < 1) {
1325 FXJSE_Value_SetNull(args.GetReturnValue()); 1307 args.GetReturnValue()->SetNull();
1326 return; 1308 return;
1327 } 1309 }
1328 1310
1329 CFX_ByteString formatString; 1311 CFX_ByteString formatString;
1330 if (argc > 1) { 1312 if (argc > 1) {
1331 std::unique_ptr<CFXJSE_Value> formatValue = GetSimpleValue(pThis, args, 1); 1313 std::unique_ptr<CFXJSE_Value> formatValue = GetSimpleValue(pThis, args, 1);
1332 if (ValueIsNull(pThis, formatValue.get())) { 1314 if (ValueIsNull(pThis, formatValue.get())) {
1333 FXJSE_Value_SetNull(args.GetReturnValue()); 1315 args.GetReturnValue()->SetNull();
1334 return; 1316 return;
1335 } 1317 }
1336 ValueToUTF8String(formatValue.get(), formatString); 1318 ValueToUTF8String(formatValue.get(), formatString);
1337 } 1319 }
1338 1320
1339 CFX_ByteString localString; 1321 CFX_ByteString localString;
1340 if (argc > 2) { 1322 if (argc > 2) {
1341 std::unique_ptr<CFXJSE_Value> localValue = GetSimpleValue(pThis, args, 2); 1323 std::unique_ptr<CFXJSE_Value> localValue = GetSimpleValue(pThis, args, 2);
1342 if (ValueIsNull(pThis, localValue.get())) { 1324 if (ValueIsNull(pThis, localValue.get())) {
1343 FXJSE_Value_SetNull(args.GetReturnValue()); 1325 args.GetReturnValue()->SetNull();
1344 return; 1326 return;
1345 } 1327 }
1346 ValueToUTF8String(localValue.get(), localString); 1328 ValueToUTF8String(localValue.get(), localString);
1347 } 1329 }
1348 1330
1349 int32_t iYear = 1900; 1331 int32_t iYear = 1900;
1350 int32_t iMonth = 1; 1332 int32_t iMonth = 1;
1351 int32_t iDay = 1; 1333 int32_t iDay = 1;
1352 int32_t i = 0; 1334 int32_t i = 0;
1353 while (dDate > 0) { 1335 while (dDate > 0) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 } 1418 }
1437 } 1419 }
1438 } 1420 }
1439 } 1421 }
1440 1422
1441 CFX_ByteString szIsoDateString; 1423 CFX_ByteString szIsoDateString;
1442 szIsoDateString.Format("%d%02d%02d", iYear + i, iMonth, iDay); 1424 szIsoDateString.Format("%d%02d%02d", iYear + i, iMonth, iDay);
1443 CFX_ByteString szLocalDateString; 1425 CFX_ByteString szLocalDateString;
1444 IsoDate2Local(pThis, szIsoDateString.AsStringC(), formatString.AsStringC(), 1426 IsoDate2Local(pThis, szIsoDateString.AsStringC(), formatString.AsStringC(),
1445 localString.AsStringC(), szLocalDateString); 1427 localString.AsStringC(), szLocalDateString);
1446 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 1428 args.GetReturnValue()->SetString(szLocalDateString.AsStringC());
1447 szLocalDateString.AsStringC());
1448 } 1429 }
1449 1430
1450 // static 1431 // static
1451 void CXFA_FM2JSContext::Num2GMTime(CFXJSE_Value* pThis, 1432 void CXFA_FM2JSContext::Num2GMTime(CFXJSE_Value* pThis,
1452 const CFX_ByteStringC& szFuncName, 1433 const CFX_ByteStringC& szFuncName,
1453 CFXJSE_Arguments& args) { 1434 CFXJSE_Arguments& args) {
1454 int32_t argc = args.GetLength(); 1435 int32_t argc = args.GetLength();
1455 if (argc < 1 || argc > 3) { 1436 if (argc < 1 || argc > 3) {
1456 ToJSContext(pThis, nullptr) 1437 ToJSContext(pThis, nullptr)
1457 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2GMTime"); 1438 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2GMTime");
1458 return; 1439 return;
1459 } 1440 }
1460 1441
1461 std::unique_ptr<CFXJSE_Value> timeValue = GetSimpleValue(pThis, args, 0); 1442 std::unique_ptr<CFXJSE_Value> timeValue = GetSimpleValue(pThis, args, 0);
1462 if (FXJSE_Value_IsNull(timeValue.get())) { 1443 if (FXJSE_Value_IsNull(timeValue.get())) {
1463 FXJSE_Value_SetNull(args.GetReturnValue()); 1444 args.GetReturnValue()->SetNull();
1464 return; 1445 return;
1465 } 1446 }
1466 int32_t iTime = (int32_t)ValueToFloat(pThis, timeValue.get()); 1447 int32_t iTime = (int32_t)ValueToFloat(pThis, timeValue.get());
1467 if (FXSYS_abs(iTime) < 1.0) { 1448 if (FXSYS_abs(iTime) < 1.0) {
1468 FXJSE_Value_SetNull(args.GetReturnValue()); 1449 args.GetReturnValue()->SetNull();
1469 return; 1450 return;
1470 } 1451 }
1471 1452
1472 CFX_ByteString formatString; 1453 CFX_ByteString formatString;
1473 if (argc > 1) { 1454 if (argc > 1) {
1474 std::unique_ptr<CFXJSE_Value> formatValue = GetSimpleValue(pThis, args, 1); 1455 std::unique_ptr<CFXJSE_Value> formatValue = GetSimpleValue(pThis, args, 1);
1475 if (FXJSE_Value_IsNull(formatValue.get())) { 1456 if (FXJSE_Value_IsNull(formatValue.get())) {
1476 FXJSE_Value_SetNull(args.GetReturnValue()); 1457 args.GetReturnValue()->SetNull();
1477 return; 1458 return;
1478 } 1459 }
1479 ValueToUTF8String(formatValue.get(), formatString); 1460 ValueToUTF8String(formatValue.get(), formatString);
1480 } 1461 }
1481 1462
1482 CFX_ByteString localString; 1463 CFX_ByteString localString;
1483 if (argc > 2) { 1464 if (argc > 2) {
1484 std::unique_ptr<CFXJSE_Value> localValue = GetSimpleValue(pThis, args, 2); 1465 std::unique_ptr<CFXJSE_Value> localValue = GetSimpleValue(pThis, args, 2);
1485 if (FXJSE_Value_IsNull(localValue.get())) { 1466 if (FXJSE_Value_IsNull(localValue.get())) {
1486 FXJSE_Value_SetNull(args.GetReturnValue()); 1467 args.GetReturnValue()->SetNull();
1487 return; 1468 return;
1488 } 1469 }
1489 ValueToUTF8String(localValue.get(), localString); 1470 ValueToUTF8String(localValue.get(), localString);
1490 } 1471 }
1491 1472
1492 CFX_ByteString szGMTTimeString; 1473 CFX_ByteString szGMTTimeString;
1493 Num2AllTime(pThis, iTime, formatString.AsStringC(), localString.AsStringC(), 1474 Num2AllTime(pThis, iTime, formatString.AsStringC(), localString.AsStringC(),
1494 TRUE, szGMTTimeString); 1475 TRUE, szGMTTimeString);
1495 FXJSE_Value_SetUTF8String(args.GetReturnValue(), szGMTTimeString.AsStringC()); 1476 args.GetReturnValue()->SetString(szGMTTimeString.AsStringC());
1496 } 1477 }
1497 1478
1498 // static 1479 // static
1499 void CXFA_FM2JSContext::Num2Time(CFXJSE_Value* pThis, 1480 void CXFA_FM2JSContext::Num2Time(CFXJSE_Value* pThis,
1500 const CFX_ByteStringC& szFuncName, 1481 const CFX_ByteStringC& szFuncName,
1501 CFXJSE_Arguments& args) { 1482 CFXJSE_Arguments& args) {
1502 int32_t argc = args.GetLength(); 1483 int32_t argc = args.GetLength();
1503 if (argc < 1 || argc > 3) { 1484 if (argc < 1 || argc > 3) {
1504 ToJSContext(pThis, nullptr) 1485 ToJSContext(pThis, nullptr)
1505 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2Time"); 1486 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Num2Time");
1506 return; 1487 return;
1507 } 1488 }
1508 1489
1509 std::unique_ptr<CFXJSE_Value> timeValue = GetSimpleValue(pThis, args, 0); 1490 std::unique_ptr<CFXJSE_Value> timeValue = GetSimpleValue(pThis, args, 0);
1510 if (FXJSE_Value_IsNull(timeValue.get())) { 1491 if (FXJSE_Value_IsNull(timeValue.get())) {
1511 FXJSE_Value_SetNull(args.GetReturnValue()); 1492 args.GetReturnValue()->SetNull();
1512 return; 1493 return;
1513 } 1494 }
1514 FX_FLOAT fTime = ValueToFloat(pThis, timeValue.get()); 1495 FX_FLOAT fTime = ValueToFloat(pThis, timeValue.get());
1515 if (FXSYS_fabs(fTime) < 1.0) { 1496 if (FXSYS_fabs(fTime) < 1.0) {
1516 FXJSE_Value_SetNull(args.GetReturnValue()); 1497 args.GetReturnValue()->SetNull();
1517 return; 1498 return;
1518 } 1499 }
1519 1500
1520 CFX_ByteString formatString; 1501 CFX_ByteString formatString;
1521 if (argc > 1) { 1502 if (argc > 1) {
1522 std::unique_ptr<CFXJSE_Value> formatValue = GetSimpleValue(pThis, args, 1); 1503 std::unique_ptr<CFXJSE_Value> formatValue = GetSimpleValue(pThis, args, 1);
1523 if (FXJSE_Value_IsNull(formatValue.get())) { 1504 if (FXJSE_Value_IsNull(formatValue.get())) {
1524 FXJSE_Value_SetNull(args.GetReturnValue()); 1505 args.GetReturnValue()->SetNull();
1525 return; 1506 return;
1526 } 1507 }
1527 ValueToUTF8String(formatValue.get(), formatString); 1508 ValueToUTF8String(formatValue.get(), formatString);
1528 } 1509 }
1529 1510
1530 CFX_ByteString localString; 1511 CFX_ByteString localString;
1531 if (argc > 2) { 1512 if (argc > 2) {
1532 std::unique_ptr<CFXJSE_Value> localValue = GetSimpleValue(pThis, args, 2); 1513 std::unique_ptr<CFXJSE_Value> localValue = GetSimpleValue(pThis, args, 2);
1533 if (FXJSE_Value_IsNull(localValue.get())) { 1514 if (FXJSE_Value_IsNull(localValue.get())) {
1534 FXJSE_Value_SetNull(args.GetReturnValue()); 1515 args.GetReturnValue()->SetNull();
1535 return; 1516 return;
1536 } 1517 }
1537 ValueToUTF8String(localValue.get(), localString); 1518 ValueToUTF8String(localValue.get(), localString);
1538 } 1519 }
1539 1520
1540 CFX_ByteString szLocalTimeString; 1521 CFX_ByteString szLocalTimeString;
1541 Num2AllTime(pThis, (int32_t)fTime, formatString.AsStringC(), 1522 Num2AllTime(pThis, (int32_t)fTime, formatString.AsStringC(),
1542 localString.AsStringC(), FALSE, szLocalTimeString); 1523 localString.AsStringC(), FALSE, szLocalTimeString);
1543 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 1524 args.GetReturnValue()->SetString(szLocalTimeString.AsStringC());
1544 szLocalTimeString.AsStringC());
1545 } 1525 }
1546 1526
1547 // static 1527 // static
1548 void CXFA_FM2JSContext::Time(CFXJSE_Value* pThis, 1528 void CXFA_FM2JSContext::Time(CFXJSE_Value* pThis,
1549 const CFX_ByteStringC& szFuncName, 1529 const CFX_ByteStringC& szFuncName,
1550 CFXJSE_Arguments& args) { 1530 CFXJSE_Arguments& args) {
1551 if (args.GetLength() != 0) { 1531 if (args.GetLength() != 0) {
1552 ToJSContext(pThis, nullptr) 1532 ToJSContext(pThis, nullptr)
1553 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Time"); 1533 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Time");
1554 return; 1534 return;
1555 } 1535 }
1556 1536
1557 time_t now; 1537 time_t now;
1558 time(&now); 1538 time(&now);
1559 1539
1560 struct tm* pGmt = gmtime(&now); 1540 struct tm* pGmt = gmtime(&now);
1561 FXJSE_Value_SetInteger( 1541 args.GetReturnValue()->SetInteger(
1562 args.GetReturnValue(), 1542 (pGmt->tm_hour * 3600 + pGmt->tm_min * 60 + pGmt->tm_sec) * 1000);
1563 ((pGmt->tm_hour * 3600 + pGmt->tm_min * 60 + pGmt->tm_sec) * 1000));
1564 } 1543 }
1565 1544
1566 // static 1545 // static
1567 void CXFA_FM2JSContext::Time2Num(CFXJSE_Value* pThis, 1546 void CXFA_FM2JSContext::Time2Num(CFXJSE_Value* pThis,
1568 const CFX_ByteStringC& szFuncName, 1547 const CFX_ByteStringC& szFuncName,
1569 CFXJSE_Arguments& args) { 1548 CFXJSE_Arguments& args) {
1570 int32_t argc = args.GetLength(); 1549 int32_t argc = args.GetLength();
1571 if (argc < 1 || argc > 3) { 1550 if (argc < 1 || argc > 3) {
1572 ToJSContext(pThis, nullptr) 1551 ToJSContext(pThis, nullptr)
1573 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Time2Num"); 1552 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Time2Num");
1574 return; 1553 return;
1575 } 1554 }
1576 1555
1577 CFX_ByteString timeString; 1556 CFX_ByteString timeString;
1578 std::unique_ptr<CFXJSE_Value> timeValue = GetSimpleValue(pThis, args, 0); 1557 std::unique_ptr<CFXJSE_Value> timeValue = GetSimpleValue(pThis, args, 0);
1579 if (ValueIsNull(pThis, timeValue.get())) { 1558 if (ValueIsNull(pThis, timeValue.get())) {
1580 FXJSE_Value_SetNull(args.GetReturnValue()); 1559 args.GetReturnValue()->SetNull();
1581 return; 1560 return;
1582 } 1561 }
1583 ValueToUTF8String(timeValue.get(), timeString); 1562 ValueToUTF8String(timeValue.get(), timeString);
1584 1563
1585 CFX_ByteString formatString; 1564 CFX_ByteString formatString;
1586 if (argc > 1) { 1565 if (argc > 1) {
1587 std::unique_ptr<CFXJSE_Value> formatValue = GetSimpleValue(pThis, args, 1); 1566 std::unique_ptr<CFXJSE_Value> formatValue = GetSimpleValue(pThis, args, 1);
1588 if (ValueIsNull(pThis, formatValue.get())) { 1567 if (ValueIsNull(pThis, formatValue.get())) {
1589 FXJSE_Value_SetNull(args.GetReturnValue()); 1568 args.GetReturnValue()->SetNull();
1590 return; 1569 return;
1591 } 1570 }
1592 ValueToUTF8String(formatValue.get(), formatString); 1571 ValueToUTF8String(formatValue.get(), formatString);
1593 } 1572 }
1594 1573
1595 CFX_ByteString localString; 1574 CFX_ByteString localString;
1596 if (argc > 2) { 1575 if (argc > 2) {
1597 std::unique_ptr<CFXJSE_Value> localValue = GetSimpleValue(pThis, args, 2); 1576 std::unique_ptr<CFXJSE_Value> localValue = GetSimpleValue(pThis, args, 2);
1598 if (ValueIsNull(pThis, localValue.get())) { 1577 if (ValueIsNull(pThis, localValue.get())) {
1599 FXJSE_Value_SetNull(args.GetReturnValue()); 1578 args.GetReturnValue()->SetNull();
1600 return; 1579 return;
1601 } 1580 }
1602 ValueToUTF8String(localValue.get(), localString); 1581 ValueToUTF8String(localValue.get(), localString);
1603 } 1582 }
1604 1583
1605 CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument(); 1584 CXFA_Document* pDoc = ToJSContext(pThis, nullptr)->GetDocument();
1606 CXFA_LocaleMgr* pMgr = pDoc->GetLocalMgr(); 1585 CXFA_LocaleMgr* pMgr = pDoc->GetLocalMgr();
1607 IFX_Locale* pLocale = nullptr; 1586 IFX_Locale* pLocale = nullptr;
1608 if (localString.IsEmpty()) { 1587 if (localString.IsEmpty()) {
1609 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); 1588 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
(...skipping 11 matching lines...) Expand all
1621 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); 1600 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat);
1622 else 1601 else
1623 wsFormat = CFX_WideString::FromUTF8(formatString.AsStringC()); 1602 wsFormat = CFX_WideString::FromUTF8(formatString.AsStringC());
1624 1603
1625 wsFormat = FX_WSTRC(L"time{") + wsFormat; 1604 wsFormat = FX_WSTRC(L"time{") + wsFormat;
1626 wsFormat += FX_WSTRC(L"}"); 1605 wsFormat += FX_WSTRC(L"}");
1627 CXFA_LocaleValue localeValue(XFA_VT_TIME, 1606 CXFA_LocaleValue localeValue(XFA_VT_TIME,
1628 CFX_WideString::FromUTF8(timeString.AsStringC()), 1607 CFX_WideString::FromUTF8(timeString.AsStringC()),
1629 wsFormat, pLocale, pMgr); 1608 wsFormat, pLocale, pMgr);
1630 if (!localeValue.IsValid()) { 1609 if (!localeValue.IsValid()) {
1631 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); 1610 args.GetReturnValue()->SetInteger(0);
1632 return; 1611 return;
1633 } 1612 }
1634 1613
1635 CFX_Unitime uniTime = localeValue.GetTime(); 1614 CFX_Unitime uniTime = localeValue.GetTime();
1636 int32_t hour = uniTime.GetHour(); 1615 int32_t hour = uniTime.GetHour();
1637 int32_t min = uniTime.GetMinute(); 1616 int32_t min = uniTime.GetMinute();
1638 int32_t second = uniTime.GetSecond(); 1617 int32_t second = uniTime.GetSecond();
1639 int32_t milSecond = uniTime.GetMillisecond(); 1618 int32_t milSecond = uniTime.GetMillisecond();
1640 int32_t mins = hour * 60 + min; 1619 int32_t mins = hour * 60 + min;
1641 CXFA_TimeZoneProvider* pProvider = CXFA_TimeZoneProvider::Get(); 1620 CXFA_TimeZoneProvider* pProvider = CXFA_TimeZoneProvider::Get();
1642 if (pProvider) { 1621 if (pProvider) {
1643 FX_TIMEZONE tz; 1622 FX_TIMEZONE tz;
1644 pProvider->GetTimeZone(tz); 1623 pProvider->GetTimeZone(tz);
1645 mins -= (tz.tzHour * 60); 1624 mins -= (tz.tzHour * 60);
1646 while (mins > 1440) 1625 while (mins > 1440)
1647 mins -= 1440; 1626 mins -= 1440;
1648 while (mins < 0) 1627 while (mins < 0)
1649 mins += 1440; 1628 mins += 1440;
1650 1629
1651 hour = mins / 60; 1630 hour = mins / 60;
1652 min = mins % 60; 1631 min = mins % 60;
1653 } 1632 }
1654 FXJSE_Value_SetInteger( 1633 args.GetReturnValue()->SetInteger(hour * 3600000 + min * 60000 +
1655 args.GetReturnValue(), 1634 second * 1000 + milSecond + 1);
1656 hour * 3600000 + min * 60000 + second * 1000 + milSecond + 1);
1657 } 1635 }
1658 1636
1659 // static 1637 // static
1660 void CXFA_FM2JSContext::TimeFmt(CFXJSE_Value* pThis, 1638 void CXFA_FM2JSContext::TimeFmt(CFXJSE_Value* pThis,
1661 const CFX_ByteStringC& szFuncName, 1639 const CFX_ByteStringC& szFuncName,
1662 CFXJSE_Arguments& args) { 1640 CFXJSE_Arguments& args) {
1663 int32_t argc = args.GetLength(); 1641 int32_t argc = args.GetLength();
1664 if (argc > 2) { 1642 if (argc > 2) {
1665 ToJSContext(pThis, nullptr) 1643 ToJSContext(pThis, nullptr)
1666 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"TimeFmt"); 1644 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"TimeFmt");
1667 return; 1645 return;
1668 } 1646 }
1669 1647
1670 int32_t iStyle = 0; 1648 int32_t iStyle = 0;
1671 if (argc > 0) { 1649 if (argc > 0) {
1672 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0); 1650 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0);
1673 if (FXJSE_Value_IsNull(argStyle.get())) { 1651 if (FXJSE_Value_IsNull(argStyle.get())) {
1674 FXJSE_Value_SetNull(args.GetReturnValue()); 1652 args.GetReturnValue()->SetNull();
1675 return; 1653 return;
1676 } 1654 }
1677 iStyle = (int32_t)ValueToFloat(pThis, argStyle.get()); 1655 iStyle = (int32_t)ValueToFloat(pThis, argStyle.get());
1678 if (iStyle > 4 || iStyle < 0) 1656 if (iStyle > 4 || iStyle < 0)
1679 iStyle = 0; 1657 iStyle = 0;
1680 } 1658 }
1681 1659
1682 CFX_ByteString szLocal; 1660 CFX_ByteString szLocal;
1683 if (argc > 1) { 1661 if (argc > 1) {
1684 std::unique_ptr<CFXJSE_Value> argLocal = GetSimpleValue(pThis, args, 1); 1662 std::unique_ptr<CFXJSE_Value> argLocal = GetSimpleValue(pThis, args, 1);
1685 if (FXJSE_Value_IsNull(argLocal.get())) { 1663 if (FXJSE_Value_IsNull(argLocal.get())) {
1686 FXJSE_Value_SetNull(args.GetReturnValue()); 1664 args.GetReturnValue()->SetNull();
1687 return; 1665 return;
1688 } 1666 }
1689 ValueToUTF8String(argLocal.get(), szLocal); 1667 ValueToUTF8String(argLocal.get(), szLocal);
1690 } 1668 }
1691 1669
1692 CFX_ByteString formatStr; 1670 CFX_ByteString formatStr;
1693 GetStandardTimeFormat(pThis, iStyle, szLocal.AsStringC(), formatStr); 1671 GetStandardTimeFormat(pThis, iStyle, szLocal.AsStringC(), formatStr);
1694 FXJSE_Value_SetUTF8String(args.GetReturnValue(), formatStr.AsStringC()); 1672 args.GetReturnValue()->SetString(formatStr.AsStringC());
1695 } 1673 }
1696 1674
1697 // static 1675 // static
1698 FX_BOOL CXFA_FM2JSContext::IsIsoDateFormat(const FX_CHAR* pData, 1676 FX_BOOL CXFA_FM2JSContext::IsIsoDateFormat(const FX_CHAR* pData,
1699 int32_t iLength, 1677 int32_t iLength,
1700 int32_t& iStyle, 1678 int32_t& iStyle,
1701 int32_t& iYear, 1679 int32_t& iYear,
1702 int32_t& iMonth, 1680 int32_t& iMonth,
1703 int32_t& iDay) { 1681 int32_t& iDay) {
1704 iYear = 0; 1682 iYear = 0;
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
2399 if (args.GetLength() != 3) { 2377 if (args.GetLength() != 3) {
2400 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Apr"); 2378 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Apr");
2401 return; 2379 return;
2402 } 2380 }
2403 2381
2404 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2382 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
2405 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 2383 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
2406 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 2384 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
2407 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || 2385 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) ||
2408 ValueIsNull(pThis, argThree.get())) { 2386 ValueIsNull(pThis, argThree.get())) {
2409 FXJSE_Value_SetNull(args.GetReturnValue()); 2387 args.GetReturnValue()->SetNull();
2410 return; 2388 return;
2411 } 2389 }
2412 2390
2413 FX_DOUBLE nPrincipal = ValueToDouble(pThis, argOne.get()); 2391 FX_DOUBLE nPrincipal = ValueToDouble(pThis, argOne.get());
2414 FX_DOUBLE nPayment = ValueToDouble(pThis, argTwo.get()); 2392 FX_DOUBLE nPayment = ValueToDouble(pThis, argTwo.get());
2415 FX_DOUBLE nPeriods = ValueToDouble(pThis, argThree.get()); 2393 FX_DOUBLE nPeriods = ValueToDouble(pThis, argThree.get());
2416 if (nPrincipal <= 0 || nPayment <= 0 || nPeriods <= 0) { 2394 if (nPrincipal <= 0 || nPayment <= 0 || nPeriods <= 0) {
2417 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); 2395 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
2418 return; 2396 return;
2419 } 2397 }
2420 2398
2421 FX_DOUBLE r = 2399 FX_DOUBLE r =
2422 2 * (nPeriods * nPayment - nPrincipal) / (nPeriods * nPrincipal); 2400 2 * (nPeriods * nPayment - nPrincipal) / (nPeriods * nPrincipal);
2423 FX_DOUBLE nTemp = 1; 2401 FX_DOUBLE nTemp = 1;
2424 for (int32_t i = 0; i < nPeriods; ++i) 2402 for (int32_t i = 0; i < nPeriods; ++i)
2425 nTemp *= (1 + r); 2403 nTemp *= (1 + r);
2426 2404
2427 FX_DOUBLE nRet = r * nTemp / (nTemp - 1) - nPayment / nPrincipal; 2405 FX_DOUBLE nRet = r * nTemp / (nTemp - 1) - nPayment / nPrincipal;
2428 while (fabs(nRet) > kFinancialPrecision) { 2406 while (fabs(nRet) > kFinancialPrecision) {
2429 FX_DOUBLE nDerivative = 2407 FX_DOUBLE nDerivative =
2430 ((nTemp + r * nPeriods * (nTemp / (1 + r))) * (nTemp - 1) - 2408 ((nTemp + r * nPeriods * (nTemp / (1 + r))) * (nTemp - 1) -
2431 (r * nTemp * nPeriods * (nTemp / (1 + r)))) / 2409 (r * nTemp * nPeriods * (nTemp / (1 + r)))) /
2432 ((nTemp - 1) * (nTemp - 1)); 2410 ((nTemp - 1) * (nTemp - 1));
2433 if (nDerivative == 0) { 2411 if (nDerivative == 0) {
2434 FXJSE_Value_SetNull(args.GetReturnValue()); 2412 args.GetReturnValue()->SetNull();
2435 return; 2413 return;
2436 } 2414 }
2437 2415
2438 r = r - nRet / nDerivative; 2416 r = r - nRet / nDerivative;
2439 nTemp = 1; 2417 nTemp = 1;
2440 for (int32_t i = 0; i < nPeriods; ++i) { 2418 for (int32_t i = 0; i < nPeriods; ++i) {
2441 nTemp *= (1 + r); 2419 nTemp *= (1 + r);
2442 } 2420 }
2443 nRet = r * nTemp / (nTemp - 1) - nPayment / nPrincipal; 2421 nRet = r * nTemp / (nTemp - 1) - nPayment / nPrincipal;
2444 } 2422 }
2445 FXJSE_Value_SetDouble(args.GetReturnValue(), r * 12); 2423 args.GetReturnValue()->SetDouble(r * 12);
2446 } 2424 }
2447 2425
2448 // static 2426 // static
2449 void CXFA_FM2JSContext::CTerm(CFXJSE_Value* pThis, 2427 void CXFA_FM2JSContext::CTerm(CFXJSE_Value* pThis,
2450 const CFX_ByteStringC& szFuncName, 2428 const CFX_ByteStringC& szFuncName,
2451 CFXJSE_Arguments& args) { 2429 CFXJSE_Arguments& args) {
2452 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 2430 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
2453 if (args.GetLength() != 3) { 2431 if (args.GetLength() != 3) {
2454 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"CTerm"); 2432 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"CTerm");
2455 return; 2433 return;
2456 } 2434 }
2457 2435
2458 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2436 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
2459 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 2437 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
2460 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 2438 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
2461 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || 2439 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) ||
2462 ValueIsNull(pThis, argThree.get())) { 2440 ValueIsNull(pThis, argThree.get())) {
2463 FXJSE_Value_SetNull(args.GetReturnValue()); 2441 args.GetReturnValue()->SetNull();
2464 return; 2442 return;
2465 } 2443 }
2466 2444
2467 FX_FLOAT nRate = ValueToFloat(pThis, argOne.get()); 2445 FX_FLOAT nRate = ValueToFloat(pThis, argOne.get());
2468 FX_FLOAT nFutureValue = ValueToFloat(pThis, argTwo.get()); 2446 FX_FLOAT nFutureValue = ValueToFloat(pThis, argTwo.get());
2469 FX_FLOAT nInitAmount = ValueToFloat(pThis, argThree.get()); 2447 FX_FLOAT nInitAmount = ValueToFloat(pThis, argThree.get());
2470 if ((nRate <= 0) || (nFutureValue <= 0) || (nInitAmount <= 0)) { 2448 if ((nRate <= 0) || (nFutureValue <= 0) || (nInitAmount <= 0)) {
2471 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); 2449 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
2472 return; 2450 return;
2473 } 2451 }
2474 2452
2475 FXJSE_Value_SetFloat(args.GetReturnValue(), 2453 args.GetReturnValue()->SetFloat(
2476 FXSYS_log((FX_FLOAT)(nFutureValue / nInitAmount)) / 2454 FXSYS_log((FX_FLOAT)(nFutureValue / nInitAmount)) /
2477 FXSYS_log((FX_FLOAT)(1 + nRate))); 2455 FXSYS_log((FX_FLOAT)(1 + nRate)));
2478 } 2456 }
2479 2457
2480 // static 2458 // static
2481 void CXFA_FM2JSContext::FV(CFXJSE_Value* pThis, 2459 void CXFA_FM2JSContext::FV(CFXJSE_Value* pThis,
2482 const CFX_ByteStringC& szFuncName, 2460 const CFX_ByteStringC& szFuncName,
2483 CFXJSE_Arguments& args) { 2461 CFXJSE_Arguments& args) {
2484 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 2462 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
2485 if (args.GetLength() != 3) { 2463 if (args.GetLength() != 3) {
2486 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"FV"); 2464 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"FV");
2487 return; 2465 return;
2488 } 2466 }
2489 2467
2490 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2468 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
2491 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 2469 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
2492 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 2470 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
2493 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || 2471 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) ||
2494 ValueIsNull(pThis, argThree.get())) { 2472 ValueIsNull(pThis, argThree.get())) {
2495 FXJSE_Value_SetNull(args.GetReturnValue()); 2473 args.GetReturnValue()->SetNull();
2496 return; 2474 return;
2497 } 2475 }
2498 2476
2499 FX_DOUBLE nAmount = ValueToDouble(pThis, argOne.get()); 2477 FX_DOUBLE nAmount = ValueToDouble(pThis, argOne.get());
2500 FX_DOUBLE nRate = ValueToDouble(pThis, argTwo.get()); 2478 FX_DOUBLE nRate = ValueToDouble(pThis, argTwo.get());
2501 FX_DOUBLE nPeriod = ValueToDouble(pThis, argThree.get()); 2479 FX_DOUBLE nPeriod = ValueToDouble(pThis, argThree.get());
2502 if ((nRate < 0) || (nPeriod <= 0) || (nAmount <= 0)) { 2480 if ((nRate < 0) || (nPeriod <= 0) || (nAmount <= 0)) {
2503 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); 2481 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
2504 return; 2482 return;
2505 } 2483 }
2506 2484
2507 FX_DOUBLE dResult = 0; 2485 FX_DOUBLE dResult = 0;
2508 if (nRate) { 2486 if (nRate) {
2509 FX_DOUBLE nTemp = 1; 2487 FX_DOUBLE nTemp = 1;
2510 for (int i = 0; i < nPeriod; ++i) { 2488 for (int i = 0; i < nPeriod; ++i) {
2511 nTemp *= 1 + nRate; 2489 nTemp *= 1 + nRate;
2512 } 2490 }
2513 dResult = nAmount * (nTemp - 1) / nRate; 2491 dResult = nAmount * (nTemp - 1) / nRate;
2514 } else { 2492 } else {
2515 dResult = nAmount * nPeriod; 2493 dResult = nAmount * nPeriod;
2516 } 2494 }
2517 2495
2518 FXJSE_Value_SetDouble(args.GetReturnValue(), dResult); 2496 args.GetReturnValue()->SetDouble(dResult);
2519 } 2497 }
2520 2498
2521 // static 2499 // static
2522 void CXFA_FM2JSContext::IPmt(CFXJSE_Value* pThis, 2500 void CXFA_FM2JSContext::IPmt(CFXJSE_Value* pThis,
2523 const CFX_ByteStringC& szFuncName, 2501 const CFX_ByteStringC& szFuncName,
2524 CFXJSE_Arguments& args) { 2502 CFXJSE_Arguments& args) {
2525 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 2503 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
2526 if (args.GetLength() != 5) { 2504 if (args.GetLength() != 5) {
2527 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"IPmt"); 2505 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"IPmt");
2528 return; 2506 return;
2529 } 2507 }
2530 2508
2531 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2509 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
2532 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 2510 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
2533 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 2511 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
2534 std::unique_ptr<CFXJSE_Value> argFour = GetSimpleValue(pThis, args, 3); 2512 std::unique_ptr<CFXJSE_Value> argFour = GetSimpleValue(pThis, args, 3);
2535 std::unique_ptr<CFXJSE_Value> argFive = GetSimpleValue(pThis, args, 4); 2513 std::unique_ptr<CFXJSE_Value> argFive = GetSimpleValue(pThis, args, 4);
2536 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || 2514 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) ||
2537 ValueIsNull(pThis, argThree.get()) || ValueIsNull(pThis, argFour.get()) || 2515 ValueIsNull(pThis, argThree.get()) || ValueIsNull(pThis, argFour.get()) ||
2538 ValueIsNull(pThis, argFive.get())) { 2516 ValueIsNull(pThis, argFive.get())) {
2539 FXJSE_Value_SetNull(args.GetReturnValue()); 2517 args.GetReturnValue()->SetNull();
2540 return; 2518 return;
2541 } 2519 }
2542 2520
2543 FX_FLOAT nPrincipalAmount = ValueToFloat(pThis, argOne.get()); 2521 FX_FLOAT nPrincipalAmount = ValueToFloat(pThis, argOne.get());
2544 FX_FLOAT nRate = ValueToFloat(pThis, argTwo.get()); 2522 FX_FLOAT nRate = ValueToFloat(pThis, argTwo.get());
2545 FX_FLOAT nPayment = ValueToFloat(pThis, argThree.get()); 2523 FX_FLOAT nPayment = ValueToFloat(pThis, argThree.get());
2546 FX_FLOAT nFirstMonth = ValueToFloat(pThis, argFour.get()); 2524 FX_FLOAT nFirstMonth = ValueToFloat(pThis, argFour.get());
2547 FX_FLOAT nNumberOfMonths = ValueToFloat(pThis, argFive.get()); 2525 FX_FLOAT nNumberOfMonths = ValueToFloat(pThis, argFive.get());
2548 if ((nPrincipalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) || 2526 if ((nPrincipalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) ||
2549 (nFirstMonth < 0) || (nNumberOfMonths < 0)) { 2527 (nFirstMonth < 0) || (nNumberOfMonths < 0)) {
2550 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); 2528 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
2551 return; 2529 return;
2552 } 2530 }
2553 2531
2554 FX_FLOAT nRateOfMonth = nRate / 12; 2532 FX_FLOAT nRateOfMonth = nRate / 12;
2555 int32_t iNums = (int32_t)( 2533 int32_t iNums = (int32_t)(
2556 (FXSYS_log10((FX_FLOAT)(nPayment / nPrincipalAmount)) - 2534 (FXSYS_log10((FX_FLOAT)(nPayment / nPrincipalAmount)) -
2557 FXSYS_log10((FX_FLOAT)(nPayment / nPrincipalAmount - nRateOfMonth))) / 2535 FXSYS_log10((FX_FLOAT)(nPayment / nPrincipalAmount - nRateOfMonth))) /
2558 FXSYS_log10((FX_FLOAT)(1 + nRateOfMonth))); 2536 FXSYS_log10((FX_FLOAT)(1 + nRateOfMonth)));
2559 int32_t iEnd = std::min((int32_t)(nFirstMonth + nNumberOfMonths - 1), iNums); 2537 int32_t iEnd = std::min((int32_t)(nFirstMonth + nNumberOfMonths - 1), iNums);
2560 2538
2561 if (nPayment < nPrincipalAmount * nRateOfMonth) { 2539 if (nPayment < nPrincipalAmount * nRateOfMonth) {
2562 FXJSE_Value_SetFloat(args.GetReturnValue(), 0); 2540 args.GetReturnValue()->SetFloat(0);
2563 return; 2541 return;
2564 } 2542 }
2565 2543
2566 int32_t i = 0; 2544 int32_t i = 0;
2567 for (i = 0; i < nFirstMonth - 1; ++i) 2545 for (i = 0; i < nFirstMonth - 1; ++i)
2568 nPrincipalAmount -= nPayment - nPrincipalAmount * nRateOfMonth; 2546 nPrincipalAmount -= nPayment - nPrincipalAmount * nRateOfMonth;
2569 2547
2570 FX_FLOAT nSum = 0; 2548 FX_FLOAT nSum = 0;
2571 for (; i < iEnd; ++i) { 2549 for (; i < iEnd; ++i) {
2572 nSum += nPrincipalAmount * nRateOfMonth; 2550 nSum += nPrincipalAmount * nRateOfMonth;
2573 nPrincipalAmount -= nPayment - nPrincipalAmount * nRateOfMonth; 2551 nPrincipalAmount -= nPayment - nPrincipalAmount * nRateOfMonth;
2574 } 2552 }
2575 FXJSE_Value_SetFloat(args.GetReturnValue(), nSum); 2553 args.GetReturnValue()->SetFloat(nSum);
2576 } 2554 }
2577 2555
2578 // static 2556 // static
2579 void CXFA_FM2JSContext::NPV(CFXJSE_Value* pThis, 2557 void CXFA_FM2JSContext::NPV(CFXJSE_Value* pThis,
2580 const CFX_ByteStringC& szFuncName, 2558 const CFX_ByteStringC& szFuncName,
2581 CFXJSE_Arguments& args) { 2559 CFXJSE_Arguments& args) {
2582 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 2560 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
2583 int32_t argc = args.GetLength(); 2561 int32_t argc = args.GetLength();
2584 if (argc < 3) { 2562 if (argc < 3) {
2585 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"NPV"); 2563 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"NPV");
2586 return; 2564 return;
2587 } 2565 }
2588 2566
2589 std::vector<std::unique_ptr<CFXJSE_Value>> argValues; 2567 std::vector<std::unique_ptr<CFXJSE_Value>> argValues;
2590 for (int32_t i = 0; i < argc; i++) { 2568 for (int32_t i = 0; i < argc; i++) {
2591 argValues.push_back(GetSimpleValue(pThis, args, i)); 2569 argValues.push_back(GetSimpleValue(pThis, args, i));
2592 if (ValueIsNull(pThis, argValues[i].get())) { 2570 if (ValueIsNull(pThis, argValues[i].get())) {
2593 FXJSE_Value_SetNull(args.GetReturnValue()); 2571 args.GetReturnValue()->SetNull();
2594 return; 2572 return;
2595 } 2573 }
2596 } 2574 }
2597 2575
2598 FX_DOUBLE nRate = ValueToDouble(pThis, argValues[0].get()); 2576 FX_DOUBLE nRate = ValueToDouble(pThis, argValues[0].get());
2599 if (nRate <= 0) { 2577 if (nRate <= 0) {
2600 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); 2578 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
2601 return; 2579 return;
2602 } 2580 }
2603 2581
2604 std::vector<FX_DOUBLE> data(argc - 1); 2582 std::vector<FX_DOUBLE> data(argc - 1);
2605 for (int32_t i = 1; i < argc; i++) 2583 for (int32_t i = 1; i < argc; i++)
2606 data.push_back(ValueToDouble(pThis, argValues[i].get())); 2584 data.push_back(ValueToDouble(pThis, argValues[i].get()));
2607 2585
2608 FX_DOUBLE nSum = 0; 2586 FX_DOUBLE nSum = 0;
2609 int32_t iIndex = 0; 2587 int32_t iIndex = 0;
2610 for (int32_t i = 0; i < argc - 1; i++) { 2588 for (int32_t i = 0; i < argc - 1; i++) {
2611 FX_DOUBLE nTemp = 1; 2589 FX_DOUBLE nTemp = 1;
2612 for (int32_t j = 0; j <= i; j++) 2590 for (int32_t j = 0; j <= i; j++)
2613 nTemp *= 1 + nRate; 2591 nTemp *= 1 + nRate;
2614 2592
2615 FX_DOUBLE nNum = data[iIndex++]; 2593 FX_DOUBLE nNum = data[iIndex++];
2616 nSum += nNum / nTemp; 2594 nSum += nNum / nTemp;
2617 } 2595 }
2618 FXJSE_Value_SetDouble(args.GetReturnValue(), nSum); 2596 args.GetReturnValue()->SetDouble(nSum);
2619 } 2597 }
2620 2598
2621 // static 2599 // static
2622 void CXFA_FM2JSContext::Pmt(CFXJSE_Value* pThis, 2600 void CXFA_FM2JSContext::Pmt(CFXJSE_Value* pThis,
2623 const CFX_ByteStringC& szFuncName, 2601 const CFX_ByteStringC& szFuncName,
2624 CFXJSE_Arguments& args) { 2602 CFXJSE_Arguments& args) {
2625 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 2603 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
2626 if (args.GetLength() != 3) { 2604 if (args.GetLength() != 3) {
2627 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Pmt"); 2605 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Pmt");
2628 return; 2606 return;
2629 } 2607 }
2630 2608
2631 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2609 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
2632 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 2610 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
2633 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 2611 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
2634 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || 2612 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) ||
2635 ValueIsNull(pThis, argThree.get())) { 2613 ValueIsNull(pThis, argThree.get())) {
2636 FXJSE_Value_SetNull(args.GetReturnValue()); 2614 args.GetReturnValue()->SetNull();
2637 return; 2615 return;
2638 } 2616 }
2639 2617
2640 FX_FLOAT nPrincipal = ValueToFloat(pThis, argOne.get()); 2618 FX_FLOAT nPrincipal = ValueToFloat(pThis, argOne.get());
2641 FX_FLOAT nRate = ValueToFloat(pThis, argTwo.get()); 2619 FX_FLOAT nRate = ValueToFloat(pThis, argTwo.get());
2642 FX_FLOAT nPeriods = ValueToFloat(pThis, argThree.get()); 2620 FX_FLOAT nPeriods = ValueToFloat(pThis, argThree.get());
2643 if ((nPrincipal <= 0) || (nRate <= 0) || (nPeriods <= 0)) { 2621 if ((nPrincipal <= 0) || (nRate <= 0) || (nPeriods <= 0)) {
2644 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); 2622 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
2645 return; 2623 return;
2646 } 2624 }
2647 2625
2648 FX_FLOAT nTmp = 1 + nRate; 2626 FX_FLOAT nTmp = 1 + nRate;
2649 FX_FLOAT nSum = nTmp; 2627 FX_FLOAT nSum = nTmp;
2650 for (int32_t i = 0; i < nPeriods - 1; ++i) 2628 for (int32_t i = 0; i < nPeriods - 1; ++i)
2651 nSum *= nTmp; 2629 nSum *= nTmp;
2652 2630
2653 FXJSE_Value_SetFloat(args.GetReturnValue(), 2631 args.GetReturnValue()->SetFloat((nPrincipal * nRate * nSum) / (nSum - 1));
2654 (nPrincipal * nRate * nSum) / (nSum - 1));
2655 } 2632 }
2656 2633
2657 // static 2634 // static
2658 void CXFA_FM2JSContext::PPmt(CFXJSE_Value* pThis, 2635 void CXFA_FM2JSContext::PPmt(CFXJSE_Value* pThis,
2659 const CFX_ByteStringC& szFuncName, 2636 const CFX_ByteStringC& szFuncName,
2660 CFXJSE_Arguments& args) { 2637 CFXJSE_Arguments& args) {
2661 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 2638 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
2662 if (args.GetLength() != 5) { 2639 if (args.GetLength() != 5) {
2663 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"PPmt"); 2640 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"PPmt");
2664 return; 2641 return;
2665 } 2642 }
2666 2643
2667 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2644 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
2668 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 2645 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
2669 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 2646 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
2670 std::unique_ptr<CFXJSE_Value> argFour = GetSimpleValue(pThis, args, 3); 2647 std::unique_ptr<CFXJSE_Value> argFour = GetSimpleValue(pThis, args, 3);
2671 std::unique_ptr<CFXJSE_Value> argFive = GetSimpleValue(pThis, args, 4); 2648 std::unique_ptr<CFXJSE_Value> argFive = GetSimpleValue(pThis, args, 4);
2672 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || 2649 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) ||
2673 ValueIsNull(pThis, argThree.get()) || ValueIsNull(pThis, argFour.get()) || 2650 ValueIsNull(pThis, argThree.get()) || ValueIsNull(pThis, argFour.get()) ||
2674 ValueIsNull(pThis, argFive.get())) { 2651 ValueIsNull(pThis, argFive.get())) {
2675 FXJSE_Value_SetNull(args.GetReturnValue()); 2652 args.GetReturnValue()->SetNull();
2676 return; 2653 return;
2677 } 2654 }
2678 2655
2679 FX_FLOAT nPrincipalAmount = ValueToFloat(pThis, argOne.get()); 2656 FX_FLOAT nPrincipalAmount = ValueToFloat(pThis, argOne.get());
2680 FX_FLOAT nRate = ValueToFloat(pThis, argTwo.get()); 2657 FX_FLOAT nRate = ValueToFloat(pThis, argTwo.get());
2681 FX_FLOAT nPayment = ValueToFloat(pThis, argThree.get()); 2658 FX_FLOAT nPayment = ValueToFloat(pThis, argThree.get());
2682 FX_FLOAT nFirstMonth = ValueToFloat(pThis, argFour.get()); 2659 FX_FLOAT nFirstMonth = ValueToFloat(pThis, argFour.get());
2683 FX_FLOAT nNumberOfMonths = ValueToFloat(pThis, argFive.get()); 2660 FX_FLOAT nNumberOfMonths = ValueToFloat(pThis, argFive.get());
2684 if ((nPrincipalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) || 2661 if ((nPrincipalAmount <= 0) || (nRate <= 0) || (nPayment <= 0) ||
2685 (nFirstMonth < 0) || (nNumberOfMonths < 0)) { 2662 (nFirstMonth < 0) || (nNumberOfMonths < 0)) {
(...skipping 16 matching lines...) Expand all
2702 for (i = 0; i < nFirstMonth - 1; ++i) 2679 for (i = 0; i < nFirstMonth - 1; ++i)
2703 nPrincipalAmount -= nPayment - nPrincipalAmount * nRateOfMonth; 2680 nPrincipalAmount -= nPayment - nPrincipalAmount * nRateOfMonth;
2704 2681
2705 FX_FLOAT nTemp = 0; 2682 FX_FLOAT nTemp = 0;
2706 FX_FLOAT nSum = 0; 2683 FX_FLOAT nSum = 0;
2707 for (; i < iEnd; ++i) { 2684 for (; i < iEnd; ++i) {
2708 nTemp = nPayment - nPrincipalAmount * nRateOfMonth; 2685 nTemp = nPayment - nPrincipalAmount * nRateOfMonth;
2709 nSum += nTemp; 2686 nSum += nTemp;
2710 nPrincipalAmount -= nTemp; 2687 nPrincipalAmount -= nTemp;
2711 } 2688 }
2712 FXJSE_Value_SetFloat(args.GetReturnValue(), nSum); 2689 args.GetReturnValue()->SetFloat(nSum);
2713 } 2690 }
2714 2691
2715 // static 2692 // static
2716 void CXFA_FM2JSContext::PV(CFXJSE_Value* pThis, 2693 void CXFA_FM2JSContext::PV(CFXJSE_Value* pThis,
2717 const CFX_ByteStringC& szFuncName, 2694 const CFX_ByteStringC& szFuncName,
2718 CFXJSE_Arguments& args) { 2695 CFXJSE_Arguments& args) {
2719 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 2696 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
2720 if (args.GetLength() != 3) { 2697 if (args.GetLength() != 3) {
2721 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"PV"); 2698 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"PV");
2722 return; 2699 return;
2723 } 2700 }
2724 2701
2725 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2702 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
2726 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 2703 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
2727 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 2704 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
2728 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || 2705 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) ||
2729 ValueIsNull(pThis, argThree.get())) { 2706 ValueIsNull(pThis, argThree.get())) {
2730 FXJSE_Value_SetNull(args.GetReturnValue()); 2707 args.GetReturnValue()->SetNull();
2731 return; 2708 return;
2732 } 2709 }
2733 2710
2734 FX_DOUBLE nAmount = ValueToDouble(pThis, argOne.get()); 2711 FX_DOUBLE nAmount = ValueToDouble(pThis, argOne.get());
2735 FX_DOUBLE nRate = ValueToDouble(pThis, argTwo.get()); 2712 FX_DOUBLE nRate = ValueToDouble(pThis, argTwo.get());
2736 FX_DOUBLE nPeriod = ValueToDouble(pThis, argThree.get()); 2713 FX_DOUBLE nPeriod = ValueToDouble(pThis, argThree.get());
2737 if ((nAmount <= 0) || (nRate < 0) || (nPeriod <= 0)) { 2714 if ((nAmount <= 0) || (nRate < 0) || (nPeriod <= 0)) {
2738 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); 2715 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
2739 return; 2716 return;
2740 } 2717 }
2741 2718
2742 FX_DOUBLE nTemp = 1; 2719 FX_DOUBLE nTemp = 1;
2743 for (int32_t i = 0; i < nPeriod; ++i) 2720 for (int32_t i = 0; i < nPeriod; ++i)
2744 nTemp *= 1 + nRate; 2721 nTemp *= 1 + nRate;
2745 2722
2746 nTemp = 1 / nTemp; 2723 nTemp = 1 / nTemp;
2747 FXJSE_Value_SetDouble(args.GetReturnValue(), nAmount * ((1 - nTemp) / nRate)); 2724 args.GetReturnValue()->SetDouble(nAmount * ((1 - nTemp) / nRate));
2748 } 2725 }
2749 2726
2750 // static 2727 // static
2751 void CXFA_FM2JSContext::Rate(CFXJSE_Value* pThis, 2728 void CXFA_FM2JSContext::Rate(CFXJSE_Value* pThis,
2752 const CFX_ByteStringC& szFuncName, 2729 const CFX_ByteStringC& szFuncName,
2753 CFXJSE_Arguments& args) { 2730 CFXJSE_Arguments& args) {
2754 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 2731 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
2755 if (args.GetLength() != 3) { 2732 if (args.GetLength() != 3) {
2756 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Rate"); 2733 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Rate");
2757 return; 2734 return;
2758 } 2735 }
2759 2736
2760 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2737 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
2761 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 2738 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
2762 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 2739 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
2763 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || 2740 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) ||
2764 ValueIsNull(pThis, argThree.get())) { 2741 ValueIsNull(pThis, argThree.get())) {
2765 FXJSE_Value_SetNull(args.GetReturnValue()); 2742 args.GetReturnValue()->SetNull();
2766 return; 2743 return;
2767 } 2744 }
2768 2745
2769 FX_FLOAT nFuture = ValueToFloat(pThis, argOne.get()); 2746 FX_FLOAT nFuture = ValueToFloat(pThis, argOne.get());
2770 FX_FLOAT nPresent = ValueToFloat(pThis, argTwo.get()); 2747 FX_FLOAT nPresent = ValueToFloat(pThis, argTwo.get());
2771 FX_FLOAT nTotalNumber = ValueToFloat(pThis, argThree.get()); 2748 FX_FLOAT nTotalNumber = ValueToFloat(pThis, argThree.get());
2772 if ((nFuture <= 0) || (nPresent < 0) || (nTotalNumber <= 0)) { 2749 if ((nFuture <= 0) || (nPresent < 0) || (nTotalNumber <= 0)) {
2773 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); 2750 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
2774 return; 2751 return;
2775 } 2752 }
2776 2753
2777 FXJSE_Value_SetFloat( 2754 args.GetReturnValue()->SetFloat(
2778 args.GetReturnValue(), 2755 FXSYS_pow((FX_FLOAT)(nFuture / nPresent), (FX_FLOAT)(1 / nTotalNumber)) -
2779 (FXSYS_pow((FX_FLOAT)(nFuture / nPresent), (FX_FLOAT)(1 / nTotalNumber)) - 2756 1);
2780 1));
2781 } 2757 }
2782 2758
2783 // static 2759 // static
2784 void CXFA_FM2JSContext::Term(CFXJSE_Value* pThis, 2760 void CXFA_FM2JSContext::Term(CFXJSE_Value* pThis,
2785 const CFX_ByteStringC& szFuncName, 2761 const CFX_ByteStringC& szFuncName,
2786 CFXJSE_Arguments& args) { 2762 CFXJSE_Arguments& args) {
2787 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 2763 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
2788 if (args.GetLength() != 3) { 2764 if (args.GetLength() != 3) {
2789 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Term"); 2765 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Term");
2790 return; 2766 return;
2791 } 2767 }
2792 2768
2793 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2769 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
2794 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 2770 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
2795 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 2771 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
2796 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) || 2772 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get()) ||
2797 ValueIsNull(pThis, argThree.get())) { 2773 ValueIsNull(pThis, argThree.get())) {
2798 FXJSE_Value_SetNull(args.GetReturnValue()); 2774 args.GetReturnValue()->SetNull();
2799 return; 2775 return;
2800 } 2776 }
2801 2777
2802 FX_FLOAT nMount = ValueToFloat(pThis, argOne.get()); 2778 FX_FLOAT nMount = ValueToFloat(pThis, argOne.get());
2803 FX_FLOAT nRate = ValueToFloat(pThis, argTwo.get()); 2779 FX_FLOAT nRate = ValueToFloat(pThis, argTwo.get());
2804 FX_FLOAT nFuture = ValueToFloat(pThis, argThree.get()); 2780 FX_FLOAT nFuture = ValueToFloat(pThis, argThree.get());
2805 if ((nMount <= 0) || (nRate <= 0) || (nFuture <= 0)) { 2781 if ((nMount <= 0) || (nRate <= 0) || (nFuture <= 0)) {
2806 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); 2782 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
2807 return; 2783 return;
2808 } 2784 }
2809 2785
2810 FXJSE_Value_SetFloat(args.GetReturnValue(), 2786 args.GetReturnValue()->SetFloat(
2811 (FXSYS_log((FX_FLOAT)(nFuture / nMount * nRate) + 1) / 2787 FXSYS_log((FX_FLOAT)(nFuture / nMount * nRate) + 1) /
2812 FXSYS_log((FX_FLOAT)(1 + nRate)))); 2788 FXSYS_log((FX_FLOAT)(1 + nRate)));
2813 } 2789 }
2814 2790
2815 // static 2791 // static
2816 void CXFA_FM2JSContext::Choose(CFXJSE_Value* pThis, 2792 void CXFA_FM2JSContext::Choose(CFXJSE_Value* pThis,
2817 const CFX_ByteStringC& szFuncName, 2793 const CFX_ByteStringC& szFuncName,
2818 CFXJSE_Arguments& args) { 2794 CFXJSE_Arguments& args) {
2819 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 2795 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
2820 int32_t argc = args.GetLength(); 2796 int32_t argc = args.GetLength();
2821 if (argc < 2) { 2797 if (argc < 2) {
2822 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Choose"); 2798 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Choose");
2823 return; 2799 return;
2824 } 2800 }
2825 2801
2826 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 2802 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
2827 if (ValueIsNull(pThis, argOne.get())) { 2803 if (ValueIsNull(pThis, argOne.get())) {
2828 FXJSE_Value_SetNull(args.GetReturnValue()); 2804 args.GetReturnValue()->SetNull();
2829 return; 2805 return;
2830 } 2806 }
2831 2807
2832 int32_t iIndex = (int32_t)ValueToFloat(pThis, argOne.get()); 2808 int32_t iIndex = (int32_t)ValueToFloat(pThis, argOne.get());
2833 if (iIndex < 1) { 2809 if (iIndex < 1) {
2834 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); 2810 args.GetReturnValue()->SetString("");
2835 return; 2811 return;
2836 } 2812 }
2837 2813
2838 FX_BOOL bFound = FALSE; 2814 FX_BOOL bFound = FALSE;
2839 FX_BOOL bStopCounterFlags = FALSE; 2815 FX_BOOL bStopCounterFlags = FALSE;
2840 int32_t iArgIndex = 1; 2816 int32_t iArgIndex = 1;
2841 int32_t iValueIndex = 0; 2817 int32_t iValueIndex = 0;
2842 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 2818 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
2843 while (!bFound && !bStopCounterFlags && (iArgIndex < argc)) { 2819 while (!bFound && !bStopCounterFlags && (iArgIndex < argc)) {
2844 std::unique_ptr<CFXJSE_Value> argIndexValue = args.GetValue(iArgIndex); 2820 std::unique_ptr<CFXJSE_Value> argIndexValue = args.GetValue(iArgIndex);
2845 if (FXJSE_Value_IsArray(argIndexValue.get())) { 2821 if (FXJSE_Value_IsArray(argIndexValue.get())) {
2846 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 2822 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
2847 FXJSE_Value_GetObjectProp(argIndexValue.get(), "length", 2823 argIndexValue->GetObjectProperty("length", lengthValue.get());
2848 lengthValue.get()); 2824 int32_t iLength = lengthValue->ToInteger();
2849 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get());
2850 if (iLength > 3) 2825 if (iLength > 3)
2851 bStopCounterFlags = TRUE; 2826 bStopCounterFlags = TRUE;
2852 2827
2853 iValueIndex += (iLength - 2); 2828 iValueIndex += (iLength - 2);
2854 if (iValueIndex >= iIndex) { 2829 if (iValueIndex >= iIndex) {
2855 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 2830 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
2856 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 2831 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
2857 std::unique_ptr<CFXJSE_Value> newPropertyValue( 2832 std::unique_ptr<CFXJSE_Value> newPropertyValue(
2858 new CFXJSE_Value(pIsolate)); 2833 new CFXJSE_Value(pIsolate));
2859 FXJSE_Value_GetObjectPropByIdx(argIndexValue.get(), 1, 2834 argIndexValue->GetObjectPropertyByIdx(1, propertyValue.get());
2860 propertyValue.get()); 2835 argIndexValue->GetObjectPropertyByIdx(
2861 FXJSE_Value_GetObjectPropByIdx(argIndexValue.get(), 2836 (iLength - 1) - (iValueIndex - iIndex), jsObjectValue.get());
2862 ((iLength - 1) - (iValueIndex - iIndex)),
2863 jsObjectValue.get());
2864 if (FXJSE_Value_IsNull(propertyValue.get())) { 2837 if (FXJSE_Value_IsNull(propertyValue.get())) {
2865 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); 2838 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get());
2866 } else { 2839 } else {
2867 CFX_ByteString propStr; 2840 CFX_ByteString propStr;
2868 FXJSE_Value_ToUTF8String(propertyValue.get(), propStr); 2841 propertyValue->ToString(propStr);
2869 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propStr.AsStringC(), 2842 jsObjectValue->GetObjectProperty(propStr.AsStringC(),
2870 newPropertyValue.get()); 2843 newPropertyValue.get());
2871 } 2844 }
2872 CFX_ByteString bsChoosed; 2845 CFX_ByteString bsChoosed;
2873 ValueToUTF8String(newPropertyValue.get(), bsChoosed); 2846 ValueToUTF8String(newPropertyValue.get(), bsChoosed);
2874 FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsChoosed.AsStringC()); 2847 args.GetReturnValue()->SetString(bsChoosed.AsStringC());
2875 bFound = TRUE; 2848 bFound = TRUE;
2876 } 2849 }
2877 } else { 2850 } else {
2878 iValueIndex++; 2851 iValueIndex++;
2879 if (iValueIndex == iIndex) { 2852 if (iValueIndex == iIndex) {
2880 CFX_ByteString bsChoosed; 2853 CFX_ByteString bsChoosed;
2881 ValueToUTF8String(argIndexValue.get(), bsChoosed); 2854 ValueToUTF8String(argIndexValue.get(), bsChoosed);
2882 FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsChoosed.AsStringC()); 2855 args.GetReturnValue()->SetString(bsChoosed.AsStringC());
2883 bFound = TRUE; 2856 bFound = TRUE;
2884 } 2857 }
2885 } 2858 }
2886 iArgIndex++; 2859 iArgIndex++;
2887 } 2860 }
2888 if (!bFound) 2861 if (!bFound)
2889 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); 2862 args.GetReturnValue()->SetString("");
2890 } 2863 }
2891 2864
2892 // static 2865 // static
2893 void CXFA_FM2JSContext::Exists(CFXJSE_Value* pThis, 2866 void CXFA_FM2JSContext::Exists(CFXJSE_Value* pThis,
2894 const CFX_ByteStringC& szFuncName, 2867 const CFX_ByteStringC& szFuncName,
2895 CFXJSE_Arguments& args) { 2868 CFXJSE_Arguments& args) {
2896 if (args.GetLength() != 1) { 2869 if (args.GetLength() != 1) {
2897 ToJSContext(pThis, nullptr) 2870 ToJSContext(pThis, nullptr)
2898 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Exists"); 2871 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Exists");
2899 return; 2872 return;
2900 } 2873 }
2901 2874
2902 FXJSE_Value_SetInteger(args.GetReturnValue(), 2875 args.GetReturnValue()->SetInteger(
2903 FXJSE_Value_IsObject(args.GetValue(0).get())); 2876 FXJSE_Value_IsObject(args.GetValue(0).get()));
2904 } 2877 }
2905 2878
2906 // static 2879 // static
2907 void CXFA_FM2JSContext::HasValue(CFXJSE_Value* pThis, 2880 void CXFA_FM2JSContext::HasValue(CFXJSE_Value* pThis,
2908 const CFX_ByteStringC& szFuncName, 2881 const CFX_ByteStringC& szFuncName,
2909 CFXJSE_Arguments& args) { 2882 CFXJSE_Arguments& args) {
2910 if (args.GetLength() != 1) { 2883 if (args.GetLength() != 1) {
2911 ToJSContext(pThis, nullptr) 2884 ToJSContext(pThis, nullptr)
2912 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"HasValue"); 2885 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"HasValue");
2913 return; 2886 return;
2914 } 2887 }
2915 2888
2916 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2889 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
2917 if (!FXJSE_Value_IsUTF8String(argOne.get())) { 2890 if (!FXJSE_Value_IsUTF8String(argOne.get())) {
2918 FXJSE_Value_SetInteger(args.GetReturnValue(), 2891 args.GetReturnValue()->SetInteger(FXJSE_Value_IsNumber(argOne.get()) ||
2919 FXJSE_Value_IsNumber(argOne.get()) || 2892 FXJSE_Value_IsBoolean(argOne.get()));
2920 FXJSE_Value_IsBoolean(argOne.get()));
2921 return; 2893 return;
2922 } 2894 }
2923 2895
2924 CFX_ByteString valueStr; 2896 CFX_ByteString valueStr;
2925 FXJSE_Value_ToUTF8String(argOne.get(), valueStr); 2897 argOne->ToString(valueStr);
2926 valueStr.TrimLeft(); 2898 valueStr.TrimLeft();
2927 FXJSE_Value_SetInteger(args.GetReturnValue(), (!valueStr.IsEmpty())); 2899 args.GetReturnValue()->SetInteger(!valueStr.IsEmpty());
2928 } 2900 }
2929 2901
2930 // static 2902 // static
2931 void CXFA_FM2JSContext::Oneof(CFXJSE_Value* pThis, 2903 void CXFA_FM2JSContext::Oneof(CFXJSE_Value* pThis,
2932 const CFX_ByteStringC& szFuncName, 2904 const CFX_ByteStringC& szFuncName,
2933 CFXJSE_Arguments& args) { 2905 CFXJSE_Arguments& args) {
2934 if (args.GetLength() < 2) { 2906 if (args.GetLength() < 2) {
2935 ToJSContext(pThis, nullptr) 2907 ToJSContext(pThis, nullptr)
2936 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Oneof"); 2908 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Oneof");
2937 return; 2909 return;
2938 } 2910 }
2939 2911
2940 FX_BOOL bFlags = FALSE; 2912 FX_BOOL bFlags = FALSE;
2941 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2913 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
2942 CFXJSE_Value** parametersValue = nullptr; 2914 CFXJSE_Value** parametersValue = nullptr;
2943 int32_t iCount = 0; 2915 int32_t iCount = 0;
2944 unfoldArgs(pThis, args, parametersValue, iCount, 1); 2916 unfoldArgs(pThis, args, parametersValue, iCount, 1);
2945 for (int32_t i = 0; i < iCount; i++) { 2917 for (int32_t i = 0; i < iCount; i++) {
2946 if (simpleValueCompare(pThis, argOne.get(), parametersValue[i])) { 2918 if (simpleValueCompare(pThis, argOne.get(), parametersValue[i])) {
2947 bFlags = TRUE; 2919 bFlags = TRUE;
2948 break; 2920 break;
2949 } 2921 }
2950 } 2922 }
2951 for (int32_t i = 0; i < iCount; i++) 2923 for (int32_t i = 0; i < iCount; i++)
2952 delete parametersValue[i]; 2924 delete parametersValue[i];
2953 FX_Free(parametersValue); 2925 FX_Free(parametersValue);
2954 2926
2955 FXJSE_Value_SetInteger(args.GetReturnValue(), bFlags); 2927 args.GetReturnValue()->SetInteger(bFlags);
2956 } 2928 }
2957 2929
2958 // static 2930 // static
2959 void CXFA_FM2JSContext::Within(CFXJSE_Value* pThis, 2931 void CXFA_FM2JSContext::Within(CFXJSE_Value* pThis,
2960 const CFX_ByteStringC& szFuncName, 2932 const CFX_ByteStringC& szFuncName,
2961 CFXJSE_Arguments& args) { 2933 CFXJSE_Arguments& args) {
2962 if (args.GetLength() != 3) { 2934 if (args.GetLength() != 3) {
2963 ToJSContext(pThis, nullptr) 2935 ToJSContext(pThis, nullptr)
2964 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Within"); 2936 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Within");
2965 return; 2937 return;
2966 } 2938 }
2967 2939
2968 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 2940 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
2969 if (FXJSE_Value_IsNull(argOne.get())) { 2941 if (FXJSE_Value_IsNull(argOne.get())) {
2970 FXJSE_Value_SetUndefined(args.GetReturnValue()); 2942 args.GetReturnValue()->SetUndefined();
2971 return; 2943 return;
2972 } 2944 }
2973 2945
2974 std::unique_ptr<CFXJSE_Value> argLow = GetSimpleValue(pThis, args, 1); 2946 std::unique_ptr<CFXJSE_Value> argLow = GetSimpleValue(pThis, args, 1);
2975 std::unique_ptr<CFXJSE_Value> argHigh = GetSimpleValue(pThis, args, 2); 2947 std::unique_ptr<CFXJSE_Value> argHigh = GetSimpleValue(pThis, args, 2);
2976 if (FXJSE_Value_IsNumber(argOne.get())) { 2948 if (FXJSE_Value_IsNumber(argOne.get())) {
2977 FX_FLOAT oneNumber = ValueToFloat(pThis, argOne.get()); 2949 FX_FLOAT oneNumber = ValueToFloat(pThis, argOne.get());
2978 FX_FLOAT lowNumber = ValueToFloat(pThis, argLow.get()); 2950 FX_FLOAT lowNumber = ValueToFloat(pThis, argLow.get());
2979 FX_FLOAT heightNumber = ValueToFloat(pThis, argHigh.get()); 2951 FX_FLOAT heightNumber = ValueToFloat(pThis, argHigh.get());
2980 FXJSE_Value_SetInteger( 2952 args.GetReturnValue()->SetInteger((oneNumber >= lowNumber) &&
2981 args.GetReturnValue(), 2953 (oneNumber <= heightNumber));
2982 ((oneNumber >= lowNumber) && (oneNumber <= heightNumber)));
2983 return; 2954 return;
2984 } 2955 }
2985 2956
2986 CFX_ByteString oneString; 2957 CFX_ByteString oneString;
2987 CFX_ByteString lowString; 2958 CFX_ByteString lowString;
2988 CFX_ByteString heightString; 2959 CFX_ByteString heightString;
2989 ValueToUTF8String(argOne.get(), oneString); 2960 ValueToUTF8String(argOne.get(), oneString);
2990 ValueToUTF8String(argLow.get(), lowString); 2961 ValueToUTF8String(argLow.get(), lowString);
2991 ValueToUTF8String(argHigh.get(), heightString); 2962 ValueToUTF8String(argHigh.get(), heightString);
2992 FXJSE_Value_SetInteger(args.GetReturnValue(), 2963 args.GetReturnValue()->SetInteger(
2993 ((oneString.Compare(lowString.AsStringC()) >= 0) && 2964 (oneString.Compare(lowString.AsStringC()) >= 0) &&
2994 (oneString.Compare(heightString.AsStringC()) <= 0))); 2965 (oneString.Compare(heightString.AsStringC()) <= 0));
2995 } 2966 }
2996 2967
2997 // static 2968 // static
2998 void CXFA_FM2JSContext::If(CFXJSE_Value* pThis, 2969 void CXFA_FM2JSContext::If(CFXJSE_Value* pThis,
2999 const CFX_ByteStringC& szFuncName, 2970 const CFX_ByteStringC& szFuncName,
3000 CFXJSE_Arguments& args) { 2971 CFXJSE_Arguments& args) {
3001 if (args.GetLength() != 3) { 2972 if (args.GetLength() != 3) {
3002 ToJSContext(pThis, nullptr) 2973 ToJSContext(pThis, nullptr)
3003 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"If"); 2974 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"If");
3004 return; 2975 return;
3005 } 2976 }
3006 2977
3007 FXJSE_Value_Set(args.GetReturnValue(), 2978 args.GetReturnValue()->Assign(GetSimpleValue(pThis, args, 0)->ToBoolean()
3008 FXJSE_Value_ToBoolean(GetSimpleValue(pThis, args, 0).get()) 2979 ? GetSimpleValue(pThis, args, 1).get()
3009 ? GetSimpleValue(pThis, args, 1).get() 2980 : GetSimpleValue(pThis, args, 2).get());
3010 : GetSimpleValue(pThis, args, 2).get());
3011 } 2981 }
3012 2982
3013 // static 2983 // static
3014 void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis, 2984 void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis,
3015 const CFX_ByteStringC& szFuncName, 2985 const CFX_ByteStringC& szFuncName,
3016 CFXJSE_Arguments& args) { 2986 CFXJSE_Arguments& args) {
3017 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 2987 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
3018 if (args.GetLength() != 1) { 2988 if (args.GetLength() != 1) {
3019 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Eval"); 2989 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Eval");
3020 return; 2990 return;
3021 } 2991 }
3022 2992
3023 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 2993 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
3024 std::unique_ptr<CFXJSE_Value> scriptValue = GetSimpleValue(pThis, args, 0); 2994 std::unique_ptr<CFXJSE_Value> scriptValue = GetSimpleValue(pThis, args, 0);
3025 CFX_ByteString utf8ScriptString; 2995 CFX_ByteString utf8ScriptString;
3026 ValueToUTF8String(scriptValue.get(), utf8ScriptString); 2996 ValueToUTF8String(scriptValue.get(), utf8ScriptString);
3027 if (utf8ScriptString.IsEmpty()) { 2997 if (utf8ScriptString.IsEmpty()) {
3028 FXJSE_Value_SetNull(args.GetReturnValue()); 2998 args.GetReturnValue()->SetNull();
3029 return; 2999 return;
3030 } 3000 }
3031 3001
3032 CFX_WideTextBuf wsJavaScriptBuf; 3002 CFX_WideTextBuf wsJavaScriptBuf;
3033 CFX_WideString wsError; 3003 CFX_WideString wsError;
3034 CXFA_FM2JSContext::Translate( 3004 CXFA_FM2JSContext::Translate(
3035 CFX_WideString::FromUTF8(utf8ScriptString.AsStringC()).AsStringC(), 3005 CFX_WideString::FromUTF8(utf8ScriptString.AsStringC()).AsStringC(),
3036 wsJavaScriptBuf, wsError); 3006 wsJavaScriptBuf, wsError);
3037 CFXJSE_Context* pNewContext = 3007 CFXJSE_Context* pNewContext =
3038 FXJSE_Context_Create(pIsolate, nullptr, nullptr); 3008 FXJSE_Context_Create(pIsolate, nullptr, nullptr);
3039 3009
3040 std::unique_ptr<CFXJSE_Value> returnValue(new CFXJSE_Value(pIsolate)); 3010 std::unique_ptr<CFXJSE_Value> returnValue(new CFXJSE_Value(pIsolate));
3041 CFX_WideString javaScript(wsJavaScriptBuf.AsStringC()); 3011 CFX_WideString javaScript(wsJavaScriptBuf.AsStringC());
3042 FXJSE_ExecuteScript( 3012 FXJSE_ExecuteScript(
3043 pNewContext, 3013 pNewContext,
3044 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(), 3014 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(),
3045 returnValue.get()); 3015 returnValue.get());
3046 3016
3047 FXJSE_Value_Set(args.GetReturnValue(), returnValue.get()); 3017 args.GetReturnValue()->Assign(returnValue.get());
3048 FXJSE_Context_Release(pNewContext); 3018 FXJSE_Context_Release(pNewContext);
3049 } 3019 }
3050 3020
3051 // static 3021 // static
3052 void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis, 3022 void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis,
3053 const CFX_ByteStringC& szFuncName, 3023 const CFX_ByteStringC& szFuncName,
3054 CFXJSE_Arguments& args) { 3024 CFXJSE_Arguments& args) {
3055 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 3025 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
3056 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 3026 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
3057 if (args.GetLength() != 1) { 3027 if (args.GetLength() != 1) {
3058 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Ref"); 3028 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Ref");
3059 return; 3029 return;
3060 } 3030 }
3061 3031
3062 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 3032 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
3063 if (!FXJSE_Value_IsArray(argOne.get()) && 3033 if (!FXJSE_Value_IsArray(argOne.get()) &&
3064 !FXJSE_Value_IsObject(argOne.get()) && 3034 !FXJSE_Value_IsObject(argOne.get()) &&
3065 !FXJSE_Value_IsBoolean(argOne.get()) && 3035 !FXJSE_Value_IsBoolean(argOne.get()) &&
3066 !FXJSE_Value_IsUTF8String(argOne.get()) && 3036 !FXJSE_Value_IsUTF8String(argOne.get()) &&
3067 !FXJSE_Value_IsNull(argOne.get()) && 3037 !FXJSE_Value_IsNull(argOne.get()) &&
3068 !FXJSE_Value_IsNumber(argOne.get())) { 3038 !FXJSE_Value_IsNumber(argOne.get())) {
3069 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); 3039 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
3070 return; 3040 return;
3071 } 3041 }
3072 3042
3073 if (FXJSE_Value_IsBoolean(argOne.get()) || 3043 if (FXJSE_Value_IsBoolean(argOne.get()) ||
3074 FXJSE_Value_IsUTF8String(argOne.get()) || 3044 FXJSE_Value_IsUTF8String(argOne.get()) ||
3075 FXJSE_Value_IsNumber(argOne.get())) { 3045 FXJSE_Value_IsNumber(argOne.get())) {
3076 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); 3046 args.GetReturnValue()->Assign(argOne.get());
3077 return; 3047 return;
3078 } 3048 }
3079 3049
3080 CFXJSE_Value* rgValues[3]; 3050 CFXJSE_Value* rgValues[3];
3081 for (int32_t i = 0; i < 3; i++) 3051 for (int32_t i = 0; i < 3; i++)
3082 rgValues[i] = new CFXJSE_Value(pIsolate); 3052 rgValues[i] = new CFXJSE_Value(pIsolate);
3083 3053
3084 int intVal = 3; 3054 int intVal = 3;
3085 if (FXJSE_Value_IsNull(argOne.get())) { 3055 if (FXJSE_Value_IsNull(argOne.get())) {
3086 intVal = 4; 3056 intVal = 4;
3087 FXJSE_Value_SetNull(rgValues[2]); 3057 rgValues[2]->SetNull();
3088 } else if (FXJSE_Value_IsArray(argOne.get())) { 3058 } else if (FXJSE_Value_IsArray(argOne.get())) {
3089 #ifndef NDEBUG 3059 #ifndef NDEBUG
3090 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 3060 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
3091 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get()); 3061 argOne->GetObjectProperty("length", lengthValue.get());
3092 ASSERT(FXJSE_Value_ToInteger(lengthValue.get()) >= 3); 3062 ASSERT(lengthValue->ToInteger() >= 3);
3093 #endif 3063 #endif
3094 3064
3095 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 3065 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
3096 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 3066 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
3097 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 1, propertyValue.get()); 3067 argOne->GetObjectPropertyByIdx(1, propertyValue.get());
3098 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, jsObjectValue.get()); 3068 argOne->GetObjectPropertyByIdx(2, jsObjectValue.get());
3099 if (!FXJSE_Value_IsNull(propertyValue.get()) || 3069 if (!FXJSE_Value_IsNull(propertyValue.get()) ||
3100 FXJSE_Value_IsNull(jsObjectValue.get())) { 3070 FXJSE_Value_IsNull(jsObjectValue.get())) {
3101 for (int32_t i = 0; i < 3; i++) 3071 for (int32_t i = 0; i < 3; i++)
3102 delete rgValues[i]; 3072 delete rgValues[i];
3103 3073
3104 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); 3074 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
3105 return; 3075 return;
3106 } 3076 }
3107 3077
3108 FXJSE_Value_Set(rgValues[2], jsObjectValue.get()); 3078 rgValues[2]->Assign(jsObjectValue.get());
3109 } else if (FXJSE_Value_IsObject(argOne.get())) { 3079 } else if (FXJSE_Value_IsObject(argOne.get())) {
3110 FXJSE_Value_Set(rgValues[2], argOne.get()); 3080 rgValues[2]->Assign(argOne.get());
3111 } 3081 }
3112 3082
3113 FXJSE_Value_SetInteger(rgValues[0], intVal); 3083 rgValues[0]->SetInteger(intVal);
3114 FXJSE_Value_SetNull(rgValues[1]); 3084 rgValues[1]->SetNull();
3115 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); 3085 args.GetReturnValue()->SetArray(3, rgValues);
3116 3086
3117 for (int32_t i = 0; i < 3; i++) 3087 for (int32_t i = 0; i < 3; i++)
3118 delete rgValues[i]; 3088 delete rgValues[i];
3119 } 3089 }
3120 3090
3121 // static 3091 // static
3122 void CXFA_FM2JSContext::UnitType(CFXJSE_Value* pThis, 3092 void CXFA_FM2JSContext::UnitType(CFXJSE_Value* pThis,
3123 const CFX_ByteStringC& szFuncName, 3093 const CFX_ByteStringC& szFuncName,
3124 CFXJSE_Arguments& args) { 3094 CFXJSE_Arguments& args) {
3125 if (args.GetLength() != 1) { 3095 if (args.GetLength() != 1) {
3126 ToJSContext(pThis, nullptr) 3096 ToJSContext(pThis, nullptr)
3127 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"UnitType"); 3097 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"UnitType");
3128 return; 3098 return;
3129 } 3099 }
3130 3100
3131 std::unique_ptr<CFXJSE_Value> unitspanValue = GetSimpleValue(pThis, args, 0); 3101 std::unique_ptr<CFXJSE_Value> unitspanValue = GetSimpleValue(pThis, args, 0);
3132 if (FXJSE_Value_IsNull(unitspanValue.get())) { 3102 if (FXJSE_Value_IsNull(unitspanValue.get())) {
3133 FXJSE_Value_SetNull(args.GetReturnValue()); 3103 args.GetReturnValue()->SetNull();
3134 return; 3104 return;
3135 } 3105 }
3136 3106
3137 CFX_ByteString unitspanString; 3107 CFX_ByteString unitspanString;
3138 ValueToUTF8String(unitspanValue.get(), unitspanString); 3108 ValueToUTF8String(unitspanValue.get(), unitspanString);
3139 if (unitspanString.IsEmpty()) { 3109 if (unitspanString.IsEmpty()) {
3140 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "in"); 3110 args.GetReturnValue()->SetString("in");
3141 return; 3111 return;
3142 } 3112 }
3143 3113
3144 enum XFA_FM2JS_VALUETYPE_ParserStatus { 3114 enum XFA_FM2JS_VALUETYPE_ParserStatus {
3145 VALUETYPE_START, 3115 VALUETYPE_START,
3146 VALUETYPE_HAVEINVALIDCHAR, 3116 VALUETYPE_HAVEINVALIDCHAR,
3147 VALUETYPE_HAVEDIGIT, 3117 VALUETYPE_HAVEDIGIT,
3148 VALUETYPE_HAVEDIGITWHITE, 3118 VALUETYPE_HAVEDIGITWHITE,
3149 VALUETYPE_ISCM, 3119 VALUETYPE_ISCM,
3150 VALUETYPE_ISMM, 3120 VALUETYPE_ISMM,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
3207 } 3177 }
3208 break; 3178 break;
3209 } 3179 }
3210 } else { 3180 } else {
3211 eParserStatus = VALUETYPE_HAVEINVALIDCHAR; 3181 eParserStatus = VALUETYPE_HAVEINVALIDCHAR;
3212 } 3182 }
3213 u++; 3183 u++;
3214 } 3184 }
3215 switch (eParserStatus) { 3185 switch (eParserStatus) {
3216 case VALUETYPE_ISCM: 3186 case VALUETYPE_ISCM:
3217 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "cm"); 3187 args.GetReturnValue()->SetString("cm");
3218 break; 3188 break;
3219 case VALUETYPE_ISMM: 3189 case VALUETYPE_ISMM:
3220 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "mm"); 3190 args.GetReturnValue()->SetString("mm");
3221 break; 3191 break;
3222 case VALUETYPE_ISPT: 3192 case VALUETYPE_ISPT:
3223 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "pt"); 3193 args.GetReturnValue()->SetString("pt");
3224 break; 3194 break;
3225 case VALUETYPE_ISMP: 3195 case VALUETYPE_ISMP:
3226 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "mp"); 3196 args.GetReturnValue()->SetString("mp");
3227 break; 3197 break;
3228 default: 3198 default:
3229 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "in"); 3199 args.GetReturnValue()->SetString("in");
3230 break; 3200 break;
3231 } 3201 }
3232 } 3202 }
3233 3203
3234 // static 3204 // static
3235 void CXFA_FM2JSContext::UnitValue(CFXJSE_Value* pThis, 3205 void CXFA_FM2JSContext::UnitValue(CFXJSE_Value* pThis,
3236 const CFX_ByteStringC& szFuncName, 3206 const CFX_ByteStringC& szFuncName,
3237 CFXJSE_Arguments& args) { 3207 CFXJSE_Arguments& args) {
3238 int32_t argc = args.GetLength(); 3208 int32_t argc = args.GetLength();
3239 if (argc < 1 || argc > 2) { 3209 if (argc < 1 || argc > 2) {
3240 ToJSContext(pThis, nullptr) 3210 ToJSContext(pThis, nullptr)
3241 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"UnitValue"); 3211 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"UnitValue");
3242 return; 3212 return;
3243 } 3213 }
3244 3214
3245 std::unique_ptr<CFXJSE_Value> unitspanValue = GetSimpleValue(pThis, args, 0); 3215 std::unique_ptr<CFXJSE_Value> unitspanValue = GetSimpleValue(pThis, args, 0);
3246 if (FXJSE_Value_IsNull(unitspanValue.get())) { 3216 if (FXJSE_Value_IsNull(unitspanValue.get())) {
3247 FXJSE_Value_SetNull(args.GetReturnValue()); 3217 args.GetReturnValue()->SetNull();
3248 return; 3218 return;
3249 } 3219 }
3250 3220
3251 CFX_ByteString unitspanString; 3221 CFX_ByteString unitspanString;
3252 ValueToUTF8String(unitspanValue.get(), unitspanString); 3222 ValueToUTF8String(unitspanValue.get(), unitspanString);
3253 const FX_CHAR* pData = unitspanString.c_str(); 3223 const FX_CHAR* pData = unitspanString.c_str();
3254 if (!pData) { 3224 if (!pData) {
3255 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); 3225 args.GetReturnValue()->SetInteger(0);
3256 return; 3226 return;
3257 } 3227 }
3258 3228
3259 int32_t u = 0; 3229 int32_t u = 0;
3260 while (IsWhitespace(pData[u])) 3230 while (IsWhitespace(pData[u]))
3261 ++u; 3231 ++u;
3262 3232
3263 while (u < unitspanString.GetLength()) { 3233 while (u < unitspanString.GetLength()) {
3264 if ((pData[u] > '9' || pData[u] < '0') && pData[u] != '.' && 3234 if ((pData[u] > '9' || pData[u] < '0') && pData[u] != '.' &&
3265 pData[u] != '-') { 3235 pData[u] != '-') {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
3366 dResult = dFirstNumber / 72000 * 25.4; 3336 dResult = dFirstNumber / 72000 * 25.4;
3367 else if (strUnit == "cm" || strUnit == "centimeters") 3337 else if (strUnit == "cm" || strUnit == "centimeters")
3368 dResult = dFirstNumber / 72000 * 2.54; 3338 dResult = dFirstNumber / 72000 * 2.54;
3369 else if (strUnit == "pt" || strUnit == "points") 3339 else if (strUnit == "pt" || strUnit == "points")
3370 dResult = dFirstNumber / 1000; 3340 dResult = dFirstNumber / 1000;
3371 else if (strUnit == "mp" || strUnit == "millipoints") 3341 else if (strUnit == "mp" || strUnit == "millipoints")
3372 dResult = dFirstNumber; 3342 dResult = dFirstNumber;
3373 else 3343 else
3374 dResult = dFirstNumber / 72000; 3344 dResult = dFirstNumber / 72000;
3375 } 3345 }
3376 FXJSE_Value_SetDouble(args.GetReturnValue(), dResult); 3346 args.GetReturnValue()->SetDouble(dResult);
3377 } 3347 }
3378 3348
3379 // static 3349 // static
3380 void CXFA_FM2JSContext::At(CFXJSE_Value* pThis, 3350 void CXFA_FM2JSContext::At(CFXJSE_Value* pThis,
3381 const CFX_ByteStringC& szFuncName, 3351 const CFX_ByteStringC& szFuncName,
3382 CFXJSE_Arguments& args) { 3352 CFXJSE_Arguments& args) {
3383 if (args.GetLength() != 2) { 3353 if (args.GetLength() != 2) {
3384 ToJSContext(pThis, nullptr) 3354 ToJSContext(pThis, nullptr)
3385 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"At"); 3355 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"At");
3386 return; 3356 return;
3387 } 3357 }
3388 3358
3389 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 3359 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
3390 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 3360 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
3391 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get())) { 3361 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get())) {
3392 FXJSE_Value_SetNull(args.GetReturnValue()); 3362 args.GetReturnValue()->SetNull();
3393 return; 3363 return;
3394 } 3364 }
3395 3365
3396 CFX_ByteString stringTwo; 3366 CFX_ByteString stringTwo;
3397 ValueToUTF8String(argTwo.get(), stringTwo); 3367 ValueToUTF8String(argTwo.get(), stringTwo);
3398 if (stringTwo.IsEmpty()) { 3368 if (stringTwo.IsEmpty()) {
3399 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); 3369 args.GetReturnValue()->SetInteger(1);
3400 return; 3370 return;
3401 } 3371 }
3402 3372
3403 CFX_ByteString stringOne; 3373 CFX_ByteString stringOne;
3404 ValueToUTF8String(argOne.get(), stringOne); 3374 ValueToUTF8String(argOne.get(), stringOne);
3405 FX_STRSIZE iPosition = stringOne.Find(stringTwo.AsStringC()); 3375 FX_STRSIZE iPosition = stringOne.Find(stringTwo.AsStringC());
3406 FXJSE_Value_SetInteger(args.GetReturnValue(), iPosition + 1); 3376 args.GetReturnValue()->SetInteger(iPosition + 1);
3407 } 3377 }
3408 3378
3409 // static 3379 // static
3410 void CXFA_FM2JSContext::Concat(CFXJSE_Value* pThis, 3380 void CXFA_FM2JSContext::Concat(CFXJSE_Value* pThis,
3411 const CFX_ByteStringC& szFuncName, 3381 const CFX_ByteStringC& szFuncName,
3412 CFXJSE_Arguments& args) { 3382 CFXJSE_Arguments& args) {
3413 int32_t argc = args.GetLength(); 3383 int32_t argc = args.GetLength();
3414 if (argc < 1) { 3384 if (argc < 1) {
3415 ToJSContext(pThis, nullptr) 3385 ToJSContext(pThis, nullptr)
3416 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Concat"); 3386 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Concat");
3417 return; 3387 return;
3418 } 3388 }
3419 3389
3420 CFX_ByteString resultString; 3390 CFX_ByteString resultString;
3421 FX_BOOL bAllNull = TRUE; 3391 FX_BOOL bAllNull = TRUE;
3422 for (int32_t i = 0; i < argc; i++) { 3392 for (int32_t i = 0; i < argc; i++) {
3423 std::unique_ptr<CFXJSE_Value> value = GetSimpleValue(pThis, args, i); 3393 std::unique_ptr<CFXJSE_Value> value = GetSimpleValue(pThis, args, i);
3424 if (ValueIsNull(pThis, value.get())) 3394 if (ValueIsNull(pThis, value.get()))
3425 continue; 3395 continue;
3426 3396
3427 bAllNull = FALSE; 3397 bAllNull = FALSE;
3428 3398
3429 CFX_ByteString valueStr; 3399 CFX_ByteString valueStr;
3430 ValueToUTF8String(value.get(), valueStr); 3400 ValueToUTF8String(value.get(), valueStr);
3431 resultString += valueStr; 3401 resultString += valueStr;
3432 } 3402 }
3433 3403
3434 if (bAllNull) { 3404 if (bAllNull) {
3435 FXJSE_Value_SetNull(args.GetReturnValue()); 3405 args.GetReturnValue()->SetNull();
3436 return; 3406 return;
3437 } 3407 }
3438 3408
3439 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); 3409 args.GetReturnValue()->SetString(resultString.AsStringC());
3440 } 3410 }
3441 3411
3442 // static 3412 // static
3443 void CXFA_FM2JSContext::Decode(CFXJSE_Value* pThis, 3413 void CXFA_FM2JSContext::Decode(CFXJSE_Value* pThis,
3444 const CFX_ByteStringC& szFuncName, 3414 const CFX_ByteStringC& szFuncName,
3445 CFXJSE_Arguments& args) { 3415 CFXJSE_Arguments& args) {
3446 int32_t argc = args.GetLength(); 3416 int32_t argc = args.GetLength();
3447 if (argc < 1 || argc > 2) { 3417 if (argc < 1 || argc > 2) {
3448 ToJSContext(pThis, nullptr) 3418 ToJSContext(pThis, nullptr)
3449 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Decode"); 3419 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Decode");
3450 return; 3420 return;
3451 } 3421 }
3452 3422
3453 if (argc == 1) { 3423 if (argc == 1) {
3454 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 3424 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
3455 if (ValueIsNull(pThis, argOne.get())) { 3425 if (ValueIsNull(pThis, argOne.get())) {
3456 FXJSE_Value_SetNull(args.GetReturnValue()); 3426 args.GetReturnValue()->SetNull();
3457 return; 3427 return;
3458 } 3428 }
3459 3429
3460 CFX_ByteString toDecodeString; 3430 CFX_ByteString toDecodeString;
3461 ValueToUTF8String(argOne.get(), toDecodeString); 3431 ValueToUTF8String(argOne.get(), toDecodeString);
3462 CFX_ByteTextBuf resultBuf; 3432 CFX_ByteTextBuf resultBuf;
3463 DecodeURL(toDecodeString.AsStringC(), resultBuf); 3433 DecodeURL(toDecodeString.AsStringC(), resultBuf);
3464 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); 3434 args.GetReturnValue()->SetString(resultBuf.AsStringC());
3465 return; 3435 return;
3466 } 3436 }
3467 3437
3468 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 3438 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
3469 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 3439 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
3470 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get())) { 3440 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get())) {
3471 FXJSE_Value_SetNull(args.GetReturnValue()); 3441 args.GetReturnValue()->SetNull();
3472 return; 3442 return;
3473 } 3443 }
3474 3444
3475 CFX_ByteString toDecodeString; 3445 CFX_ByteString toDecodeString;
3476 ValueToUTF8String(argOne.get(), toDecodeString); 3446 ValueToUTF8String(argOne.get(), toDecodeString);
3477 3447
3478 CFX_ByteString identifyString; 3448 CFX_ByteString identifyString;
3479 ValueToUTF8String(argTwo.get(), identifyString); 3449 ValueToUTF8String(argTwo.get(), identifyString);
3480 3450
3481 CFX_ByteTextBuf resultBuf; 3451 CFX_ByteTextBuf resultBuf;
3482 if (identifyString.EqualNoCase("html")) 3452 if (identifyString.EqualNoCase("html"))
3483 DecodeHTML(toDecodeString.AsStringC(), resultBuf); 3453 DecodeHTML(toDecodeString.AsStringC(), resultBuf);
3484 else if (identifyString.EqualNoCase("xml")) 3454 else if (identifyString.EqualNoCase("xml"))
3485 DecodeXML(toDecodeString.AsStringC(), resultBuf); 3455 DecodeXML(toDecodeString.AsStringC(), resultBuf);
3486 else 3456 else
3487 DecodeURL(toDecodeString.AsStringC(), resultBuf); 3457 DecodeURL(toDecodeString.AsStringC(), resultBuf);
3488 3458
3489 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); 3459 args.GetReturnValue()->SetString(resultBuf.AsStringC());
3490 } 3460 }
3491 3461
3492 // static 3462 // static
3493 void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString, 3463 void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString,
3494 CFX_ByteTextBuf& szResultString) { 3464 CFX_ByteTextBuf& szResultString) {
3495 CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString); 3465 CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString);
3496 const FX_WCHAR* pData = wsURLString.c_str(); 3466 const FX_WCHAR* pData = wsURLString.c_str();
3497 int32_t i = 0; 3467 int32_t i = 0;
3498 CFX_WideTextBuf wsResultBuf; 3468 CFX_WideTextBuf wsResultBuf;
3499 while (i < wsURLString.GetLength()) { 3469 while (i < wsURLString.GetLength()) {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
3715 } 3685 }
3716 3686
3717 // static 3687 // static
3718 void CXFA_FM2JSContext::Encode(CFXJSE_Value* pThis, 3688 void CXFA_FM2JSContext::Encode(CFXJSE_Value* pThis,
3719 const CFX_ByteStringC& szFuncName, 3689 const CFX_ByteStringC& szFuncName,
3720 CFXJSE_Arguments& args) { 3690 CFXJSE_Arguments& args) {
3721 int32_t argc = args.GetLength(); 3691 int32_t argc = args.GetLength();
3722 if (argc == 1) { 3692 if (argc == 1) {
3723 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 3693 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
3724 if (ValueIsNull(pThis, argOne.get())) { 3694 if (ValueIsNull(pThis, argOne.get())) {
3725 FXJSE_Value_SetNull(args.GetReturnValue()); 3695 args.GetReturnValue()->SetNull();
3726 } else { 3696 } else {
3727 CFX_ByteString toEncodeString; 3697 CFX_ByteString toEncodeString;
3728 ValueToUTF8String(argOne.get(), toEncodeString); 3698 ValueToUTF8String(argOne.get(), toEncodeString);
3729 CFX_ByteTextBuf resultBuf; 3699 CFX_ByteTextBuf resultBuf;
3730 EncodeURL(toEncodeString.AsStringC(), resultBuf); 3700 EncodeURL(toEncodeString.AsStringC(), resultBuf);
3731 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); 3701 args.GetReturnValue()->SetString(resultBuf.AsStringC());
3732 } 3702 }
3733 } else if (argc == 2) { 3703 } else if (argc == 2) {
3734 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 3704 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
3735 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 3705 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
3736 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get())) { 3706 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get())) {
3737 FXJSE_Value_SetNull(args.GetReturnValue()); 3707 args.GetReturnValue()->SetNull();
3738 } else { 3708 } else {
3739 CFX_ByteString toEncodeString; 3709 CFX_ByteString toEncodeString;
3740 ValueToUTF8String(argOne.get(), toEncodeString); 3710 ValueToUTF8String(argOne.get(), toEncodeString);
3741 CFX_ByteString identifyString; 3711 CFX_ByteString identifyString;
3742 ValueToUTF8String(argTwo.get(), identifyString); 3712 ValueToUTF8String(argTwo.get(), identifyString);
3743 CFX_ByteTextBuf resultBuf; 3713 CFX_ByteTextBuf resultBuf;
3744 if (identifyString.EqualNoCase("html")) { 3714 if (identifyString.EqualNoCase("html")) {
3745 EncodeHTML(toEncodeString.AsStringC(), resultBuf); 3715 EncodeHTML(toEncodeString.AsStringC(), resultBuf);
3746 } else if (identifyString.EqualNoCase("xml")) { 3716 } else if (identifyString.EqualNoCase("xml")) {
3747 EncodeXML(toEncodeString.AsStringC(), resultBuf); 3717 EncodeXML(toEncodeString.AsStringC(), resultBuf);
3748 } else { 3718 } else {
3749 EncodeURL(toEncodeString.AsStringC(), resultBuf); 3719 EncodeURL(toEncodeString.AsStringC(), resultBuf);
3750 } 3720 }
3751 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); 3721 args.GetReturnValue()->SetString(resultBuf.AsStringC());
3752 } 3722 }
3753 } else { 3723 } else {
3754 ToJSContext(pThis, nullptr) 3724 ToJSContext(pThis, nullptr)
3755 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Encode"); 3725 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Encode");
3756 } 3726 }
3757 } 3727 }
3758 3728
3759 // static 3729 // static
3760 void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString, 3730 void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString,
3761 CFX_ByteTextBuf& szResultBuf) { 3731 CFX_ByteTextBuf& szResultBuf) {
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
4113 patternType = XFA_VT_TEXT; 4083 patternType = XFA_VT_TEXT;
4114 } 4084 }
4115 } break; 4085 } break;
4116 } 4086 }
4117 } 4087 }
4118 CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, pLocale, 4088 CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, pLocale,
4119 (CXFA_LocaleMgr*)pMgr); 4089 (CXFA_LocaleMgr*)pMgr);
4120 CFX_WideString wsRet; 4090 CFX_WideString wsRet;
4121 if (localeValue.FormatPatterns(wsRet, wsPattern, pLocale, 4091 if (localeValue.FormatPatterns(wsRet, wsPattern, pLocale,
4122 XFA_VALUEPICTURE_Display)) { 4092 XFA_VALUEPICTURE_Display)) {
4123 FXJSE_Value_SetUTF8String( 4093 args.GetReturnValue()->SetString(
4124 args.GetReturnValue(),
4125 FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()).AsStringC()); 4094 FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()).AsStringC());
4126 } else { 4095 } else {
4127 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); 4096 args.GetReturnValue()->SetString("");
4128 } 4097 }
4129 } else { 4098 } else {
4130 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Format"); 4099 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Format");
4131 } 4100 }
4132 } 4101 }
4133 4102
4134 // static 4103 // static
4135 void CXFA_FM2JSContext::Left(CFXJSE_Value* pThis, 4104 void CXFA_FM2JSContext::Left(CFXJSE_Value* pThis,
4136 const CFX_ByteStringC& szFuncName, 4105 const CFX_ByteStringC& szFuncName,
4137 CFXJSE_Arguments& args) { 4106 CFXJSE_Arguments& args) {
4138 if (args.GetLength() == 2) { 4107 if (args.GetLength() == 2) {
4139 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 4108 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
4140 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 4109 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
4141 FX_BOOL argIsNull = FALSE; 4110 FX_BOOL argIsNull = FALSE;
4142 if ((ValueIsNull(pThis, argOne.get())) || 4111 if ((ValueIsNull(pThis, argOne.get())) ||
4143 (ValueIsNull(pThis, argTwo.get()))) { 4112 (ValueIsNull(pThis, argTwo.get()))) {
4144 argIsNull = TRUE; 4113 argIsNull = TRUE;
4145 } 4114 }
4146 if (argIsNull) { 4115 if (argIsNull) {
4147 FXJSE_Value_SetNull(args.GetReturnValue()); 4116 args.GetReturnValue()->SetNull();
4148 } else { 4117 } else {
4149 CFX_ByteString sourceString; 4118 CFX_ByteString sourceString;
4150 ValueToUTF8String(argOne.get(), sourceString); 4119 ValueToUTF8String(argOne.get(), sourceString);
4151 int32_t count = ValueToInteger(pThis, argTwo.get()); 4120 int32_t count = ValueToInteger(pThis, argTwo.get());
4152 if (count < 0) { 4121 if (count < 0) {
4153 count = 0; 4122 count = 0;
4154 } 4123 }
4155 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 4124 args.GetReturnValue()->SetString(sourceString.Left(count).AsStringC());
4156 sourceString.Left(count).AsStringC());
4157 } 4125 }
4158 } else { 4126 } else {
4159 ToJSContext(pThis, nullptr) 4127 ToJSContext(pThis, nullptr)
4160 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Left"); 4128 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Left");
4161 } 4129 }
4162 } 4130 }
4163 4131
4164 // static 4132 // static
4165 void CXFA_FM2JSContext::Len(CFXJSE_Value* pThis, 4133 void CXFA_FM2JSContext::Len(CFXJSE_Value* pThis,
4166 const CFX_ByteStringC& szFuncName, 4134 const CFX_ByteStringC& szFuncName,
4167 CFXJSE_Arguments& args) { 4135 CFXJSE_Arguments& args) {
4168 if (args.GetLength() == 1) { 4136 if (args.GetLength() == 1) {
4169 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 4137 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
4170 if (ValueIsNull(pThis, argOne.get())) { 4138 if (ValueIsNull(pThis, argOne.get())) {
4171 FXJSE_Value_SetNull(args.GetReturnValue()); 4139 args.GetReturnValue()->SetNull();
4172 } else { 4140 } else {
4173 CFX_ByteString sourceString; 4141 CFX_ByteString sourceString;
4174 ValueToUTF8String(argOne.get(), sourceString); 4142 ValueToUTF8String(argOne.get(), sourceString);
4175 FXJSE_Value_SetInteger(args.GetReturnValue(), sourceString.GetLength()); 4143 args.GetReturnValue()->SetInteger(sourceString.GetLength());
4176 } 4144 }
4177 } else { 4145 } else {
4178 ToJSContext(pThis, nullptr) 4146 ToJSContext(pThis, nullptr)
4179 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Len"); 4147 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Len");
4180 } 4148 }
4181 } 4149 }
4182 4150
4183 // static 4151 // static
4184 void CXFA_FM2JSContext::Lower(CFXJSE_Value* pThis, 4152 void CXFA_FM2JSContext::Lower(CFXJSE_Value* pThis,
4185 const CFX_ByteStringC& szFuncName, 4153 const CFX_ByteStringC& szFuncName,
4186 CFXJSE_Arguments& args) { 4154 CFXJSE_Arguments& args) {
4187 int32_t argc = args.GetLength(); 4155 int32_t argc = args.GetLength();
4188 if ((argc > 0) && (argc < 3)) { 4156 if ((argc > 0) && (argc < 3)) {
4189 CFX_ByteString argString; 4157 CFX_ByteString argString;
4190 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 4158 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
4191 if (ValueIsNull(pThis, argOne.get())) { 4159 if (ValueIsNull(pThis, argOne.get())) {
4192 FXJSE_Value_SetNull(args.GetReturnValue()); 4160 args.GetReturnValue()->SetNull();
4193 } else { 4161 } else {
4194 ValueToUTF8String(argOne.get(), argString); 4162 ValueToUTF8String(argOne.get(), argString);
4195 CFX_WideTextBuf lowStringBuf; 4163 CFX_WideTextBuf lowStringBuf;
4196 CFX_WideString wsArgString = 4164 CFX_WideString wsArgString =
4197 CFX_WideString::FromUTF8(argString.AsStringC()); 4165 CFX_WideString::FromUTF8(argString.AsStringC());
4198 const FX_WCHAR* pData = wsArgString.c_str(); 4166 const FX_WCHAR* pData = wsArgString.c_str();
4199 int32_t iLen = argString.GetLength(); 4167 int32_t iLen = argString.GetLength();
4200 int32_t i = 0; 4168 int32_t i = 0;
4201 int32_t ch = 0; 4169 int32_t ch = 0;
4202 while (i < iLen) { 4170 while (i < iLen) {
4203 ch = pData[i]; 4171 ch = pData[i];
4204 if (ch >= 0x41 && ch <= 0x5A) { 4172 if (ch >= 0x41 && ch <= 0x5A) {
4205 ch += 32; 4173 ch += 32;
4206 } else if (ch >= 0xC0 && ch <= 0xDE) { 4174 } else if (ch >= 0xC0 && ch <= 0xDE) {
4207 ch += 32; 4175 ch += 32;
4208 } else if (ch == 0x100 || ch == 0x102 || ch == 0x104) { 4176 } else if (ch == 0x100 || ch == 0x102 || ch == 0x104) {
4209 ch += 1; 4177 ch += 1;
4210 } 4178 }
4211 lowStringBuf.AppendChar(ch); 4179 lowStringBuf.AppendChar(ch);
4212 ++i; 4180 ++i;
4213 } 4181 }
4214 lowStringBuf.AppendChar(0); 4182 lowStringBuf.AppendChar(0);
4215 FXJSE_Value_SetUTF8String( 4183 args.GetReturnValue()->SetString(
4216 args.GetReturnValue(),
4217 FX_UTF8Encode(lowStringBuf.GetBuffer(), lowStringBuf.GetLength()) 4184 FX_UTF8Encode(lowStringBuf.GetBuffer(), lowStringBuf.GetLength())
4218 .AsStringC()); 4185 .AsStringC());
4219 } 4186 }
4220 } else { 4187 } else {
4221 ToJSContext(pThis, nullptr) 4188 ToJSContext(pThis, nullptr)
4222 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Lower"); 4189 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Lower");
4223 } 4190 }
4224 } 4191 }
4225 4192
4226 // static 4193 // static
4227 void CXFA_FM2JSContext::Ltrim(CFXJSE_Value* pThis, 4194 void CXFA_FM2JSContext::Ltrim(CFXJSE_Value* pThis,
4228 const CFX_ByteStringC& szFuncName, 4195 const CFX_ByteStringC& szFuncName,
4229 CFXJSE_Arguments& args) { 4196 CFXJSE_Arguments& args) {
4230 if (args.GetLength() == 1) { 4197 if (args.GetLength() == 1) {
4231 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 4198 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
4232 if (ValueIsNull(pThis, argOne.get())) { 4199 if (ValueIsNull(pThis, argOne.get())) {
4233 FXJSE_Value_SetNull(args.GetReturnValue()); 4200 args.GetReturnValue()->SetNull();
4234 } else { 4201 } else {
4235 CFX_ByteString sourceString; 4202 CFX_ByteString sourceString;
4236 ValueToUTF8String(argOne.get(), sourceString); 4203 ValueToUTF8String(argOne.get(), sourceString);
4237 sourceString.TrimLeft(); 4204 sourceString.TrimLeft();
4238 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 4205 args.GetReturnValue()->SetString(sourceString.AsStringC());
4239 sourceString.AsStringC());
4240 } 4206 }
4241 } else { 4207 } else {
4242 ToJSContext(pThis, nullptr) 4208 ToJSContext(pThis, nullptr)
4243 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Ltrim"); 4209 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Ltrim");
4244 } 4210 }
4245 } 4211 }
4246 4212
4247 // static 4213 // static
4248 void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis, 4214 void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis,
4249 const CFX_ByteStringC& szFuncName, 4215 const CFX_ByteStringC& szFuncName,
4250 CFXJSE_Arguments& args) { 4216 CFXJSE_Arguments& args) {
4251 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 4217 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
4252 if (args.GetLength() == 2) { 4218 if (args.GetLength() == 2) {
4253 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 4219 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
4254 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 4220 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
4255 if (ValueIsNull(pThis, argTwo.get())) { 4221 if (ValueIsNull(pThis, argTwo.get())) {
4256 FXJSE_Value_SetNull(args.GetReturnValue()); 4222 args.GetReturnValue()->SetNull();
4257 } else { 4223 } else {
4258 CFX_ByteString szPattern; 4224 CFX_ByteString szPattern;
4259 ValueToUTF8String(argOne.get(), szPattern); 4225 ValueToUTF8String(argOne.get(), szPattern);
4260 CFX_ByteString szValue; 4226 CFX_ByteString szValue;
4261 ValueToUTF8String(argTwo.get(), szValue); 4227 ValueToUTF8String(argTwo.get(), szValue);
4262 CXFA_Document* pDoc = pContext->GetDocument(); 4228 CXFA_Document* pDoc = pContext->GetDocument();
4263 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); 4229 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr();
4264 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); 4230 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
4265 ASSERT(pThisNode); 4231 ASSERT(pThisNode);
4266 CXFA_WidgetData widgetData(pThisNode); 4232 CXFA_WidgetData widgetData(pThisNode);
4267 IFX_Locale* pLocale = widgetData.GetLocal(); 4233 IFX_Locale* pLocale = widgetData.GetLocal();
4268 uint32_t patternType; 4234 uint32_t patternType;
4269 CFX_WideString wsPattern = 4235 CFX_WideString wsPattern =
4270 CFX_WideString::FromUTF8(szPattern.AsStringC()); 4236 CFX_WideString::FromUTF8(szPattern.AsStringC());
4271 CFX_WideString wsValue = CFX_WideString::FromUTF8(szValue.AsStringC()); 4237 CFX_WideString wsValue = CFX_WideString::FromUTF8(szValue.AsStringC());
4272 CFX_ByteString szParsedValue; 4238 CFX_ByteString szParsedValue;
4273 if (PatternStringType(szPattern.AsStringC(), patternType)) { 4239 if (PatternStringType(szPattern.AsStringC(), patternType)) {
4274 CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, pLocale, 4240 CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, pLocale,
4275 (CXFA_LocaleMgr*)pMgr); 4241 (CXFA_LocaleMgr*)pMgr);
4276 if (localeValue.IsValid()) { 4242 if (localeValue.IsValid()) {
4277 szParsedValue = FX_UTF8Encode(localeValue.GetValue()); 4243 szParsedValue = FX_UTF8Encode(localeValue.GetValue());
4278 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 4244 args.GetReturnValue()->SetString(szParsedValue.AsStringC());
4279 szParsedValue.AsStringC());
4280 } else { 4245 } else {
4281 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); 4246 args.GetReturnValue()->SetString("");
4282 } 4247 }
4283 } else { 4248 } else {
4284 switch (patternType) { 4249 switch (patternType) {
4285 case XFA_VT_DATETIME: { 4250 case XFA_VT_DATETIME: {
4286 FX_STRSIZE iTChar = wsPattern.Find(L'T'); 4251 FX_STRSIZE iTChar = wsPattern.Find(L'T');
4287 CFX_WideString wsDatePattern(L"date{"); 4252 CFX_WideString wsDatePattern(L"date{");
4288 wsDatePattern += wsPattern.Left(iTChar); 4253 wsDatePattern += wsPattern.Left(iTChar);
4289 wsDatePattern += FX_WSTRC(L"} "); 4254 wsDatePattern += FX_WSTRC(L"} ");
4290 CFX_WideString wsTimePattern(L"time{"); 4255 CFX_WideString wsTimePattern(L"time{");
4291 wsTimePattern += wsPattern.Mid(iTChar + 1); 4256 wsTimePattern += wsPattern.Mid(iTChar + 1);
4292 wsTimePattern += FX_WSTRC(L"}"); 4257 wsTimePattern += FX_WSTRC(L"}");
4293 wsPattern = wsDatePattern + wsTimePattern; 4258 wsPattern = wsDatePattern + wsTimePattern;
4294 CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, 4259 CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern,
4295 pLocale, (CXFA_LocaleMgr*)pMgr); 4260 pLocale, (CXFA_LocaleMgr*)pMgr);
4296 if (localeValue.IsValid()) { 4261 if (localeValue.IsValid()) {
4297 szParsedValue = FX_UTF8Encode(localeValue.GetValue()); 4262 szParsedValue = FX_UTF8Encode(localeValue.GetValue());
4298 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 4263 args.GetReturnValue()->SetString(szParsedValue.AsStringC());
4299 szParsedValue.AsStringC());
4300 } else { 4264 } else {
4301 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); 4265 args.GetReturnValue()->SetString("");
4302 } 4266 }
4303 } break; 4267 } break;
4304 case XFA_VT_DATE: { 4268 case XFA_VT_DATE: {
4305 wsPattern = FX_WSTRC(L"date{") + wsPattern; 4269 wsPattern = FX_WSTRC(L"date{") + wsPattern;
4306 wsPattern += FX_WSTRC(L"}"); 4270 wsPattern += FX_WSTRC(L"}");
4307 CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, 4271 CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern,
4308 pLocale, (CXFA_LocaleMgr*)pMgr); 4272 pLocale, (CXFA_LocaleMgr*)pMgr);
4309 if (localeValue.IsValid()) { 4273 if (localeValue.IsValid()) {
4310 szParsedValue = FX_UTF8Encode(localeValue.GetValue()); 4274 szParsedValue = FX_UTF8Encode(localeValue.GetValue());
4311 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 4275 args.GetReturnValue()->SetString(szParsedValue.AsStringC());
4312 szParsedValue.AsStringC());
4313 } else { 4276 } else {
4314 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); 4277 args.GetReturnValue()->SetString("");
4315 } 4278 }
4316 } break; 4279 } break;
4317 case XFA_VT_TIME: { 4280 case XFA_VT_TIME: {
4318 wsPattern = FX_WSTRC(L"time{") + wsPattern; 4281 wsPattern = FX_WSTRC(L"time{") + wsPattern;
4319 wsPattern += FX_WSTRC(L"}"); 4282 wsPattern += FX_WSTRC(L"}");
4320 CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, 4283 CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern,
4321 pLocale, (CXFA_LocaleMgr*)pMgr); 4284 pLocale, (CXFA_LocaleMgr*)pMgr);
4322 if (localeValue.IsValid()) { 4285 if (localeValue.IsValid()) {
4323 szParsedValue = FX_UTF8Encode(localeValue.GetValue()); 4286 szParsedValue = FX_UTF8Encode(localeValue.GetValue());
4324 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 4287 args.GetReturnValue()->SetString(szParsedValue.AsStringC());
4325 szParsedValue.AsStringC());
4326 } else { 4288 } else {
4327 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); 4289 args.GetReturnValue()->SetString("");
4328 } 4290 }
4329 } break; 4291 } break;
4330 case XFA_VT_TEXT: { 4292 case XFA_VT_TEXT: {
4331 wsPattern = FX_WSTRC(L"text{") + wsPattern; 4293 wsPattern = FX_WSTRC(L"text{") + wsPattern;
4332 wsPattern += FX_WSTRC(L"}"); 4294 wsPattern += FX_WSTRC(L"}");
4333 CXFA_LocaleValue localeValue(XFA_VT_TEXT, wsValue, wsPattern, 4295 CXFA_LocaleValue localeValue(XFA_VT_TEXT, wsValue, wsPattern,
4334 pLocale, (CXFA_LocaleMgr*)pMgr); 4296 pLocale, (CXFA_LocaleMgr*)pMgr);
4335 if (localeValue.IsValid()) { 4297 if (localeValue.IsValid()) {
4336 szParsedValue = FX_UTF8Encode(localeValue.GetValue()); 4298 szParsedValue = FX_UTF8Encode(localeValue.GetValue());
4337 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 4299 args.GetReturnValue()->SetString(szParsedValue.AsStringC());
4338 szParsedValue.AsStringC());
4339 } else { 4300 } else {
4340 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); 4301 args.GetReturnValue()->SetString("");
4341 } 4302 }
4342 } break; 4303 } break;
4343 case XFA_VT_FLOAT: { 4304 case XFA_VT_FLOAT: {
4344 wsPattern = FX_WSTRC(L"num{") + wsPattern; 4305 wsPattern = FX_WSTRC(L"num{") + wsPattern;
4345 wsPattern += FX_WSTRC(L"}"); 4306 wsPattern += FX_WSTRC(L"}");
4346 CXFA_LocaleValue localeValue(XFA_VT_FLOAT, wsValue, wsPattern, 4307 CXFA_LocaleValue localeValue(XFA_VT_FLOAT, wsValue, wsPattern,
4347 pLocale, (CXFA_LocaleMgr*)pMgr); 4308 pLocale, (CXFA_LocaleMgr*)pMgr);
4348 if (localeValue.IsValid()) { 4309 if (localeValue.IsValid()) {
4349 FXJSE_Value_SetDouble(args.GetReturnValue(), 4310 args.GetReturnValue()->SetDouble(localeValue.GetDoubleNum());
4350 localeValue.GetDoubleNum());
4351 } else { 4311 } else {
4352 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); 4312 args.GetReturnValue()->SetString("");
4353 } 4313 }
4354 } break; 4314 } break;
4355 default: { 4315 default: {
4356 CFX_WideString wsTestPattern; 4316 CFX_WideString wsTestPattern;
4357 wsTestPattern = FX_WSTRC(L"num{") + wsPattern; 4317 wsTestPattern = FX_WSTRC(L"num{") + wsPattern;
4358 wsTestPattern += FX_WSTRC(L"}"); 4318 wsTestPattern += FX_WSTRC(L"}");
4359 CXFA_LocaleValue localeValue(XFA_VT_FLOAT, wsValue, wsTestPattern, 4319 CXFA_LocaleValue localeValue(XFA_VT_FLOAT, wsValue, wsTestPattern,
4360 pLocale, (CXFA_LocaleMgr*)pMgr); 4320 pLocale, (CXFA_LocaleMgr*)pMgr);
4361 if (localeValue.IsValid()) { 4321 if (localeValue.IsValid()) {
4362 FXJSE_Value_SetDouble(args.GetReturnValue(), 4322 args.GetReturnValue()->SetDouble(localeValue.GetDoubleNum());
4363 localeValue.GetDoubleNum());
4364 } else { 4323 } else {
4365 wsTestPattern = FX_WSTRC(L"text{") + wsPattern; 4324 wsTestPattern = FX_WSTRC(L"text{") + wsPattern;
4366 wsTestPattern += FX_WSTRC(L"}"); 4325 wsTestPattern += FX_WSTRC(L"}");
4367 CXFA_LocaleValue localeValue2(XFA_VT_TEXT, wsValue, wsTestPattern, 4326 CXFA_LocaleValue localeValue2(XFA_VT_TEXT, wsValue, wsTestPattern,
4368 pLocale, (CXFA_LocaleMgr*)pMgr); 4327 pLocale, (CXFA_LocaleMgr*)pMgr);
4369 if (localeValue2.IsValid()) { 4328 if (localeValue2.IsValid()) {
4370 szParsedValue = FX_UTF8Encode(localeValue2.GetValue()); 4329 szParsedValue = FX_UTF8Encode(localeValue2.GetValue());
4371 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 4330 args.GetReturnValue()->SetString(szParsedValue.AsStringC());
4372 szParsedValue.AsStringC());
4373 } else { 4331 } else {
4374 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); 4332 args.GetReturnValue()->SetString("");
4375 } 4333 }
4376 } 4334 }
4377 } break; 4335 } break;
4378 } 4336 }
4379 } 4337 }
4380 } 4338 }
4381 } else { 4339 } else {
4382 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Parse"); 4340 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Parse");
4383 } 4341 }
4384 } 4342 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
4429 u += iFindLen - 1; 4387 u += iFindLen - 1;
4430 iFindIndex = 0; 4388 iFindIndex = 0;
4431 } else { 4389 } else {
4432 resultString.AppendChar(ch); 4390 resultString.AppendChar(ch);
4433 } 4391 }
4434 } else { 4392 } else {
4435 resultString.AppendChar(ch); 4393 resultString.AppendChar(ch);
4436 } 4394 }
4437 } 4395 }
4438 resultString.AppendChar(0); 4396 resultString.AppendChar(0);
4439 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); 4397 args.GetReturnValue()->SetString(resultString.AsStringC());
4440 } else { 4398 } else {
4441 ToJSContext(pThis, nullptr) 4399 ToJSContext(pThis, nullptr)
4442 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Replace"); 4400 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Replace");
4443 } 4401 }
4444 } 4402 }
4445 4403
4446 // static 4404 // static
4447 void CXFA_FM2JSContext::Right(CFXJSE_Value* pThis, 4405 void CXFA_FM2JSContext::Right(CFXJSE_Value* pThis,
4448 const CFX_ByteStringC& szFuncName, 4406 const CFX_ByteStringC& szFuncName,
4449 CFXJSE_Arguments& args) { 4407 CFXJSE_Arguments& args) {
4450 if (args.GetLength() == 2) { 4408 if (args.GetLength() == 2) {
4451 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 4409 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
4452 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); 4410 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1);
4453 FX_BOOL argIsNull = FALSE; 4411 FX_BOOL argIsNull = FALSE;
4454 if ((ValueIsNull(pThis, argOne.get())) || 4412 if ((ValueIsNull(pThis, argOne.get())) ||
4455 (ValueIsNull(pThis, argTwo.get()))) { 4413 (ValueIsNull(pThis, argTwo.get()))) {
4456 argIsNull = TRUE; 4414 argIsNull = TRUE;
4457 } 4415 }
4458 if (argIsNull) { 4416 if (argIsNull) {
4459 FXJSE_Value_SetNull(args.GetReturnValue()); 4417 args.GetReturnValue()->SetNull();
4460 } else { 4418 } else {
4461 CFX_ByteString sourceString; 4419 CFX_ByteString sourceString;
4462 ValueToUTF8String(argOne.get(), sourceString); 4420 ValueToUTF8String(argOne.get(), sourceString);
4463 int32_t count = ValueToInteger(pThis, argTwo.get()); 4421 int32_t count = ValueToInteger(pThis, argTwo.get());
4464 if (count < 0) { 4422 if (count < 0) {
4465 count = 0; 4423 count = 0;
4466 } 4424 }
4467 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 4425 args.GetReturnValue()->SetString(sourceString.Right(count).AsStringC());
4468 sourceString.Right(count).AsStringC());
4469 } 4426 }
4470 } else { 4427 } else {
4471 ToJSContext(pThis, nullptr) 4428 ToJSContext(pThis, nullptr)
4472 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Right"); 4429 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Right");
4473 } 4430 }
4474 } 4431 }
4475 4432
4476 // static 4433 // static
4477 void CXFA_FM2JSContext::Rtrim(CFXJSE_Value* pThis, 4434 void CXFA_FM2JSContext::Rtrim(CFXJSE_Value* pThis,
4478 const CFX_ByteStringC& szFuncName, 4435 const CFX_ByteStringC& szFuncName,
4479 CFXJSE_Arguments& args) { 4436 CFXJSE_Arguments& args) {
4480 if (args.GetLength() == 1) { 4437 if (args.GetLength() == 1) {
4481 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 4438 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
4482 if (ValueIsNull(pThis, argOne.get())) { 4439 if (ValueIsNull(pThis, argOne.get())) {
4483 FXJSE_Value_SetNull(args.GetReturnValue()); 4440 args.GetReturnValue()->SetNull();
4484 } else { 4441 } else {
4485 CFX_ByteString sourceString; 4442 CFX_ByteString sourceString;
4486 ValueToUTF8String(argOne.get(), sourceString); 4443 ValueToUTF8String(argOne.get(), sourceString);
4487 sourceString.TrimRight(); 4444 sourceString.TrimRight();
4488 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 4445 args.GetReturnValue()->SetString(sourceString.AsStringC());
4489 sourceString.AsStringC());
4490 } 4446 }
4491 } else { 4447 } else {
4492 ToJSContext(pThis, nullptr) 4448 ToJSContext(pThis, nullptr)
4493 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Rtrim"); 4449 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Rtrim");
4494 } 4450 }
4495 } 4451 }
4496 4452
4497 // static 4453 // static
4498 void CXFA_FM2JSContext::Space(CFXJSE_Value* pThis, 4454 void CXFA_FM2JSContext::Space(CFXJSE_Value* pThis,
4499 const CFX_ByteStringC& szFuncName, 4455 const CFX_ByteStringC& szFuncName,
4500 CFXJSE_Arguments& args) { 4456 CFXJSE_Arguments& args) {
4501 if (args.GetLength() == 1) { 4457 if (args.GetLength() == 1) {
4502 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 4458 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
4503 if (FXJSE_Value_IsNull(argOne.get())) { 4459 if (FXJSE_Value_IsNull(argOne.get())) {
4504 FXJSE_Value_SetNull(args.GetReturnValue()); 4460 args.GetReturnValue()->SetNull();
4505 } else { 4461 } else {
4506 int32_t count = 0; 4462 int32_t count = 0;
4507 count = ValueToInteger(pThis, argOne.get()); 4463 count = ValueToInteger(pThis, argOne.get());
4508 count = (count < 0) ? 0 : count; 4464 count = (count < 0) ? 0 : count;
4509 CFX_ByteTextBuf spaceString; 4465 CFX_ByteTextBuf spaceString;
4510 int32_t index = 0; 4466 int32_t index = 0;
4511 while (index < count) { 4467 while (index < count) {
4512 spaceString.AppendByte(' '); 4468 spaceString.AppendByte(' ');
4513 index++; 4469 index++;
4514 } 4470 }
4515 spaceString.AppendByte(0); 4471 spaceString.AppendByte(0);
4516 FXJSE_Value_SetUTF8String(args.GetReturnValue(), spaceString.AsStringC()); 4472 args.GetReturnValue()->SetString(spaceString.AsStringC());
4517 } 4473 }
4518 } else { 4474 } else {
4519 ToJSContext(pThis, nullptr) 4475 ToJSContext(pThis, nullptr)
4520 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Space"); 4476 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Space");
4521 } 4477 }
4522 } 4478 }
4523 4479
4524 // static 4480 // static
4525 void CXFA_FM2JSContext::Str(CFXJSE_Value* pThis, 4481 void CXFA_FM2JSContext::Str(CFXJSE_Value* pThis,
4526 const CFX_ByteStringC& szFuncName, 4482 const CFX_ByteStringC& szFuncName,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
4622 ++i; 4578 ++i;
4623 ++u; 4579 ++u;
4624 } 4580 }
4625 while (i < iPrecision) { 4581 while (i < iPrecision) {
4626 resultBuf.AppendChar('0'); 4582 resultBuf.AppendChar('0');
4627 ++i; 4583 ++i;
4628 } 4584 }
4629 resultBuf.AppendChar(0); 4585 resultBuf.AppendChar(0);
4630 } 4586 }
4631 } 4587 }
4632 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); 4588 args.GetReturnValue()->SetString(resultBuf.AsStringC());
4633 } else { 4589 } else {
4634 FXJSE_Value_SetNull(args.GetReturnValue()); 4590 args.GetReturnValue()->SetNull();
4635 } 4591 }
4636 } else { 4592 } else {
4637 ToJSContext(pThis, nullptr) 4593 ToJSContext(pThis, nullptr)
4638 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Str"); 4594 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Str");
4639 } 4595 }
4640 } 4596 }
4641 4597
4642 // static 4598 // static
4643 void CXFA_FM2JSContext::Stuff(CFXJSE_Value* pThis, 4599 void CXFA_FM2JSContext::Stuff(CFXJSE_Value* pThis,
4644 const CFX_ByteStringC& szFuncName, 4600 const CFX_ByteStringC& szFuncName,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
4682 resultString.AppendChar(sourceString.GetAt(i)); 4638 resultString.AppendChar(sourceString.GetAt(i));
4683 ++i; 4639 ++i;
4684 } 4640 }
4685 resultString << insertString.AsStringC(); 4641 resultString << insertString.AsStringC();
4686 i = iStart + iDelete; 4642 i = iStart + iDelete;
4687 while (i < iLength) { 4643 while (i < iLength) {
4688 resultString.AppendChar(sourceString.GetAt(i)); 4644 resultString.AppendChar(sourceString.GetAt(i));
4689 ++i; 4645 ++i;
4690 } 4646 }
4691 resultString.AppendChar(0); 4647 resultString.AppendChar(0);
4692 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); 4648 args.GetReturnValue()->SetString(resultString.AsStringC());
4693 } else { 4649 } else {
4694 ToJSContext(pThis, nullptr) 4650 ToJSContext(pThis, nullptr)
4695 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Stuff"); 4651 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Stuff");
4696 } 4652 }
4697 } 4653 }
4698 4654
4699 // static 4655 // static
4700 void CXFA_FM2JSContext::Substr(CFXJSE_Value* pThis, 4656 void CXFA_FM2JSContext::Substr(CFXJSE_Value* pThis,
4701 const CFX_ByteStringC& szFuncName, 4657 const CFX_ByteStringC& szFuncName,
4702 CFXJSE_Arguments& args) { 4658 CFXJSE_Arguments& args) {
4703 if (args.GetLength() == 3) { 4659 if (args.GetLength() == 3) {
4704 std::unique_ptr<CFXJSE_Value> stringValue = GetSimpleValue(pThis, args, 0); 4660 std::unique_ptr<CFXJSE_Value> stringValue = GetSimpleValue(pThis, args, 0);
4705 std::unique_ptr<CFXJSE_Value> startValue = GetSimpleValue(pThis, args, 1); 4661 std::unique_ptr<CFXJSE_Value> startValue = GetSimpleValue(pThis, args, 1);
4706 std::unique_ptr<CFXJSE_Value> endValue = GetSimpleValue(pThis, args, 2); 4662 std::unique_ptr<CFXJSE_Value> endValue = GetSimpleValue(pThis, args, 2);
4707 if (ValueIsNull(pThis, stringValue.get()) || 4663 if (ValueIsNull(pThis, stringValue.get()) ||
4708 (ValueIsNull(pThis, startValue.get())) || 4664 (ValueIsNull(pThis, startValue.get())) ||
4709 (ValueIsNull(pThis, endValue.get()))) { 4665 (ValueIsNull(pThis, endValue.get()))) {
4710 FXJSE_Value_SetNull(args.GetReturnValue()); 4666 args.GetReturnValue()->SetNull();
4711 } else { 4667 } else {
4712 CFX_ByteString szSourceStr; 4668 CFX_ByteString szSourceStr;
4713 int32_t iStart = 0; 4669 int32_t iStart = 0;
4714 int32_t iCount = 0; 4670 int32_t iCount = 0;
4715 ValueToUTF8String(stringValue.get(), szSourceStr); 4671 ValueToUTF8String(stringValue.get(), szSourceStr);
4716 int32_t iLength = szSourceStr.GetLength(); 4672 int32_t iLength = szSourceStr.GetLength();
4717 if (iLength == 0) { 4673 if (iLength == 0) {
4718 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); 4674 args.GetReturnValue()->SetString("");
4719 } else { 4675 } else {
4720 iStart = (int32_t)ValueToFloat(pThis, startValue.get()); 4676 iStart = (int32_t)ValueToFloat(pThis, startValue.get());
4721 iCount = (int32_t)ValueToFloat(pThis, endValue.get()); 4677 iCount = (int32_t)ValueToFloat(pThis, endValue.get());
4722 if (iStart < 1) { 4678 if (iStart < 1) {
4723 iStart = 1; 4679 iStart = 1;
4724 } 4680 }
4725 if (iStart > iLength) { 4681 if (iStart > iLength) {
4726 iStart = iLength; 4682 iStart = iLength;
4727 } 4683 }
4728 if (iCount <= 0) { 4684 if (iCount <= 0) {
4729 iCount = 0; 4685 iCount = 0;
4730 } 4686 }
4731 iStart -= 1; 4687 iStart -= 1;
4732 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 4688 args.GetReturnValue()->SetString(
4733 szSourceStr.Mid(iStart, iCount).AsStringC()); 4689 szSourceStr.Mid(iStart, iCount).AsStringC());
4734 } 4690 }
4735 } 4691 }
4736 } else { 4692 } else {
4737 ToJSContext(pThis, nullptr) 4693 ToJSContext(pThis, nullptr)
4738 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Substr"); 4694 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Substr");
4739 } 4695 }
4740 } 4696 }
4741 4697
4742 // static 4698 // static
4743 void CXFA_FM2JSContext::Uuid(CFXJSE_Value* pThis, 4699 void CXFA_FM2JSContext::Uuid(CFXJSE_Value* pThis,
4744 const CFX_ByteStringC& szFuncName, 4700 const CFX_ByteStringC& szFuncName,
4745 CFXJSE_Arguments& args) { 4701 CFXJSE_Arguments& args) {
4746 int32_t argc = args.GetLength(); 4702 int32_t argc = args.GetLength();
4747 if ((argc == 0) || (argc == 1)) { 4703 if ((argc == 0) || (argc == 1)) {
4748 int32_t iNum = 0; 4704 int32_t iNum = 0;
4749 if (argc > 0) { 4705 if (argc > 0) {
4750 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 4706 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
4751 iNum = (int32_t)ValueToFloat(pThis, argOne.get()); 4707 iNum = (int32_t)ValueToFloat(pThis, argOne.get());
4752 } 4708 }
4753 FX_GUID guid; 4709 FX_GUID guid;
4754 FX_GUID_CreateV4(&guid); 4710 FX_GUID_CreateV4(&guid);
4755 CFX_ByteString bsUId; 4711 CFX_ByteString bsUId;
4756 FX_GUID_ToString(&guid, bsUId, iNum); 4712 FX_GUID_ToString(&guid, bsUId, iNum);
4757 FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsUId.AsStringC()); 4713 args.GetReturnValue()->SetString(bsUId.AsStringC());
4758 } else { 4714 } else {
4759 ToJSContext(pThis, nullptr) 4715 ToJSContext(pThis, nullptr)
4760 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Uuid"); 4716 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Uuid");
4761 } 4717 }
4762 } 4718 }
4763 4719
4764 // static 4720 // static
4765 void CXFA_FM2JSContext::Upper(CFXJSE_Value* pThis, 4721 void CXFA_FM2JSContext::Upper(CFXJSE_Value* pThis,
4766 const CFX_ByteStringC& szFuncName, 4722 const CFX_ByteStringC& szFuncName,
4767 CFXJSE_Arguments& args) { 4723 CFXJSE_Arguments& args) {
4768 int32_t argc = args.GetLength(); 4724 int32_t argc = args.GetLength();
4769 if ((argc > 0) && (argc < 3)) { 4725 if ((argc > 0) && (argc < 3)) {
4770 CFX_ByteString argString; 4726 CFX_ByteString argString;
4771 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 4727 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
4772 if (ValueIsNull(pThis, argOne.get())) { 4728 if (ValueIsNull(pThis, argOne.get())) {
4773 FXJSE_Value_SetNull(args.GetReturnValue()); 4729 args.GetReturnValue()->SetNull();
4774 } else { 4730 } else {
4775 ValueToUTF8String(argOne.get(), argString); 4731 ValueToUTF8String(argOne.get(), argString);
4776 CFX_WideTextBuf upperStringBuf; 4732 CFX_WideTextBuf upperStringBuf;
4777 CFX_WideString wsArgString = 4733 CFX_WideString wsArgString =
4778 CFX_WideString::FromUTF8(argString.AsStringC()); 4734 CFX_WideString::FromUTF8(argString.AsStringC());
4779 const FX_WCHAR* pData = wsArgString.c_str(); 4735 const FX_WCHAR* pData = wsArgString.c_str();
4780 int32_t iLen = wsArgString.GetLength(); 4736 int32_t iLen = wsArgString.GetLength();
4781 int32_t i = 0; 4737 int32_t i = 0;
4782 int32_t ch = 0; 4738 int32_t ch = 0;
4783 while (i < iLen) { 4739 while (i < iLen) {
4784 ch = pData[i]; 4740 ch = pData[i];
4785 if (ch >= 0x61 && ch <= 0x7A) { 4741 if (ch >= 0x61 && ch <= 0x7A) {
4786 ch -= 32; 4742 ch -= 32;
4787 } else if (ch >= 0xE0 && ch <= 0xFE) { 4743 } else if (ch >= 0xE0 && ch <= 0xFE) {
4788 ch -= 32; 4744 ch -= 32;
4789 } else if (ch == 0x101 || ch == 0x103 || ch == 0x105) { 4745 } else if (ch == 0x101 || ch == 0x103 || ch == 0x105) {
4790 ch -= 1; 4746 ch -= 1;
4791 } 4747 }
4792 upperStringBuf.AppendChar(ch); 4748 upperStringBuf.AppendChar(ch);
4793 ++i; 4749 ++i;
4794 } 4750 }
4795 upperStringBuf.AppendChar(0); 4751 upperStringBuf.AppendChar(0);
4796 FXJSE_Value_SetUTF8String( 4752 args.GetReturnValue()->SetString(
4797 args.GetReturnValue(),
4798 FX_UTF8Encode(upperStringBuf.GetBuffer(), upperStringBuf.GetLength()) 4753 FX_UTF8Encode(upperStringBuf.GetBuffer(), upperStringBuf.GetLength())
4799 .AsStringC()); 4754 .AsStringC());
4800 } 4755 }
4801 } else { 4756 } else {
4802 ToJSContext(pThis, nullptr) 4757 ToJSContext(pThis, nullptr)
4803 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Upper"); 4758 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Upper");
4804 } 4759 }
4805 } 4760 }
4806 4761
4807 // static 4762 // static
(...skipping 25 matching lines...) Expand all
4833 std::unique_ptr<CFXJSE_Value> localeValue = 4788 std::unique_ptr<CFXJSE_Value> localeValue =
4834 GetSimpleValue(pThis, args, 2); 4789 GetSimpleValue(pThis, args, 2);
4835 if (FXJSE_Value_IsNull(localeValue.get())) { 4790 if (FXJSE_Value_IsNull(localeValue.get())) {
4836 bFlags = TRUE; 4791 bFlags = TRUE;
4837 } else { 4792 } else {
4838 ValueToUTF8String(localeValue.get(), localeString); 4793 ValueToUTF8String(localeValue.get(), localeString);
4839 } 4794 }
4840 } 4795 }
4841 if (!bFlags) { 4796 if (!bFlags) {
4842 if ((fNumber < 0) || (fNumber > 922337203685477550)) { 4797 if ((fNumber < 0) || (fNumber > 922337203685477550)) {
4843 FXJSE_Value_SetUTF8String(args.GetReturnValue(), "*"); 4798 args.GetReturnValue()->SetString("*");
4844 } else { 4799 } else {
4845 CFX_ByteTextBuf resultBuf; 4800 CFX_ByteTextBuf resultBuf;
4846 CFX_ByteString numberString; 4801 CFX_ByteString numberString;
4847 numberString.Format("%.2f", fNumber); 4802 numberString.Format("%.2f", fNumber);
4848 WordUS(numberString.AsStringC(), iIdentifier, resultBuf); 4803 WordUS(numberString.AsStringC(), iIdentifier, resultBuf);
4849 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); 4804 args.GetReturnValue()->SetString(resultBuf.AsStringC());
4850 } 4805 }
4851 } else { 4806 } else {
4852 FXJSE_Value_SetNull(args.GetReturnValue()); 4807 args.GetReturnValue()->SetNull();
4853 } 4808 }
4854 } else { 4809 } else {
4855 ToJSContext(pThis, nullptr) 4810 ToJSContext(pThis, nullptr)
4856 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"WordNum"); 4811 ->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"WordNum");
4857 } 4812 }
4858 } 4813 }
4859 4814
4860 // static 4815 // static
4861 void CXFA_FM2JSContext::TrillionUS(const CFX_ByteStringC& szData, 4816 void CXFA_FM2JSContext::TrillionUS(const CFX_ByteStringC& szData,
4862 CFX_ByteTextBuf& strBuf) { 4817 CFX_ByteTextBuf& strBuf) {
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
5071 } 5026 }
5072 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 5027 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
5073 CFX_ByteString urlString; 5028 CFX_ByteString urlString;
5074 ValueToUTF8String(argOne.get(), urlString); 5029 ValueToUTF8String(argOne.get(), urlString);
5075 IFX_FileRead* pFile = pAppProvider->DownloadURL( 5030 IFX_FileRead* pFile = pAppProvider->DownloadURL(
5076 CFX_WideString::FromUTF8(urlString.AsStringC())); 5031 CFX_WideString::FromUTF8(urlString.AsStringC()));
5077 if (pFile) { 5032 if (pFile) {
5078 int32_t size = pFile->GetSize(); 5033 int32_t size = pFile->GetSize();
5079 uint8_t* pData = FX_Alloc(uint8_t, size); 5034 uint8_t* pData = FX_Alloc(uint8_t, size);
5080 pFile->ReadBlock(pData, size); 5035 pFile->ReadBlock(pData, size);
5081 FXJSE_Value_SetUTF8String(args.GetReturnValue(), 5036 args.GetReturnValue()->SetString(CFX_ByteStringC(pData, size));
5082 CFX_ByteStringC(pData, size));
5083 FX_Free(pData); 5037 FX_Free(pData);
5084 pFile->Release(); 5038 pFile->Release();
5085 } 5039 }
5086 } else { 5040 } else {
5087 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Get"); 5041 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Get");
5088 } 5042 }
5089 } 5043 }
5090 5044
5091 // static 5045 // static
5092 void CXFA_FM2JSContext::Post(CFXJSE_Value* pThis, 5046 void CXFA_FM2JSContext::Post(CFXJSE_Value* pThis,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
5126 ValueToUTF8String(argFive.get(), bsHeader); 5080 ValueToUTF8String(argFive.get(), bsHeader);
5127 } 5081 }
5128 CFX_WideString decodedResponse; 5082 CFX_WideString decodedResponse;
5129 FX_BOOL bFlags = pAppProvider->PostRequestURL( 5083 FX_BOOL bFlags = pAppProvider->PostRequestURL(
5130 CFX_WideString::FromUTF8(bsURL.AsStringC()), 5084 CFX_WideString::FromUTF8(bsURL.AsStringC()),
5131 CFX_WideString::FromUTF8(bsData.AsStringC()), 5085 CFX_WideString::FromUTF8(bsData.AsStringC()),
5132 CFX_WideString::FromUTF8(bsContentType.AsStringC()), 5086 CFX_WideString::FromUTF8(bsContentType.AsStringC()),
5133 CFX_WideString::FromUTF8(bsEncode.AsStringC()), 5087 CFX_WideString::FromUTF8(bsEncode.AsStringC()),
5134 CFX_WideString::FromUTF8(bsHeader.AsStringC()), decodedResponse); 5088 CFX_WideString::FromUTF8(bsHeader.AsStringC()), decodedResponse);
5135 if (bFlags) { 5089 if (bFlags) {
5136 FXJSE_Value_SetUTF8String( 5090 args.GetReturnValue()->SetString(
5137 args.GetReturnValue(),
5138 FX_UTF8Encode(decodedResponse.c_str(), decodedResponse.GetLength()) 5091 FX_UTF8Encode(decodedResponse.c_str(), decodedResponse.GetLength())
5139 .AsStringC()); 5092 .AsStringC());
5140 } else { 5093 } else {
5141 pContext->ThrowException(XFA_IDS_SERVER_DENY); 5094 pContext->ThrowException(XFA_IDS_SERVER_DENY);
5142 } 5095 }
5143 } else { 5096 } else {
5144 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Post"); 5097 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Post");
5145 } 5098 }
5146 } 5099 }
5147 5100
(...skipping 22 matching lines...) Expand all
5170 ValueToUTF8String(argTwo.get(), bsData); 5123 ValueToUTF8String(argTwo.get(), bsData);
5171 if (argc > 2) { 5124 if (argc > 2) {
5172 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); 5125 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2);
5173 ValueToUTF8String(argThree.get(), bsEncode); 5126 ValueToUTF8String(argThree.get(), bsEncode);
5174 } 5127 }
5175 FX_BOOL bFlags = pAppProvider->PutRequestURL( 5128 FX_BOOL bFlags = pAppProvider->PutRequestURL(
5176 CFX_WideString::FromUTF8(bsURL.AsStringC()), 5129 CFX_WideString::FromUTF8(bsURL.AsStringC()),
5177 CFX_WideString::FromUTF8(bsData.AsStringC()), 5130 CFX_WideString::FromUTF8(bsData.AsStringC()),
5178 CFX_WideString::FromUTF8(bsEncode.AsStringC())); 5131 CFX_WideString::FromUTF8(bsEncode.AsStringC()));
5179 if (bFlags) { 5132 if (bFlags) {
5180 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); 5133 args.GetReturnValue()->SetString("");
5181 } else { 5134 } else {
5182 pContext->ThrowException(XFA_IDS_SERVER_DENY); 5135 pContext->ThrowException(XFA_IDS_SERVER_DENY);
5183 } 5136 }
5184 } else { 5137 } else {
5185 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Put"); 5138 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Put");
5186 } 5139 }
5187 } 5140 }
5188 5141
5189 // static 5142 // static
5190 void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis, 5143 void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis,
5191 const CFX_ByteStringC& szFuncName, 5144 const CFX_ByteStringC& szFuncName,
5192 CFXJSE_Arguments& args) { 5145 CFXJSE_Arguments& args) {
5193 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 5146 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
5194 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 5147 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
5195 if (args.GetLength() == 2) { 5148 if (args.GetLength() == 2) {
5196 std::unique_ptr<CFXJSE_Value> lValue = args.GetValue(0); 5149 std::unique_ptr<CFXJSE_Value> lValue = args.GetValue(0);
5197 std::unique_ptr<CFXJSE_Value> rValue = GetSimpleValue(pThis, args, 1); 5150 std::unique_ptr<CFXJSE_Value> rValue = GetSimpleValue(pThis, args, 1);
5198 FX_BOOL bSetStatus = TRUE; 5151 FX_BOOL bSetStatus = TRUE;
5199 if (FXJSE_Value_IsArray(lValue.get())) { 5152 if (FXJSE_Value_IsArray(lValue.get())) {
5200 std::unique_ptr<CFXJSE_Value> leftLengthValue(new CFXJSE_Value(pIsolate)); 5153 std::unique_ptr<CFXJSE_Value> leftLengthValue(new CFXJSE_Value(pIsolate));
5201 FXJSE_Value_GetObjectProp(lValue.get(), "length", leftLengthValue.get()); 5154 lValue->GetObjectProperty("length", leftLengthValue.get());
5202 int32_t iLeftLength = FXJSE_Value_ToInteger(leftLengthValue.get()); 5155 int32_t iLeftLength = leftLengthValue->ToInteger();
5203 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 5156 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
5204 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 5157 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
5205 FXJSE_Value_GetObjectPropByIdx(lValue.get(), 1, propertyValue.get()); 5158 lValue->GetObjectPropertyByIdx(1, propertyValue.get());
5206 if (FXJSE_Value_IsNull(propertyValue.get())) { 5159 if (FXJSE_Value_IsNull(propertyValue.get())) {
5207 for (int32_t i = 2; i < iLeftLength; i++) { 5160 for (int32_t i = 2; i < iLeftLength; i++) {
5208 FXJSE_Value_GetObjectPropByIdx(lValue.get(), i, jsObjectValue.get()); 5161 lValue->GetObjectPropertyByIdx(i, jsObjectValue.get());
5209 bSetStatus = SetObjectDefaultValue(jsObjectValue.get(), rValue.get()); 5162 bSetStatus = SetObjectDefaultValue(jsObjectValue.get(), rValue.get());
5210 if (!bSetStatus) { 5163 if (!bSetStatus) {
5211 pContext->ThrowException(XFA_IDS_NOT_DEFAUL_VALUE); 5164 pContext->ThrowException(XFA_IDS_NOT_DEFAUL_VALUE);
5212 break; 5165 break;
5213 } 5166 }
5214 } 5167 }
5215 } else { 5168 } else {
5216 CFX_ByteString propertyStr; 5169 CFX_ByteString propertyStr;
5217 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); 5170 propertyValue->ToString(propertyStr);
5218 for (int32_t i = 2; i < iLeftLength; i++) { 5171 for (int32_t i = 2; i < iLeftLength; i++) {
5219 FXJSE_Value_GetObjectPropByIdx(lValue.get(), i, jsObjectValue.get()); 5172 lValue->GetObjectPropertyByIdx(i, jsObjectValue.get());
5220 FXJSE_Value_SetObjectProp(jsObjectValue.get(), 5173 jsObjectValue->SetObjectProperty(propertyStr.AsStringC(),
5221 propertyStr.AsStringC(), rValue.get()); 5174 rValue.get());
5222 } 5175 }
5223 } 5176 }
5224 } else if (FXJSE_Value_IsObject(lValue.get())) { 5177 } else if (FXJSE_Value_IsObject(lValue.get())) {
5225 bSetStatus = SetObjectDefaultValue(lValue.get(), rValue.get()); 5178 bSetStatus = SetObjectDefaultValue(lValue.get(), rValue.get());
5226 if (!bSetStatus) { 5179 if (!bSetStatus) {
5227 pContext->ThrowException(XFA_IDS_NOT_DEFAUL_VALUE); 5180 pContext->ThrowException(XFA_IDS_NOT_DEFAUL_VALUE);
5228 } 5181 }
5229 } 5182 }
5230 FXJSE_Value_Set(args.GetReturnValue(), rValue.get()); 5183 args.GetReturnValue()->Assign(rValue.get());
5231 } else { 5184 } else {
5232 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); 5185 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5233 } 5186 }
5234 } 5187 }
5235 5188
5236 // static 5189 // static
5237 void CXFA_FM2JSContext::logical_or_operator(CFXJSE_Value* pThis, 5190 void CXFA_FM2JSContext::logical_or_operator(CFXJSE_Value* pThis,
5238 const CFX_ByteStringC& szFuncName, 5191 const CFX_ByteStringC& szFuncName,
5239 CFXJSE_Arguments& args) { 5192 CFXJSE_Arguments& args) {
5240 if (args.GetLength() == 2) { 5193 if (args.GetLength() == 2) {
5241 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5194 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
5242 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5195 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
5243 if (FXJSE_Value_IsNull(argFirst.get()) && 5196 if (FXJSE_Value_IsNull(argFirst.get()) &&
5244 FXJSE_Value_IsNull(argSecond.get())) { 5197 FXJSE_Value_IsNull(argSecond.get())) {
5245 FXJSE_Value_SetNull(args.GetReturnValue()); 5198 args.GetReturnValue()->SetNull();
5246 } else { 5199 } else {
5247 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); 5200 FX_FLOAT first = ValueToFloat(pThis, argFirst.get());
5248 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); 5201 FX_FLOAT second = ValueToFloat(pThis, argSecond.get());
5249 FXJSE_Value_SetInteger(args.GetReturnValue(), (first || second) ? 1 : 0); 5202 args.GetReturnValue()->SetInteger((first || second) ? 1 : 0);
5250 } 5203 }
5251 } else { 5204 } else {
5252 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); 5205 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
5253 } 5206 }
5254 } 5207 }
5255 5208
5256 // static 5209 // static
5257 void CXFA_FM2JSContext::logical_and_operator(CFXJSE_Value* pThis, 5210 void CXFA_FM2JSContext::logical_and_operator(CFXJSE_Value* pThis,
5258 const CFX_ByteStringC& szFuncName, 5211 const CFX_ByteStringC& szFuncName,
5259 CFXJSE_Arguments& args) { 5212 CFXJSE_Arguments& args) {
5260 if (args.GetLength() == 2) { 5213 if (args.GetLength() == 2) {
5261 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5214 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
5262 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5215 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
5263 if (FXJSE_Value_IsNull(argFirst.get()) && 5216 if (FXJSE_Value_IsNull(argFirst.get()) &&
5264 FXJSE_Value_IsNull(argSecond.get())) { 5217 FXJSE_Value_IsNull(argSecond.get())) {
5265 FXJSE_Value_SetNull(args.GetReturnValue()); 5218 args.GetReturnValue()->SetNull();
5266 } else { 5219 } else {
5267 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); 5220 FX_FLOAT first = ValueToFloat(pThis, argFirst.get());
5268 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); 5221 FX_FLOAT second = ValueToFloat(pThis, argSecond.get());
5269 FXJSE_Value_SetInteger(args.GetReturnValue(), (first && second) ? 1 : 0); 5222 args.GetReturnValue()->SetInteger((first && second) ? 1 : 0);
5270 } 5223 }
5271 } else { 5224 } else {
5272 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); 5225 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
5273 } 5226 }
5274 } 5227 }
5275 5228
5276 // static 5229 // static
5277 void CXFA_FM2JSContext::equality_operator(CFXJSE_Value* pThis, 5230 void CXFA_FM2JSContext::equality_operator(CFXJSE_Value* pThis,
5278 const CFX_ByteStringC& szFuncName, 5231 const CFX_ByteStringC& szFuncName,
5279 CFXJSE_Arguments& args) { 5232 CFXJSE_Arguments& args) {
5280 if (args.GetLength() == 2) { 5233 if (args.GetLength() == 2) {
5281 if (fm_ref_equal(pThis, args)) { 5234 if (fm_ref_equal(pThis, args)) {
5282 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); 5235 args.GetReturnValue()->SetInteger(1);
5283 } else { 5236 } else {
5284 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5237 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
5285 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5238 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
5286 if (FXJSE_Value_IsNull(argFirst.get()) || 5239 if (FXJSE_Value_IsNull(argFirst.get()) ||
5287 FXJSE_Value_IsNull(argSecond.get())) { 5240 FXJSE_Value_IsNull(argSecond.get())) {
5288 FXJSE_Value_SetInteger(args.GetReturnValue(), 5241 args.GetReturnValue()->SetInteger((FXJSE_Value_IsNull(argFirst.get()) &&
5289 (FXJSE_Value_IsNull(argFirst.get()) && 5242 FXJSE_Value_IsNull(argSecond.get()))
5290 FXJSE_Value_IsNull(argSecond.get())) 5243 ? 1
5291 ? 1 5244 : 0);
5292 : 0);
5293 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) && 5245 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) &&
5294 FXJSE_Value_IsUTF8String(argSecond.get())) { 5246 FXJSE_Value_IsUTF8String(argSecond.get())) {
5295 CFX_ByteString firstOutput; 5247 CFX_ByteString firstOutput;
5296 CFX_ByteString secondOutput; 5248 CFX_ByteString secondOutput;
5297 FXJSE_Value_ToUTF8String(argFirst.get(), firstOutput); 5249 argFirst->ToString(firstOutput);
5298 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); 5250 argSecond->ToString(secondOutput);
5299 FXJSE_Value_SetInteger(args.GetReturnValue(), 5251 args.GetReturnValue()->SetInteger(firstOutput == secondOutput);
5300 firstOutput == secondOutput);
5301 } else { 5252 } else {
5302 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5253 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5303 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5254 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5304 FXJSE_Value_SetInteger(args.GetReturnValue(), 5255 args.GetReturnValue()->SetInteger((first == second) ? 1 : 0);
5305 (first == second) ? 1 : 0);
5306 } 5256 }
5307 } 5257 }
5308 } else { 5258 } else {
5309 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); 5259 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
5310 } 5260 }
5311 } 5261 }
5312 5262
5313 // static 5263 // static
5314 void CXFA_FM2JSContext::notequality_operator(CFXJSE_Value* pThis, 5264 void CXFA_FM2JSContext::notequality_operator(CFXJSE_Value* pThis,
5315 const CFX_ByteStringC& szFuncName, 5265 const CFX_ByteStringC& szFuncName,
5316 CFXJSE_Arguments& args) { 5266 CFXJSE_Arguments& args) {
5317 if (args.GetLength() == 2) { 5267 if (args.GetLength() == 2) {
5318 if (fm_ref_equal(pThis, args)) { 5268 if (fm_ref_equal(pThis, args)) {
5319 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); 5269 args.GetReturnValue()->SetInteger(0);
5320 } else { 5270 } else {
5321 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5271 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
5322 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5272 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
5323 if (FXJSE_Value_IsNull(argFirst.get()) || 5273 if (FXJSE_Value_IsNull(argFirst.get()) ||
5324 FXJSE_Value_IsNull(argSecond.get())) { 5274 FXJSE_Value_IsNull(argSecond.get())) {
5325 FXJSE_Value_SetInteger(args.GetReturnValue(), 5275 args.GetReturnValue()->SetInteger((FXJSE_Value_IsNull(argFirst.get()) &&
5326 (FXJSE_Value_IsNull(argFirst.get()) && 5276 FXJSE_Value_IsNull(argSecond.get()))
5327 FXJSE_Value_IsNull(argSecond.get())) 5277 ? 0
5328 ? 0 5278 : 1);
5329 : 1);
5330 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) && 5279 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) &&
5331 FXJSE_Value_IsUTF8String(argSecond.get())) { 5280 FXJSE_Value_IsUTF8String(argSecond.get())) {
5332 CFX_ByteString firstOutput; 5281 CFX_ByteString firstOutput;
5333 CFX_ByteString secondOutput; 5282 CFX_ByteString secondOutput;
5334 FXJSE_Value_ToUTF8String(argFirst.get(), firstOutput); 5283 argFirst->ToString(firstOutput);
5335 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); 5284 argSecond->ToString(secondOutput);
5336 FXJSE_Value_SetInteger(args.GetReturnValue(), 5285 args.GetReturnValue()->SetInteger(firstOutput != secondOutput);
5337 firstOutput != secondOutput);
5338 } else { 5286 } else {
5339 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5287 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5340 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5288 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5341 FXJSE_Value_SetInteger(args.GetReturnValue(), first != second); 5289 args.GetReturnValue()->SetInteger(first != second);
5342 } 5290 }
5343 } 5291 }
5344 } else { 5292 } else {
5345 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); 5293 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
5346 } 5294 }
5347 } 5295 }
5348 5296
5349 // static 5297 // static
5350 FX_BOOL CXFA_FM2JSContext::fm_ref_equal(CFXJSE_Value* pThis, 5298 FX_BOOL CXFA_FM2JSContext::fm_ref_equal(CFXJSE_Value* pThis,
5351 CFXJSE_Arguments& args) { 5299 CFXJSE_Arguments& args) {
5352 FX_BOOL bRet = FALSE; 5300 FX_BOOL bRet = FALSE;
5353 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); 5301 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime();
5354 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0); 5302 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0);
5355 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1); 5303 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1);
5356 if (FXJSE_Value_IsArray(argFirst.get()) && 5304 if (FXJSE_Value_IsArray(argFirst.get()) &&
5357 FXJSE_Value_IsArray(argSecond.get())) { 5305 FXJSE_Value_IsArray(argSecond.get())) {
5358 std::unique_ptr<CFXJSE_Value> firstFlagValue(new CFXJSE_Value(pIsolate)); 5306 std::unique_ptr<CFXJSE_Value> firstFlagValue(new CFXJSE_Value(pIsolate));
5359 std::unique_ptr<CFXJSE_Value> secondFlagValue(new CFXJSE_Value(pIsolate)); 5307 std::unique_ptr<CFXJSE_Value> secondFlagValue(new CFXJSE_Value(pIsolate));
5360 FXJSE_Value_GetObjectPropByIdx(argFirst.get(), 0, firstFlagValue.get()); 5308 argFirst->GetObjectPropertyByIdx(0, firstFlagValue.get());
5361 FXJSE_Value_GetObjectPropByIdx(argSecond.get(), 0, secondFlagValue.get()); 5309 argSecond->GetObjectPropertyByIdx(0, secondFlagValue.get());
5362 if ((FXJSE_Value_ToInteger(firstFlagValue.get()) == 3) && 5310 if (firstFlagValue->ToInteger() == 3 && secondFlagValue->ToInteger() == 3) {
5363 (FXJSE_Value_ToInteger(secondFlagValue.get()) == 3)) {
5364 std::unique_ptr<CFXJSE_Value> firstJSObject(new CFXJSE_Value(pIsolate)); 5311 std::unique_ptr<CFXJSE_Value> firstJSObject(new CFXJSE_Value(pIsolate));
5365 std::unique_ptr<CFXJSE_Value> secondJSObject(new CFXJSE_Value(pIsolate)); 5312 std::unique_ptr<CFXJSE_Value> secondJSObject(new CFXJSE_Value(pIsolate));
5366 FXJSE_Value_GetObjectPropByIdx(argFirst.get(), 2, firstJSObject.get()); 5313 argFirst->GetObjectPropertyByIdx(2, firstJSObject.get());
5367 FXJSE_Value_GetObjectPropByIdx(argSecond.get(), 2, secondJSObject.get()); 5314 argSecond->GetObjectPropertyByIdx(2, secondJSObject.get());
5368 if (!FXJSE_Value_IsNull(firstJSObject.get()) && 5315 if (!FXJSE_Value_IsNull(firstJSObject.get()) &&
5369 !FXJSE_Value_IsNull(secondJSObject.get())) { 5316 !FXJSE_Value_IsNull(secondJSObject.get())) {
5370 bRet = (firstJSObject->ToHostObject(nullptr) == 5317 bRet = (firstJSObject->ToHostObject(nullptr) ==
5371 secondJSObject->ToHostObject(nullptr)); 5318 secondJSObject->ToHostObject(nullptr));
5372 } 5319 }
5373 } 5320 }
5374 } 5321 }
5375 return bRet; 5322 return bRet;
5376 } 5323 }
5377 5324
5378 // static 5325 // static
5379 void CXFA_FM2JSContext::less_operator(CFXJSE_Value* pThis, 5326 void CXFA_FM2JSContext::less_operator(CFXJSE_Value* pThis,
5380 const CFX_ByteStringC& szFuncName, 5327 const CFX_ByteStringC& szFuncName,
5381 CFXJSE_Arguments& args) { 5328 CFXJSE_Arguments& args) {
5382 if (args.GetLength() == 2) { 5329 if (args.GetLength() == 2) {
5383 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5330 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
5384 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5331 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
5385 if (FXJSE_Value_IsNull(argFirst.get()) || 5332 if (FXJSE_Value_IsNull(argFirst.get()) ||
5386 FXJSE_Value_IsNull(argSecond.get())) { 5333 FXJSE_Value_IsNull(argSecond.get())) {
5387 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); 5334 args.GetReturnValue()->SetInteger(0);
5388 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) && 5335 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) &&
5389 FXJSE_Value_IsUTF8String(argSecond.get())) { 5336 FXJSE_Value_IsUTF8String(argSecond.get())) {
5390 CFX_ByteString firstOutput; 5337 CFX_ByteString firstOutput;
5391 CFX_ByteString secondOutput; 5338 CFX_ByteString secondOutput;
5392 FXJSE_Value_ToUTF8String(argFirst.get(), firstOutput); 5339 argFirst->ToString(firstOutput);
5393 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); 5340 argSecond->ToString(secondOutput);
5394 FXJSE_Value_SetInteger( 5341 args.GetReturnValue()->SetInteger(
5395 args.GetReturnValue(),
5396 firstOutput.Compare(secondOutput.AsStringC()) == -1); 5342 firstOutput.Compare(secondOutput.AsStringC()) == -1);
5397 } else { 5343 } else {
5398 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5344 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5399 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5345 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5400 FXJSE_Value_SetInteger(args.GetReturnValue(), (first < second) ? 1 : 0); 5346 args.GetReturnValue()->SetInteger((first < second) ? 1 : 0);
5401 } 5347 }
5402 } else { 5348 } else {
5403 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); 5349 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
5404 } 5350 }
5405 } 5351 }
5406 5352
5407 // static 5353 // static
5408 void CXFA_FM2JSContext::lessequal_operator(CFXJSE_Value* pThis, 5354 void CXFA_FM2JSContext::lessequal_operator(CFXJSE_Value* pThis,
5409 const CFX_ByteStringC& szFuncName, 5355 const CFX_ByteStringC& szFuncName,
5410 CFXJSE_Arguments& args) { 5356 CFXJSE_Arguments& args) {
5411 if (args.GetLength() == 2) { 5357 if (args.GetLength() == 2) {
5412 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5358 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
5413 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5359 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
5414 if (FXJSE_Value_IsNull(argFirst.get()) || 5360 if (FXJSE_Value_IsNull(argFirst.get()) ||
5415 FXJSE_Value_IsNull(argSecond.get())) { 5361 FXJSE_Value_IsNull(argSecond.get())) {
5416 FXJSE_Value_SetInteger(args.GetReturnValue(), 5362 args.GetReturnValue()->SetInteger((FXJSE_Value_IsNull(argFirst.get()) &&
5417 (FXJSE_Value_IsNull(argFirst.get()) && 5363 FXJSE_Value_IsNull(argSecond.get()))
5418 FXJSE_Value_IsNull(argSecond.get())) 5364 ? 1
5419 ? 1 5365 : 0);
5420 : 0);
5421 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) && 5366 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) &&
5422 FXJSE_Value_IsUTF8String(argSecond.get())) { 5367 FXJSE_Value_IsUTF8String(argSecond.get())) {
5423 CFX_ByteString firstOutput; 5368 CFX_ByteString firstOutput;
5424 CFX_ByteString secondOutput; 5369 CFX_ByteString secondOutput;
5425 FXJSE_Value_ToUTF8String(argFirst.get(), firstOutput); 5370 argFirst->ToString(firstOutput);
5426 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); 5371 argSecond->ToString(secondOutput);
5427 FXJSE_Value_SetInteger( 5372 args.GetReturnValue()->SetInteger(
5428 args.GetReturnValue(),
5429 firstOutput.Compare(secondOutput.AsStringC()) != 1); 5373 firstOutput.Compare(secondOutput.AsStringC()) != 1);
5430 } else { 5374 } else {
5431 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5375 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5432 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5376 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5433 FXJSE_Value_SetInteger(args.GetReturnValue(), (first <= second) ? 1 : 0); 5377 args.GetReturnValue()->SetInteger((first <= second) ? 1 : 0);
5434 } 5378 }
5435 } else { 5379 } else {
5436 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); 5380 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
5437 } 5381 }
5438 } 5382 }
5439 5383
5440 // static 5384 // static
5441 void CXFA_FM2JSContext::greater_operator(CFXJSE_Value* pThis, 5385 void CXFA_FM2JSContext::greater_operator(CFXJSE_Value* pThis,
5442 const CFX_ByteStringC& szFuncName, 5386 const CFX_ByteStringC& szFuncName,
5443 CFXJSE_Arguments& args) { 5387 CFXJSE_Arguments& args) {
5444 if (args.GetLength() == 2) { 5388 if (args.GetLength() == 2) {
5445 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5389 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
5446 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5390 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
5447 if (FXJSE_Value_IsNull(argFirst.get()) || 5391 if (FXJSE_Value_IsNull(argFirst.get()) ||
5448 FXJSE_Value_IsNull(argSecond.get())) { 5392 FXJSE_Value_IsNull(argSecond.get())) {
5449 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); 5393 args.GetReturnValue()->SetInteger(0);
5450 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) && 5394 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) &&
5451 FXJSE_Value_IsUTF8String(argSecond.get())) { 5395 FXJSE_Value_IsUTF8String(argSecond.get())) {
5452 CFX_ByteString firstOutput; 5396 CFX_ByteString firstOutput;
5453 CFX_ByteString secondOutput; 5397 CFX_ByteString secondOutput;
5454 FXJSE_Value_ToUTF8String(argFirst.get(), firstOutput); 5398 argFirst->ToString(firstOutput);
5455 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); 5399 argSecond->ToString(secondOutput);
5456 FXJSE_Value_SetInteger( 5400 args.GetReturnValue()->SetInteger(
5457 args.GetReturnValue(),
5458 firstOutput.Compare(secondOutput.AsStringC()) == 1); 5401 firstOutput.Compare(secondOutput.AsStringC()) == 1);
5459 } else { 5402 } else {
5460 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5403 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5461 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5404 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5462 FXJSE_Value_SetInteger(args.GetReturnValue(), (first > second) ? 1 : 0); 5405 args.GetReturnValue()->SetInteger((first > second) ? 1 : 0);
5463 } 5406 }
5464 } else { 5407 } else {
5465 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); 5408 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
5466 } 5409 }
5467 } 5410 }
5468 5411
5469 // static 5412 // static
5470 void CXFA_FM2JSContext::greaterequal_operator(CFXJSE_Value* pThis, 5413 void CXFA_FM2JSContext::greaterequal_operator(CFXJSE_Value* pThis,
5471 const CFX_ByteStringC& szFuncName, 5414 const CFX_ByteStringC& szFuncName,
5472 CFXJSE_Arguments& args) { 5415 CFXJSE_Arguments& args) {
5473 if (args.GetLength() == 2) { 5416 if (args.GetLength() == 2) {
5474 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5417 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
5475 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5418 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
5476 if (FXJSE_Value_IsNull(argFirst.get()) || 5419 if (FXJSE_Value_IsNull(argFirst.get()) ||
5477 FXJSE_Value_IsNull(argSecond.get())) { 5420 FXJSE_Value_IsNull(argSecond.get())) {
5478 FXJSE_Value_SetInteger(args.GetReturnValue(), 5421 args.GetReturnValue()->SetInteger((FXJSE_Value_IsNull(argFirst.get()) &&
5479 (FXJSE_Value_IsNull(argFirst.get()) && 5422 FXJSE_Value_IsNull(argSecond.get()))
5480 FXJSE_Value_IsNull(argSecond.get())) 5423 ? 1
5481 ? 1 5424 : 0);
5482 : 0);
5483 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) && 5425 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) &&
5484 FXJSE_Value_IsUTF8String(argSecond.get())) { 5426 FXJSE_Value_IsUTF8String(argSecond.get())) {
5485 CFX_ByteString firstOutput; 5427 CFX_ByteString firstOutput;
5486 CFX_ByteString secondOutput; 5428 CFX_ByteString secondOutput;
5487 FXJSE_Value_ToUTF8String(argFirst.get(), firstOutput); 5429 argFirst->ToString(firstOutput);
5488 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); 5430 argSecond->ToString(secondOutput);
5489 FXJSE_Value_SetInteger( 5431 args.GetReturnValue()->SetInteger(
5490 args.GetReturnValue(),
5491 firstOutput.Compare(secondOutput.AsStringC()) != -1); 5432 firstOutput.Compare(secondOutput.AsStringC()) != -1);
5492 } else { 5433 } else {
5493 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5434 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5494 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5435 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5495 FXJSE_Value_SetInteger(args.GetReturnValue(), (first >= second) ? 1 : 0); 5436 args.GetReturnValue()->SetInteger((first >= second) ? 1 : 0);
5496 } 5437 }
5497 } else { 5438 } else {
5498 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); 5439 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
5499 } 5440 }
5500 } 5441 }
5501 5442
5502 // static 5443 // static
5503 void CXFA_FM2JSContext::plus_operator(CFXJSE_Value* pThis, 5444 void CXFA_FM2JSContext::plus_operator(CFXJSE_Value* pThis,
5504 const CFX_ByteStringC& szFuncName, 5445 const CFX_ByteStringC& szFuncName,
5505 CFXJSE_Arguments& args) { 5446 CFXJSE_Arguments& args) {
5506 if (args.GetLength() == 2) { 5447 if (args.GetLength() == 2) {
5507 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0); 5448 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0);
5508 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1); 5449 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1);
5509 if (ValueIsNull(pThis, argFirst.get()) && 5450 if (ValueIsNull(pThis, argFirst.get()) &&
5510 ValueIsNull(pThis, argSecond.get())) { 5451 ValueIsNull(pThis, argSecond.get())) {
5511 FXJSE_Value_SetNull(args.GetReturnValue()); 5452 args.GetReturnValue()->SetNull();
5512 } else { 5453 } else {
5513 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5454 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5514 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5455 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5515 FXJSE_Value_SetDouble(args.GetReturnValue(), first + second); 5456 args.GetReturnValue()->SetDouble(first + second);
5516 } 5457 }
5517 } else { 5458 } else {
5518 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); 5459 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
5519 } 5460 }
5520 } 5461 }
5521 5462
5522 // static 5463 // static
5523 void CXFA_FM2JSContext::minus_operator(CFXJSE_Value* pThis, 5464 void CXFA_FM2JSContext::minus_operator(CFXJSE_Value* pThis,
5524 const CFX_ByteStringC& szFuncName, 5465 const CFX_ByteStringC& szFuncName,
5525 CFXJSE_Arguments& args) { 5466 CFXJSE_Arguments& args) {
5526 if (args.GetLength() == 2) { 5467 if (args.GetLength() == 2) {
5527 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5468 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
5528 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5469 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
5529 if (FXJSE_Value_IsNull(argFirst.get()) && 5470 if (FXJSE_Value_IsNull(argFirst.get()) &&
5530 FXJSE_Value_IsNull(argSecond.get())) { 5471 FXJSE_Value_IsNull(argSecond.get())) {
5531 FXJSE_Value_SetNull(args.GetReturnValue()); 5472 args.GetReturnValue()->SetNull();
5532 } else { 5473 } else {
5533 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5474 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5534 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5475 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5535 FXJSE_Value_SetDouble(args.GetReturnValue(), first - second); 5476 args.GetReturnValue()->SetDouble(first - second);
5536 } 5477 }
5537 } else { 5478 } else {
5538 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); 5479 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
5539 } 5480 }
5540 } 5481 }
5541 5482
5542 // static 5483 // static
5543 void CXFA_FM2JSContext::multiple_operator(CFXJSE_Value* pThis, 5484 void CXFA_FM2JSContext::multiple_operator(CFXJSE_Value* pThis,
5544 const CFX_ByteStringC& szFuncName, 5485 const CFX_ByteStringC& szFuncName,
5545 CFXJSE_Arguments& args) { 5486 CFXJSE_Arguments& args) {
5546 if (args.GetLength() == 2) { 5487 if (args.GetLength() == 2) {
5547 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5488 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
5548 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5489 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
5549 if (FXJSE_Value_IsNull(argFirst.get()) && 5490 if (FXJSE_Value_IsNull(argFirst.get()) &&
5550 FXJSE_Value_IsNull(argSecond.get())) { 5491 FXJSE_Value_IsNull(argSecond.get())) {
5551 FXJSE_Value_SetNull(args.GetReturnValue()); 5492 args.GetReturnValue()->SetNull();
5552 } else { 5493 } else {
5553 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5494 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5554 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5495 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5555 FXJSE_Value_SetDouble(args.GetReturnValue(), first * second); 5496 args.GetReturnValue()->SetDouble(first * second);
5556 } 5497 }
5557 } else { 5498 } else {
5558 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); 5499 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
5559 } 5500 }
5560 } 5501 }
5561 5502
5562 // static 5503 // static
5563 void CXFA_FM2JSContext::divide_operator(CFXJSE_Value* pThis, 5504 void CXFA_FM2JSContext::divide_operator(CFXJSE_Value* pThis,
5564 const CFX_ByteStringC& szFuncName, 5505 const CFX_ByteStringC& szFuncName,
5565 CFXJSE_Arguments& args) { 5506 CFXJSE_Arguments& args) {
5566 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 5507 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
5567 if (args.GetLength() == 2) { 5508 if (args.GetLength() == 2) {
5568 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); 5509 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0);
5569 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); 5510 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1);
5570 if (FXJSE_Value_IsNull(argFirst.get()) && 5511 if (FXJSE_Value_IsNull(argFirst.get()) &&
5571 FXJSE_Value_IsNull(argSecond.get())) { 5512 FXJSE_Value_IsNull(argSecond.get())) {
5572 FXJSE_Value_SetNull(args.GetReturnValue()); 5513 args.GetReturnValue()->SetNull();
5573 } else { 5514 } else {
5574 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); 5515 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get());
5575 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); 5516 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get());
5576 if (second == 0.0) { 5517 if (second == 0.0) {
5577 pContext->ThrowException(XFA_IDS_DIVIDE_ZERO); 5518 pContext->ThrowException(XFA_IDS_DIVIDE_ZERO);
5578 } else { 5519 } else {
5579 FXJSE_Value_SetDouble(args.GetReturnValue(), first / second); 5520 args.GetReturnValue()->SetDouble(first / second);
5580 } 5521 }
5581 } 5522 }
5582 } else { 5523 } else {
5583 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); 5524 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5584 } 5525 }
5585 } 5526 }
5586 5527
5587 // static 5528 // static
5588 void CXFA_FM2JSContext::positive_operator(CFXJSE_Value* pThis, 5529 void CXFA_FM2JSContext::positive_operator(CFXJSE_Value* pThis,
5589 const CFX_ByteStringC& szFuncName, 5530 const CFX_ByteStringC& szFuncName,
5590 CFXJSE_Arguments& args) { 5531 CFXJSE_Arguments& args) {
5591 if (args.GetLength() == 1) { 5532 if (args.GetLength() == 1) {
5592 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 5533 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
5593 if (FXJSE_Value_IsNull(argOne.get())) { 5534 if (FXJSE_Value_IsNull(argOne.get())) {
5594 FXJSE_Value_SetNull(args.GetReturnValue()); 5535 args.GetReturnValue()->SetNull();
5595 } else { 5536 } else {
5596 FXJSE_Value_SetDouble(args.GetReturnValue(), 5537 args.GetReturnValue()->SetDouble(0.0 +
5597 0.0 + ValueToDouble(pThis, argOne.get())); 5538 ValueToDouble(pThis, argOne.get()));
5598 } 5539 }
5599 } else { 5540 } else {
5600 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); 5541 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
5601 } 5542 }
5602 } 5543 }
5603 5544
5604 // static 5545 // static
5605 void CXFA_FM2JSContext::negative_operator(CFXJSE_Value* pThis, 5546 void CXFA_FM2JSContext::negative_operator(CFXJSE_Value* pThis,
5606 const CFX_ByteStringC& szFuncName, 5547 const CFX_ByteStringC& szFuncName,
5607 CFXJSE_Arguments& args) { 5548 CFXJSE_Arguments& args) {
5608 if (args.GetLength() == 1) { 5549 if (args.GetLength() == 1) {
5609 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 5550 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
5610 if (FXJSE_Value_IsNull(argOne.get())) { 5551 if (FXJSE_Value_IsNull(argOne.get())) {
5611 FXJSE_Value_SetNull(args.GetReturnValue()); 5552 args.GetReturnValue()->SetNull();
5612 } else { 5553 } else {
5613 FXJSE_Value_SetDouble(args.GetReturnValue(), 5554 args.GetReturnValue()->SetDouble(0.0 -
5614 0.0 - ValueToDouble(pThis, argOne.get())); 5555 ValueToDouble(pThis, argOne.get()));
5615 } 5556 }
5616 } else { 5557 } else {
5617 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); 5558 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
5618 } 5559 }
5619 } 5560 }
5620 5561
5621 // static 5562 // static
5622 void CXFA_FM2JSContext::logical_not_operator(CFXJSE_Value* pThis, 5563 void CXFA_FM2JSContext::logical_not_operator(CFXJSE_Value* pThis,
5623 const CFX_ByteStringC& szFuncName, 5564 const CFX_ByteStringC& szFuncName,
5624 CFXJSE_Arguments& args) { 5565 CFXJSE_Arguments& args) {
5625 if (args.GetLength() == 1) { 5566 if (args.GetLength() == 1) {
5626 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); 5567 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0);
5627 if (FXJSE_Value_IsNull(argOne.get())) { 5568 if (FXJSE_Value_IsNull(argOne.get())) {
5628 FXJSE_Value_SetNull(args.GetReturnValue()); 5569 args.GetReturnValue()->SetNull();
5629 } else { 5570 } else {
5630 FX_DOUBLE first = ValueToDouble(pThis, argOne.get()); 5571 FX_DOUBLE first = ValueToDouble(pThis, argOne.get());
5631 FXJSE_Value_SetInteger(args.GetReturnValue(), (first == 0.0) ? 1 : 0); 5572 args.GetReturnValue()->SetInteger((first == 0.0) ? 1 : 0);
5632 } 5573 }
5633 } else { 5574 } else {
5634 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); 5575 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR);
5635 } 5576 }
5636 } 5577 }
5637 5578
5638 // static 5579 // static
5639 void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis, 5580 void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis,
5640 const CFX_ByteStringC& szFuncName, 5581 const CFX_ByteStringC& szFuncName,
5641 CFXJSE_Arguments& args) { 5582 CFXJSE_Arguments& args) {
(...skipping 10 matching lines...) Expand all
5652 if (argc > 4) { 5593 if (argc > 4) {
5653 bIsStar = FALSE; 5594 bIsStar = FALSE;
5654 std::unique_ptr<CFXJSE_Value> argIndex = args.GetValue(4); 5595 std::unique_ptr<CFXJSE_Value> argIndex = args.GetValue(4);
5655 iIndexValue = ValueToInteger(pThis, argIndex.get()); 5596 iIndexValue = ValueToInteger(pThis, argIndex.get());
5656 } 5597 }
5657 CFX_ByteString szSomExp; 5598 CFX_ByteString szSomExp;
5658 GenerateSomExpression(szName.AsStringC(), iIndexFlags, iIndexValue, bIsStar, 5599 GenerateSomExpression(szName.AsStringC(), iIndexFlags, iIndexValue, bIsStar,
5659 szSomExp); 5600 szSomExp);
5660 if (FXJSE_Value_IsArray(argAccessor.get())) { 5601 if (FXJSE_Value_IsArray(argAccessor.get())) {
5661 std::unique_ptr<CFXJSE_Value> pLengthValue(new CFXJSE_Value(pIsolate)); 5602 std::unique_ptr<CFXJSE_Value> pLengthValue(new CFXJSE_Value(pIsolate));
5662 FXJSE_Value_GetObjectProp(argAccessor.get(), "length", 5603 argAccessor->GetObjectProperty("length", pLengthValue.get());
5663 pLengthValue.get()); 5604 int32_t iLength = pLengthValue->ToInteger();
5664 int32_t iLength = FXJSE_Value_ToInteger(pLengthValue.get());
5665 int32_t iCounter = 0; 5605 int32_t iCounter = 0;
5666 CFXJSE_Value*** hResolveValues = FX_Alloc(CFXJSE_Value**, iLength - 2); 5606 CFXJSE_Value*** hResolveValues = FX_Alloc(CFXJSE_Value**, iLength - 2);
5667 int32_t* iSizes = FX_Alloc(int32_t, iLength - 2); 5607 int32_t* iSizes = FX_Alloc(int32_t, iLength - 2);
5668 for (int32_t i = 0; i < (iLength - 2); i++) { 5608 for (int32_t i = 0; i < (iLength - 2); i++) {
5669 iSizes[i] = 0; 5609 iSizes[i] = 0;
5670 } 5610 }
5671 std::unique_ptr<CFXJSE_Value> hJSObjValue(new CFXJSE_Value(pIsolate)); 5611 std::unique_ptr<CFXJSE_Value> hJSObjValue(new CFXJSE_Value(pIsolate));
5672 FX_BOOL bAttribute = FALSE; 5612 FX_BOOL bAttribute = FALSE;
5673 for (int32_t i = 2; i < iLength; i++) { 5613 for (int32_t i = 2; i < iLength; i++) {
5674 FXJSE_Value_GetObjectPropByIdx(argAccessor.get(), i, hJSObjValue.get()); 5614 argAccessor->GetObjectPropertyByIdx(i, hJSObjValue.get());
5675 XFA_RESOLVENODE_RS resoveNodeRS; 5615 XFA_RESOLVENODE_RS resoveNodeRS;
5676 int32_t iRet = 5616 int32_t iRet =
5677 ResolveObjects(pThis, hJSObjValue.get(), szSomExp.AsStringC(), 5617 ResolveObjects(pThis, hJSObjValue.get(), szSomExp.AsStringC(),
5678 resoveNodeRS, TRUE, szName.IsEmpty()); 5618 resoveNodeRS, TRUE, szName.IsEmpty());
5679 if (iRet > 0) { 5619 if (iRet > 0) {
5680 ParseResolveResult(pThis, resoveNodeRS, hJSObjValue.get(), 5620 ParseResolveResult(pThis, resoveNodeRS, hJSObjValue.get(),
5681 hResolveValues[i - 2], iSizes[i - 2], bAttribute); 5621 hResolveValues[i - 2], iSizes[i - 2], bAttribute);
5682 iCounter += iSizes[i - 2]; 5622 iCounter += iSizes[i - 2];
5683 } 5623 }
5684 } 5624 }
5685 if (iCounter > 0) { 5625 if (iCounter > 0) {
5686 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iCounter + 2); 5626 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iCounter + 2);
5687 for (int32_t i = 0; i < (iCounter + 2); i++) 5627 for (int32_t i = 0; i < (iCounter + 2); i++)
5688 rgValues[i] = new CFXJSE_Value(pIsolate); 5628 rgValues[i] = new CFXJSE_Value(pIsolate);
5689 5629
5690 FXJSE_Value_SetInteger(rgValues[0], 1); 5630 rgValues[0]->SetInteger(1);
5691 if (bAttribute) { 5631 if (bAttribute) {
5692 FXJSE_Value_SetUTF8String(rgValues[1], szName.AsStringC()); 5632 rgValues[1]->SetString(szName.AsStringC());
5693 } else { 5633 } else {
5694 FXJSE_Value_SetNull(rgValues[1]); 5634 rgValues[1]->SetNull();
5695 } 5635 }
5696 int32_t iIndex = 2; 5636 int32_t iIndex = 2;
5697 for (int32_t i = 0; i < iLength - 2; i++) { 5637 for (int32_t i = 0; i < iLength - 2; i++) {
5698 for (int32_t j = 0; j < iSizes[i]; j++) { 5638 for (int32_t j = 0; j < iSizes[i]; j++) {
5699 FXJSE_Value_Set(rgValues[iIndex], hResolveValues[i][j]); 5639 rgValues[iIndex]->Assign(hResolveValues[i][j]);
5700 iIndex++; 5640 iIndex++;
5701 } 5641 }
5702 } 5642 }
5703 FXJSE_Value_SetArray(args.GetReturnValue(), (iCounter + 2), rgValues); 5643 args.GetReturnValue()->SetArray(iCounter + 2, rgValues);
5704 for (int32_t i = 0; i < (iCounter + 2); i++) 5644 for (int32_t i = 0; i < (iCounter + 2); i++)
5705 delete rgValues[i]; 5645 delete rgValues[i];
5706 5646
5707 FX_Free(rgValues); 5647 FX_Free(rgValues);
5708 } else { 5648 } else {
5709 CFX_WideString wsPropertyName = 5649 CFX_WideString wsPropertyName =
5710 CFX_WideString::FromUTF8(szName.AsStringC()); 5650 CFX_WideString::FromUTF8(szName.AsStringC());
5711 CFX_WideString wsSomExpression = 5651 CFX_WideString wsSomExpression =
5712 CFX_WideString::FromUTF8(szSomExp.AsStringC()); 5652 CFX_WideString::FromUTF8(szSomExp.AsStringC());
5713 pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, 5653 pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
(...skipping 29 matching lines...) Expand all
5743 if (iRet > 0) { 5683 if (iRet > 0) {
5744 CFXJSE_Value** hResolveValues; 5684 CFXJSE_Value** hResolveValues;
5745 int32_t iSize = 0; 5685 int32_t iSize = 0;
5746 FX_BOOL bAttribute = FALSE; 5686 FX_BOOL bAttribute = FALSE;
5747 ParseResolveResult(pThis, resoveNodeRS, argAccessor.get(), 5687 ParseResolveResult(pThis, resoveNodeRS, argAccessor.get(),
5748 hResolveValues, iSize, bAttribute); 5688 hResolveValues, iSize, bAttribute);
5749 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iSize + 2); 5689 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iSize + 2);
5750 for (int32_t i = 0; i < (iSize + 2); i++) 5690 for (int32_t i = 0; i < (iSize + 2); i++)
5751 rgValues[i] = new CFXJSE_Value(pIsolate); 5691 rgValues[i] = new CFXJSE_Value(pIsolate);
5752 5692
5753 FXJSE_Value_SetInteger(rgValues[0], 1); 5693 rgValues[0]->SetInteger(1);
5754 if (bAttribute) { 5694 if (bAttribute) {
5755 FXJSE_Value_SetUTF8String(rgValues[1], szName.AsStringC()); 5695 rgValues[1]->SetString(szName.AsStringC());
5756 } else { 5696 } else {
5757 FXJSE_Value_SetNull(rgValues[1]); 5697 rgValues[1]->SetNull();
5758 } 5698 }
5759 for (int32_t i = 0; i < iSize; i++) { 5699 for (int32_t i = 0; i < iSize; i++) {
5760 FXJSE_Value_Set(rgValues[i + 2], hResolveValues[i]); 5700 rgValues[i + 2]->Assign(hResolveValues[i]);
5761 } 5701 }
5762 FXJSE_Value_SetArray(args.GetReturnValue(), (iSize + 2), rgValues); 5702 args.GetReturnValue()->SetArray(iSize + 2, rgValues);
5763 for (int32_t i = 0; i < (iSize + 2); i++) 5703 for (int32_t i = 0; i < (iSize + 2); i++)
5764 delete rgValues[i]; 5704 delete rgValues[i];
5765 5705
5766 FX_Free(rgValues); 5706 FX_Free(rgValues);
5767 for (int32_t i = 0; i < iSize; i++) 5707 for (int32_t i = 0; i < iSize; i++)
5768 delete hResolveValues[i]; 5708 delete hResolveValues[i];
5769 5709
5770 FX_Free(hResolveValues); 5710 FX_Free(hResolveValues);
5771 } else { 5711 } else {
5772 CFX_WideString wsPropertyName = 5712 CFX_WideString wsPropertyName =
(...skipping 27 matching lines...) Expand all
5800 if (argc > 4) { 5740 if (argc > 4) {
5801 bIsStar = FALSE; 5741 bIsStar = FALSE;
5802 std::unique_ptr<CFXJSE_Value> argIndex = args.GetValue(4); 5742 std::unique_ptr<CFXJSE_Value> argIndex = args.GetValue(4);
5803 iIndexValue = ValueToInteger(pThis, argIndex.get()); 5743 iIndexValue = ValueToInteger(pThis, argIndex.get());
5804 } 5744 }
5805 CFX_ByteString szSomExp; 5745 CFX_ByteString szSomExp;
5806 GenerateSomExpression(szName.AsStringC(), iIndexFlags, iIndexValue, bIsStar, 5746 GenerateSomExpression(szName.AsStringC(), iIndexFlags, iIndexValue, bIsStar,
5807 szSomExp); 5747 szSomExp);
5808 if (FXJSE_Value_IsArray(argAccessor.get())) { 5748 if (FXJSE_Value_IsArray(argAccessor.get())) {
5809 std::unique_ptr<CFXJSE_Value> pLengthValue(new CFXJSE_Value(pIsolate)); 5749 std::unique_ptr<CFXJSE_Value> pLengthValue(new CFXJSE_Value(pIsolate));
5810 FXJSE_Value_GetObjectProp(argAccessor.get(), "length", 5750 argAccessor->GetObjectProperty("length", pLengthValue.get());
5811 pLengthValue.get()); 5751 int32_t iLength = pLengthValue->ToInteger();
5812 int32_t iLength = FXJSE_Value_ToInteger(pLengthValue.get());
5813 int32_t iCounter = 0; 5752 int32_t iCounter = 0;
5814 CFXJSE_Value*** hResolveValues = FX_Alloc(CFXJSE_Value**, iLength - 2); 5753 CFXJSE_Value*** hResolveValues = FX_Alloc(CFXJSE_Value**, iLength - 2);
5815 int32_t* iSizes = FX_Alloc(int32_t, iLength - 2); 5754 int32_t* iSizes = FX_Alloc(int32_t, iLength - 2);
5816 std::unique_ptr<CFXJSE_Value> hJSObjValue(new CFXJSE_Value(pIsolate)); 5755 std::unique_ptr<CFXJSE_Value> hJSObjValue(new CFXJSE_Value(pIsolate));
5817 FX_BOOL bAttribute = FALSE; 5756 FX_BOOL bAttribute = FALSE;
5818 for (int32_t i = 2; i < iLength; i++) { 5757 for (int32_t i = 2; i < iLength; i++) {
5819 FXJSE_Value_GetObjectPropByIdx(argAccessor.get(), i, hJSObjValue.get()); 5758 argAccessor->GetObjectPropertyByIdx(i, hJSObjValue.get());
5820 XFA_RESOLVENODE_RS resoveNodeRS; 5759 XFA_RESOLVENODE_RS resoveNodeRS;
5821 int32_t iRet = 5760 int32_t iRet =
5822 ResolveObjects(pThis, hJSObjValue.get(), szSomExp.AsStringC(), 5761 ResolveObjects(pThis, hJSObjValue.get(), szSomExp.AsStringC(),
5823 resoveNodeRS, FALSE); 5762 resoveNodeRS, FALSE);
5824 if (iRet > 0) { 5763 if (iRet > 0) {
5825 ParseResolveResult(pThis, resoveNodeRS, hJSObjValue.get(), 5764 ParseResolveResult(pThis, resoveNodeRS, hJSObjValue.get(),
5826 hResolveValues[i - 2], iSizes[i - 2], bAttribute); 5765 hResolveValues[i - 2], iSizes[i - 2], bAttribute);
5827 iCounter += iSizes[i - 2]; 5766 iCounter += iSizes[i - 2];
5828 } 5767 }
5829 } 5768 }
5830 if (iCounter > 0) { 5769 if (iCounter > 0) {
5831 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iCounter + 2); 5770 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iCounter + 2);
5832 for (int32_t i = 0; i < (iCounter + 2); i++) 5771 for (int32_t i = 0; i < (iCounter + 2); i++)
5833 rgValues[i] = new CFXJSE_Value(pIsolate); 5772 rgValues[i] = new CFXJSE_Value(pIsolate);
5834 5773
5835 FXJSE_Value_SetInteger(rgValues[0], 1); 5774 rgValues[0]->SetInteger(1);
5836 if (bAttribute) { 5775 if (bAttribute) {
5837 FXJSE_Value_SetUTF8String(rgValues[1], szName.AsStringC()); 5776 rgValues[1]->SetString(szName.AsStringC());
5838 } else { 5777 } else {
5839 FXJSE_Value_SetNull(rgValues[1]); 5778 rgValues[1]->SetNull();
5840 } 5779 }
5841 int32_t iIndex = 2; 5780 int32_t iIndex = 2;
5842 for (int32_t i = 0; i < iLength - 2; i++) { 5781 for (int32_t i = 0; i < iLength - 2; i++) {
5843 for (int32_t j = 0; j < iSizes[i]; j++) { 5782 for (int32_t j = 0; j < iSizes[i]; j++) {
5844 FXJSE_Value_Set(rgValues[iIndex], hResolveValues[i][j]); 5783 rgValues[iIndex]->Assign(hResolveValues[i][j]);
5845 iIndex++; 5784 iIndex++;
5846 } 5785 }
5847 } 5786 }
5848 FXJSE_Value_SetArray(args.GetReturnValue(), (iCounter + 2), rgValues); 5787 args.GetReturnValue()->SetArray(iCounter + 2, rgValues);
5849 for (int32_t i = 0; i < (iCounter + 2); i++) 5788 for (int32_t i = 0; i < (iCounter + 2); i++)
5850 delete rgValues[i]; 5789 delete rgValues[i];
5851 5790
5852 FX_Free(rgValues); 5791 FX_Free(rgValues);
5853 } else { 5792 } else {
5854 CFX_WideString wsPropertyName = 5793 CFX_WideString wsPropertyName =
5855 CFX_WideString::FromUTF8(szName.AsStringC()); 5794 CFX_WideString::FromUTF8(szName.AsStringC());
5856 CFX_WideString wsSomExpression = 5795 CFX_WideString wsSomExpression =
5857 CFX_WideString::FromUTF8(szSomExp.AsStringC()); 5796 CFX_WideString::FromUTF8(szSomExp.AsStringC());
5858 pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, 5797 pContext->ThrowException(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT,
(...skipping 27 matching lines...) Expand all
5886 if (iRet > 0) { 5825 if (iRet > 0) {
5887 CFXJSE_Value** hResolveValues; 5826 CFXJSE_Value** hResolveValues;
5888 int32_t iSize = 0; 5827 int32_t iSize = 0;
5889 FX_BOOL bAttribute = FALSE; 5828 FX_BOOL bAttribute = FALSE;
5890 ParseResolveResult(pThis, resoveNodeRS, argAccessor.get(), 5829 ParseResolveResult(pThis, resoveNodeRS, argAccessor.get(),
5891 hResolveValues, iSize, bAttribute); 5830 hResolveValues, iSize, bAttribute);
5892 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iSize + 2); 5831 CFXJSE_Value** rgValues = FX_Alloc(CFXJSE_Value*, iSize + 2);
5893 for (int32_t i = 0; i < (iSize + 2); i++) 5832 for (int32_t i = 0; i < (iSize + 2); i++)
5894 rgValues[i] = new CFXJSE_Value(pIsolate); 5833 rgValues[i] = new CFXJSE_Value(pIsolate);
5895 5834
5896 FXJSE_Value_SetInteger(rgValues[0], 1); 5835 rgValues[0]->SetInteger(1);
5897 if (bAttribute) { 5836 if (bAttribute) {
5898 FXJSE_Value_SetUTF8String(rgValues[1], szName.AsStringC()); 5837 rgValues[1]->SetString(szName.AsStringC());
5899 } else { 5838 } else {
5900 FXJSE_Value_SetNull(rgValues[1]); 5839 rgValues[1]->SetNull();
5901 } 5840 }
5902 for (int32_t i = 0; i < iSize; i++) { 5841 for (int32_t i = 0; i < iSize; i++) {
5903 FXJSE_Value_Set(rgValues[i + 2], hResolveValues[i]); 5842 rgValues[i + 2]->Assign(hResolveValues[i]);
5904 } 5843 }
5905 FXJSE_Value_SetArray(args.GetReturnValue(), (iSize + 2), rgValues); 5844 args.GetReturnValue()->SetArray(iSize + 2, rgValues);
5906 for (int32_t i = 0; i < (iSize + 2); i++) 5845 for (int32_t i = 0; i < (iSize + 2); i++)
5907 delete rgValues[i]; 5846 delete rgValues[i];
5908 5847
5909 FX_Free(rgValues); 5848 FX_Free(rgValues);
5910 for (int32_t i = 0; i < iSize; i++) 5849 for (int32_t i = 0; i < iSize; i++)
5911 delete hResolveValues[i]; 5850 delete hResolveValues[i];
5912 5851
5913 FX_Free(hResolveValues); 5852 FX_Free(hResolveValues);
5914 } else { 5853 } else {
5915 CFX_WideString wsPropertyName = 5854 CFX_WideString wsPropertyName =
(...skipping 23 matching lines...) Expand all
5939 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH); 5878 pContext->ThrowException(XFA_IDS_ARGUMENT_MISMATCH);
5940 } else { 5879 } else {
5941 CFX_WideString scriptString = 5880 CFX_WideString scriptString =
5942 CFX_WideString::FromUTF8(argString.AsStringC()); 5881 CFX_WideString::FromUTF8(argString.AsStringC());
5943 CFX_WideTextBuf wsJavaScriptBuf; 5882 CFX_WideTextBuf wsJavaScriptBuf;
5944 CFX_WideString wsError; 5883 CFX_WideString wsError;
5945 CXFA_FM2JSContext::Translate(scriptString.AsStringC(), wsJavaScriptBuf, 5884 CXFA_FM2JSContext::Translate(scriptString.AsStringC(), wsJavaScriptBuf,
5946 wsError); 5885 wsError);
5947 if (wsError.IsEmpty()) { 5886 if (wsError.IsEmpty()) {
5948 CFX_WideString javaScript = wsJavaScriptBuf.MakeString(); 5887 CFX_WideString javaScript = wsJavaScriptBuf.MakeString();
5949 FXJSE_Value_SetUTF8String( 5888 args.GetReturnValue()->SetString(
5950 args.GetReturnValue(),
5951 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()) 5889 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength())
5952 .AsStringC()); 5890 .AsStringC());
5953 } else { 5891 } else {
5954 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); 5892 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
5955 } 5893 }
5956 } 5894 }
5957 } else { 5895 } else {
5958 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Eval"); 5896 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Eval");
5959 } 5897 }
5960 } 5898 }
5961 5899
5962 // static 5900 // static
5963 void CXFA_FM2JSContext::is_fm_object(CFXJSE_Value* pThis, 5901 void CXFA_FM2JSContext::is_fm_object(CFXJSE_Value* pThis,
5964 const CFX_ByteStringC& szFuncName, 5902 const CFX_ByteStringC& szFuncName,
5965 CFXJSE_Arguments& args) { 5903 CFXJSE_Arguments& args) {
5966 if (args.GetLength() == 1) { 5904 if (args.GetLength() == 1) {
5967 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 5905 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
5968 FXJSE_Value_SetBoolean(args.GetReturnValue(), 5906 args.GetReturnValue()->SetBoolean(FXJSE_Value_IsObject(argOne.get()));
5969 FXJSE_Value_IsObject(argOne.get()));
5970 } else { 5907 } else {
5971 FXJSE_Value_SetBoolean(args.GetReturnValue(), FALSE); 5908 args.GetReturnValue()->SetBoolean(FALSE);
5972 } 5909 }
5973 } 5910 }
5974 5911
5975 // static 5912 // static
5976 void CXFA_FM2JSContext::is_fm_array(CFXJSE_Value* pThis, 5913 void CXFA_FM2JSContext::is_fm_array(CFXJSE_Value* pThis,
5977 const CFX_ByteStringC& szFuncName, 5914 const CFX_ByteStringC& szFuncName,
5978 CFXJSE_Arguments& args) { 5915 CFXJSE_Arguments& args) {
5979 if (args.GetLength() == 1) { 5916 if (args.GetLength() == 1) {
5980 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 5917 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
5981 FX_BOOL bIsArray = FXJSE_Value_IsArray(argOne.get()); 5918 FX_BOOL bIsArray = FXJSE_Value_IsArray(argOne.get());
5982 FXJSE_Value_SetBoolean(args.GetReturnValue(), bIsArray); 5919 args.GetReturnValue()->SetBoolean(bIsArray);
5983 } else { 5920 } else {
5984 FXJSE_Value_SetBoolean(args.GetReturnValue(), FALSE); 5921 args.GetReturnValue()->SetBoolean(FALSE);
5985 } 5922 }
5986 } 5923 }
5987 5924
5988 // static 5925 // static
5989 void CXFA_FM2JSContext::get_fm_value(CFXJSE_Value* pThis, 5926 void CXFA_FM2JSContext::get_fm_value(CFXJSE_Value* pThis,
5990 const CFX_ByteStringC& szFuncName, 5927 const CFX_ByteStringC& szFuncName,
5991 CFXJSE_Arguments& args) { 5928 CFXJSE_Arguments& args) {
5992 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 5929 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
5993 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 5930 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
5994 if (args.GetLength() == 1) { 5931 if (args.GetLength() == 1) {
5995 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 5932 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
5996 if (FXJSE_Value_IsArray(argOne.get())) { 5933 if (FXJSE_Value_IsArray(argOne.get())) {
5997 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 5934 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
5998 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 5935 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
5999 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 1, propertyValue.get()); 5936 argOne->GetObjectPropertyByIdx(1, propertyValue.get());
6000 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, jsObjectValue.get()); 5937 argOne->GetObjectPropertyByIdx(2, jsObjectValue.get());
6001 if (FXJSE_Value_IsNull(propertyValue.get())) { 5938 if (FXJSE_Value_IsNull(propertyValue.get())) {
6002 GetObjectDefaultValue(jsObjectValue.get(), args.GetReturnValue()); 5939 GetObjectDefaultValue(jsObjectValue.get(), args.GetReturnValue());
6003 } else { 5940 } else {
6004 CFX_ByteString propertyStr; 5941 CFX_ByteString propertyStr;
6005 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); 5942 propertyValue->ToString(propertyStr);
6006 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), 5943 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
6007 args.GetReturnValue()); 5944 args.GetReturnValue());
6008 } 5945 }
6009 } else if (FXJSE_Value_IsObject(argOne.get())) { 5946 } else if (FXJSE_Value_IsObject(argOne.get())) {
6010 GetObjectDefaultValue(argOne.get(), args.GetReturnValue()); 5947 GetObjectDefaultValue(argOne.get(), args.GetReturnValue());
6011 } else { 5948 } else {
6012 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); 5949 args.GetReturnValue()->Assign(argOne.get());
6013 } 5950 }
6014 } else { 5951 } else {
6015 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); 5952 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
6016 } 5953 }
6017 } 5954 }
6018 5955
6019 // static 5956 // static
6020 void CXFA_FM2JSContext::get_fm_jsobj(CFXJSE_Value* pThis, 5957 void CXFA_FM2JSContext::get_fm_jsobj(CFXJSE_Value* pThis,
6021 const CFX_ByteStringC& szFuncName, 5958 const CFX_ByteStringC& szFuncName,
6022 CFXJSE_Arguments& args) { 5959 CFXJSE_Arguments& args) {
6023 if (args.GetLength() == 1) { 5960 if (args.GetLength() == 1) {
6024 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 5961 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
6025 if (FXJSE_Value_IsArray(argOne.get())) { 5962 if (FXJSE_Value_IsArray(argOne.get())) {
6026 #ifndef NDEBUG 5963 #ifndef NDEBUG
6027 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 5964 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
6028 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 5965 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
6029 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 5966 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
6030 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get()); 5967 argOne->GetObjectProperty("length", lengthValue.get());
6031 ASSERT(FXJSE_Value_ToInteger(lengthValue.get()) >= 3); 5968 ASSERT(lengthValue->ToInteger() >= 3);
6032 #endif 5969 #endif
6033 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, args.GetReturnValue()); 5970 argOne->GetObjectPropertyByIdx(2, args.GetReturnValue());
6034 } else { 5971 } else {
6035 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); 5972 args.GetReturnValue()->Assign(argOne.get());
6036 } 5973 }
6037 } else { 5974 } else {
6038 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 5975 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
6039 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); 5976 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
6040 } 5977 }
6041 } 5978 }
6042 5979
6043 // static 5980 // static
6044 void CXFA_FM2JSContext::fm_var_filter(CFXJSE_Value* pThis, 5981 void CXFA_FM2JSContext::fm_var_filter(CFXJSE_Value* pThis,
6045 const CFX_ByteStringC& szFuncName, 5982 const CFX_ByteStringC& szFuncName,
6046 CFXJSE_Arguments& args) { 5983 CFXJSE_Arguments& args) {
6047 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 5984 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
6048 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 5985 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
6049 if (args.GetLength() == 1) { 5986 if (args.GetLength() == 1) {
6050 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); 5987 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0);
6051 if (FXJSE_Value_IsArray(argOne.get())) { 5988 if (FXJSE_Value_IsArray(argOne.get())) {
6052 #ifndef NDEBUG 5989 #ifndef NDEBUG
6053 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 5990 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
6054 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get()); 5991 argOne->GetObjectProperty("length", lengthValue.get());
6055 ASSERT(FXJSE_Value_ToInteger(lengthValue.get()) >= 3); 5992 ASSERT(lengthValue->ToInteger() >= 3);
6056 #endif 5993 #endif
6057 std::unique_ptr<CFXJSE_Value> flagsValue(new CFXJSE_Value(pIsolate)); 5994 std::unique_ptr<CFXJSE_Value> flagsValue(new CFXJSE_Value(pIsolate));
6058 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 0, flagsValue.get()); 5995 argOne->GetObjectPropertyByIdx(0, flagsValue.get());
6059 int32_t iFlags = FXJSE_Value_ToInteger(flagsValue.get()); 5996 int32_t iFlags = flagsValue->ToInteger();
6060 if (iFlags == 4) { 5997 if (iFlags == 4) {
6061 CFXJSE_Value* rgValues[3]; 5998 CFXJSE_Value* rgValues[3];
6062 for (int32_t i = 0; i < 3; i++) 5999 for (int32_t i = 0; i < 3; i++)
6063 rgValues[i] = new CFXJSE_Value(pIsolate); 6000 rgValues[i] = new CFXJSE_Value(pIsolate);
6064 6001
6065 FXJSE_Value_SetInteger(rgValues[0], 3); 6002 rgValues[0]->SetInteger(3);
6066 FXJSE_Value_SetNull(rgValues[1]); 6003 rgValues[1]->SetNull();
6067 FXJSE_Value_SetNull(rgValues[2]); 6004 rgValues[2]->SetNull();
6068 FXJSE_Value_SetArray(args.GetReturnValue(), 3, rgValues); 6005 args.GetReturnValue()->SetArray(3, rgValues);
6069 for (int32_t i = 0; i < 3; i++) 6006 for (int32_t i = 0; i < 3; i++)
6070 delete rgValues[i]; 6007 delete rgValues[i];
6071 } else if (iFlags == 3) { 6008 } else if (iFlags == 3) {
6072 std::unique_ptr<CFXJSE_Value> objectValue(new CFXJSE_Value(pIsolate)); 6009 std::unique_ptr<CFXJSE_Value> objectValue(new CFXJSE_Value(pIsolate));
6073 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, objectValue.get()); 6010 argOne->GetObjectPropertyByIdx(2, objectValue.get());
6074 if (!FXJSE_Value_IsNull(objectValue.get())) { 6011 if (!FXJSE_Value_IsNull(objectValue.get())) {
6075 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); 6012 args.GetReturnValue()->Assign(argOne.get());
6076 } else { 6013 } else {
6077 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); 6014 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
6078 } 6015 }
6079 } else { 6016 } else {
6080 std::unique_ptr<CFXJSE_Value> simpleValue = 6017 std::unique_ptr<CFXJSE_Value> simpleValue =
6081 GetSimpleValue(pThis, args, 0); 6018 GetSimpleValue(pThis, args, 0);
6082 FXJSE_Value_Set(args.GetReturnValue(), simpleValue.get()); 6019 args.GetReturnValue()->Assign(simpleValue.get());
6083 } 6020 }
6084 } else { 6021 } else {
6085 std::unique_ptr<CFXJSE_Value> simpleValue = 6022 std::unique_ptr<CFXJSE_Value> simpleValue =
6086 GetSimpleValue(pThis, args, 0); 6023 GetSimpleValue(pThis, args, 0);
6087 FXJSE_Value_Set(args.GetReturnValue(), simpleValue.get()); 6024 args.GetReturnValue()->Assign(simpleValue.get());
6088 } 6025 }
6089 } else { 6026 } else {
6090 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); 6027 pContext->ThrowException(XFA_IDS_COMPILER_ERROR);
6091 } 6028 }
6092 } 6029 }
6093 6030
6094 // static 6031 // static
6095 void CXFA_FM2JSContext::concat_fm_object(CFXJSE_Value* pThis, 6032 void CXFA_FM2JSContext::concat_fm_object(CFXJSE_Value* pThis,
6096 const CFX_ByteStringC& szFuncName, 6033 const CFX_ByteStringC& szFuncName,
6097 CFXJSE_Arguments& args) { 6034 CFXJSE_Arguments& args) {
6098 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); 6035 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime();
6099 uint32_t iLength = 0; 6036 uint32_t iLength = 0;
6100 int32_t argc = args.GetLength(); 6037 int32_t argc = args.GetLength();
6101 std::vector<std::unique_ptr<CFXJSE_Value>> argValues; 6038 std::vector<std::unique_ptr<CFXJSE_Value>> argValues;
6102 for (int32_t i = 0; i < argc; i++) { 6039 for (int32_t i = 0; i < argc; i++) {
6103 argValues.push_back(args.GetValue(i)); 6040 argValues.push_back(args.GetValue(i));
6104 if (FXJSE_Value_IsArray(argValues[i].get())) { 6041 if (FXJSE_Value_IsArray(argValues[i].get())) {
6105 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 6042 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
6106 FXJSE_Value_GetObjectProp(argValues[i].get(), "length", 6043 argValues[i]->GetObjectProperty("length", lengthValue.get());
6107 lengthValue.get()); 6044 int32_t length = lengthValue->ToInteger();
6108 int32_t length = FXJSE_Value_ToInteger(lengthValue.get());
6109 iLength = iLength + ((length > 2) ? (length - 2) : 0); 6045 iLength = iLength + ((length > 2) ? (length - 2) : 0);
6110 } 6046 }
6111 iLength += 1; 6047 iLength += 1;
6112 } 6048 }
6113 CFXJSE_Value** returnValues = FX_Alloc(CFXJSE_Value*, iLength); 6049 CFXJSE_Value** returnValues = FX_Alloc(CFXJSE_Value*, iLength);
6114 for (int32_t i = 0; i < (int32_t)iLength; i++) 6050 for (int32_t i = 0; i < (int32_t)iLength; i++)
6115 returnValues[i] = new CFXJSE_Value(pIsolate); 6051 returnValues[i] = new CFXJSE_Value(pIsolate);
6116 6052
6117 int32_t index = 0; 6053 int32_t index = 0;
6118 for (int32_t i = 0; i < argc; i++) { 6054 for (int32_t i = 0; i < argc; i++) {
6119 if (FXJSE_Value_IsArray(argValues[i].get())) { 6055 if (FXJSE_Value_IsArray(argValues[i].get())) {
6120 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 6056 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
6121 FXJSE_Value_GetObjectProp(argValues[i].get(), "length", 6057 argValues[i]->GetObjectProperty("length", lengthValue.get());
6122 lengthValue.get()); 6058 int32_t length = lengthValue->ToInteger();
6123 int32_t length = FXJSE_Value_ToInteger(lengthValue.get());
6124 for (int32_t j = 2; j < length; j++) { 6059 for (int32_t j = 2; j < length; j++) {
6125 FXJSE_Value_GetObjectPropByIdx(argValues[i].get(), j, 6060 argValues[i]->GetObjectPropertyByIdx(j, returnValues[index]);
6126 returnValues[index]);
6127 index++; 6061 index++;
6128 } 6062 }
6129 } 6063 }
6130 FXJSE_Value_Set(returnValues[index], argValues[i].get()); 6064 returnValues[index]->Assign(argValues[i].get());
6131 index++; 6065 index++;
6132 } 6066 }
6133 FXJSE_Value_SetArray(args.GetReturnValue(), iLength, returnValues); 6067 args.GetReturnValue()->SetArray(iLength, returnValues);
6134 for (int32_t i = 0; i < (int32_t)iLength; i++) 6068 for (int32_t i = 0; i < (int32_t)iLength; i++)
6135 delete returnValues[i]; 6069 delete returnValues[i];
6136 6070
6137 FX_Free(returnValues); 6071 FX_Free(returnValues);
6138 } 6072 }
6139 6073
6140 // static 6074 // static
6141 std::unique_ptr<CFXJSE_Value> CXFA_FM2JSContext::GetSimpleValue( 6075 std::unique_ptr<CFXJSE_Value> CXFA_FM2JSContext::GetSimpleValue(
6142 CFXJSE_Value* pThis, 6076 CFXJSE_Value* pThis,
6143 CFXJSE_Arguments& args, 6077 CFXJSE_Arguments& args,
6144 uint32_t index) { 6078 uint32_t index) {
6145 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); 6079 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime();
6146 ASSERT(index < (uint32_t)args.GetLength()); 6080 ASSERT(index < (uint32_t)args.GetLength());
6147 std::unique_ptr<CFXJSE_Value> argIndex = args.GetValue(index); 6081 std::unique_ptr<CFXJSE_Value> argIndex = args.GetValue(index);
6148 if (FXJSE_Value_IsArray(argIndex.get())) { 6082 if (FXJSE_Value_IsArray(argIndex.get())) {
6149 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 6083 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
6150 FXJSE_Value_GetObjectProp(argIndex.get(), "length", lengthValue.get()); 6084 argIndex->GetObjectProperty("length", lengthValue.get());
6151 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); 6085 int32_t iLength = lengthValue->ToInteger();
6152 std::unique_ptr<CFXJSE_Value> simpleValue(new CFXJSE_Value(pIsolate)); 6086 std::unique_ptr<CFXJSE_Value> simpleValue(new CFXJSE_Value(pIsolate));
6153 if (iLength > 2) { 6087 if (iLength > 2) {
6154 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 6088 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
6155 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 6089 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
6156 FXJSE_Value_GetObjectPropByIdx(argIndex.get(), 1, propertyValue.get()); 6090 argIndex->GetObjectPropertyByIdx(1, propertyValue.get());
6157 FXJSE_Value_GetObjectPropByIdx(argIndex.get(), 2, jsObjectValue.get()); 6091 argIndex->GetObjectPropertyByIdx(2, jsObjectValue.get());
6158 if (FXJSE_Value_IsNull(propertyValue.get())) { 6092 if (FXJSE_Value_IsNull(propertyValue.get())) {
6159 GetObjectDefaultValue(jsObjectValue.get(), simpleValue.get()); 6093 GetObjectDefaultValue(jsObjectValue.get(), simpleValue.get());
6160 } else { 6094 } else {
6161 CFX_ByteString propertyStr; 6095 CFX_ByteString propertyStr;
6162 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); 6096 propertyValue->ToString(propertyStr);
6163 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), 6097 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
6164 simpleValue.get()); 6098 simpleValue.get());
6165 } 6099 }
6166 } else { 6100 } else {
6167 FXJSE_Value_SetUndefined(simpleValue.get()); 6101 simpleValue.get()->SetUndefined();
6168 } 6102 }
6169 return simpleValue; 6103 return simpleValue;
6170 } else if (FXJSE_Value_IsObject(argIndex.get())) { 6104 } else if (FXJSE_Value_IsObject(argIndex.get())) {
6171 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); 6105 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate));
6172 GetObjectDefaultValue(argIndex.get(), defaultValue.get()); 6106 GetObjectDefaultValue(argIndex.get(), defaultValue.get());
6173 return defaultValue; 6107 return defaultValue;
6174 } else { 6108 } else {
6175 return argIndex; 6109 return argIndex;
6176 } 6110 }
6177 } 6111 }
6178 6112
6179 // static 6113 // static
6180 FX_BOOL CXFA_FM2JSContext::ValueIsNull(CFXJSE_Value* pThis, CFXJSE_Value* arg) { 6114 FX_BOOL CXFA_FM2JSContext::ValueIsNull(CFXJSE_Value* pThis, CFXJSE_Value* arg) {
6181 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); 6115 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime();
6182 FX_BOOL isNull = FALSE; 6116 FX_BOOL isNull = FALSE;
6183 if (FXJSE_Value_IsNull(arg)) { 6117 if (FXJSE_Value_IsNull(arg)) {
6184 isNull = TRUE; 6118 isNull = TRUE;
6185 } else if (FXJSE_Value_IsArray(arg)) { 6119 } else if (FXJSE_Value_IsArray(arg)) {
6186 int32_t iLength = hvalue_get_array_length(pThis, arg); 6120 int32_t iLength = hvalue_get_array_length(pThis, arg);
6187 if (iLength > 2) { 6121 if (iLength > 2) {
6188 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 6122 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
6189 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 6123 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
6190 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue.get()); 6124 arg->GetObjectPropertyByIdx(1, propertyValue.get());
6191 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsObjectValue.get()); 6125 arg->GetObjectPropertyByIdx(2, jsObjectValue.get());
6192 if (FXJSE_Value_IsNull(propertyValue.get())) { 6126 if (FXJSE_Value_IsNull(propertyValue.get())) {
6193 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); 6127 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate));
6194 GetObjectDefaultValue(jsObjectValue.get(), defaultValue.get()); 6128 GetObjectDefaultValue(jsObjectValue.get(), defaultValue.get());
6195 if (FXJSE_Value_IsNull(defaultValue.get())) { 6129 if (FXJSE_Value_IsNull(defaultValue.get())) {
6196 isNull = TRUE; 6130 isNull = TRUE;
6197 } 6131 }
6198 } else { 6132 } else {
6199 CFX_ByteString propertyStr; 6133 CFX_ByteString propertyStr;
6200 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); 6134 propertyValue->ToString(propertyStr);
6201 std::unique_ptr<CFXJSE_Value> newPropertyValue( 6135 std::unique_ptr<CFXJSE_Value> newPropertyValue(
6202 new CFXJSE_Value(pIsolate)); 6136 new CFXJSE_Value(pIsolate));
6203 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), 6137 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
6204 newPropertyValue.get()); 6138 newPropertyValue.get());
6205 if (FXJSE_Value_IsNull(newPropertyValue.get())) { 6139 if (FXJSE_Value_IsNull(newPropertyValue.get())) {
6206 isNull = TRUE; 6140 isNull = TRUE;
6207 } 6141 }
6208 } 6142 }
6209 } else { 6143 } else {
6210 isNull = TRUE; 6144 isNull = TRUE;
6211 } 6145 }
6212 } else if (FXJSE_Value_IsObject(arg)) { 6146 } else if (FXJSE_Value_IsObject(arg)) {
6213 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); 6147 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate));
6214 GetObjectDefaultValue(arg, defaultValue.get()); 6148 GetObjectDefaultValue(arg, defaultValue.get());
6215 if (FXJSE_Value_IsNull(defaultValue.get())) { 6149 if (FXJSE_Value_IsNull(defaultValue.get())) {
6216 isNull = TRUE; 6150 isNull = TRUE;
6217 } 6151 }
6218 } 6152 }
6219 return isNull; 6153 return isNull;
6220 } 6154 }
6221 6155
6222 // static 6156 // static
6223 int32_t CXFA_FM2JSContext::hvalue_get_array_length(CFXJSE_Value* pThis, 6157 int32_t CXFA_FM2JSContext::hvalue_get_array_length(CFXJSE_Value* pThis,
6224 CFXJSE_Value* arg) { 6158 CFXJSE_Value* arg) {
6225 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); 6159 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime();
6226 int32_t iLength = 0; 6160 int32_t iLength = 0;
6227 if (FXJSE_Value_IsArray(arg)) { 6161 if (FXJSE_Value_IsArray(arg)) {
6228 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 6162 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
6229 FXJSE_Value_GetObjectProp(arg, "length", lengthValue.get()); 6163 arg->GetObjectProperty("length", lengthValue.get());
6230 iLength = FXJSE_Value_ToInteger(lengthValue.get()); 6164 iLength = lengthValue->ToInteger();
6231 } 6165 }
6232 return iLength; 6166 return iLength;
6233 } 6167 }
6234 6168
6235 // static 6169 // static
6236 FX_BOOL CXFA_FM2JSContext::simpleValueCompare(CFXJSE_Value* pThis, 6170 FX_BOOL CXFA_FM2JSContext::simpleValueCompare(CFXJSE_Value* pThis,
6237 CFXJSE_Value* firstValue, 6171 CFXJSE_Value* firstValue,
6238 CFXJSE_Value* secondValue) { 6172 CFXJSE_Value* secondValue) {
6239 FX_BOOL bReturn = FALSE; 6173 FX_BOOL bReturn = FALSE;
6240 if (FXJSE_Value_IsUTF8String(firstValue)) { 6174 if (FXJSE_Value_IsUTF8String(firstValue)) {
6241 CFX_ByteString firstString, secondString; 6175 CFX_ByteString firstString, secondString;
6242 ValueToUTF8String(firstValue, firstString); 6176 ValueToUTF8String(firstValue, firstString);
6243 ValueToUTF8String(secondValue, secondString); 6177 ValueToUTF8String(secondValue, secondString);
6244 bReturn = firstString == secondString; 6178 bReturn = firstString == secondString;
6245 } else if (FXJSE_Value_IsNumber(firstValue)) { 6179 } else if (FXJSE_Value_IsNumber(firstValue)) {
6246 FX_FLOAT first = ValueToFloat(pThis, firstValue); 6180 FX_FLOAT first = ValueToFloat(pThis, firstValue);
6247 FX_FLOAT second = ValueToFloat(pThis, secondValue); 6181 FX_FLOAT second = ValueToFloat(pThis, secondValue);
6248 bReturn = (first == second); 6182 bReturn = (first == second);
6249 } else if (FXJSE_Value_IsBoolean(firstValue)) { 6183 } else if (FXJSE_Value_IsBoolean(firstValue)) {
6250 bReturn = (FXJSE_Value_ToBoolean(firstValue) == 6184 bReturn = (firstValue->ToBoolean() == secondValue->ToBoolean());
6251 FXJSE_Value_ToBoolean(secondValue));
6252 } else if (FXJSE_Value_IsNull(firstValue) && 6185 } else if (FXJSE_Value_IsNull(firstValue) &&
6253 FXJSE_Value_IsNull(secondValue)) { 6186 FXJSE_Value_IsNull(secondValue)) {
6254 bReturn = TRUE; 6187 bReturn = TRUE;
6255 } 6188 }
6256 return bReturn; 6189 return bReturn;
6257 } 6190 }
6258 6191
6259 // static 6192 // static
6260 void CXFA_FM2JSContext::unfoldArgs(CFXJSE_Value* pThis, 6193 void CXFA_FM2JSContext::unfoldArgs(CFXJSE_Value* pThis,
6261 CFXJSE_Arguments& args, 6194 CFXJSE_Arguments& args,
6262 CFXJSE_Value**& resultValues, 6195 CFXJSE_Value**& resultValues,
6263 int32_t& iCount, 6196 int32_t& iCount,
6264 int32_t iStart) { 6197 int32_t iStart) {
6265 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); 6198 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime();
6266 iCount = 0; 6199 iCount = 0;
6267 int32_t argc = args.GetLength(); 6200 int32_t argc = args.GetLength();
6268 std::vector<std::unique_ptr<CFXJSE_Value>> argsValue; 6201 std::vector<std::unique_ptr<CFXJSE_Value>> argsValue;
6269 for (int32_t i = 0; i < argc - iStart; i++) { 6202 for (int32_t i = 0; i < argc - iStart; i++) {
6270 argsValue.push_back(args.GetValue(i + iStart)); 6203 argsValue.push_back(args.GetValue(i + iStart));
6271 if (FXJSE_Value_IsArray(argsValue[i].get())) { 6204 if (FXJSE_Value_IsArray(argsValue[i].get())) {
6272 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 6205 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
6273 FXJSE_Value_GetObjectProp(argsValue[i].get(), "length", 6206 argsValue[i]->GetObjectProperty("length", lengthValue.get());
6274 lengthValue.get()); 6207 int32_t iLength = lengthValue->ToInteger();
6275 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get());
6276 iCount += ((iLength > 2) ? (iLength - 2) : 0); 6208 iCount += ((iLength > 2) ? (iLength - 2) : 0);
6277 } else { 6209 } else {
6278 iCount += 1; 6210 iCount += 1;
6279 } 6211 }
6280 } 6212 }
6281 resultValues = FX_Alloc(CFXJSE_Value*, iCount); 6213 resultValues = FX_Alloc(CFXJSE_Value*, iCount);
6282 for (int32_t i = 0; i < iCount; i++) 6214 for (int32_t i = 0; i < iCount; i++)
6283 resultValues[i] = new CFXJSE_Value(pIsolate); 6215 resultValues[i] = new CFXJSE_Value(pIsolate);
6284 6216
6285 int32_t index = 0; 6217 int32_t index = 0;
6286 for (int32_t i = 0; i < argc - iStart; i++) { 6218 for (int32_t i = 0; i < argc - iStart; i++) {
6287 if (FXJSE_Value_IsArray(argsValue[i].get())) { 6219 if (FXJSE_Value_IsArray(argsValue[i].get())) {
6288 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 6220 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
6289 FXJSE_Value_GetObjectProp(argsValue[i].get(), "length", 6221 argsValue[i]->GetObjectProperty("length", lengthValue.get());
6290 lengthValue.get()); 6222 int32_t iLength = lengthValue->ToInteger();
6291 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get());
6292 if (iLength > 2) { 6223 if (iLength > 2) {
6293 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 6224 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
6294 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 6225 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
6295 FXJSE_Value_GetObjectPropByIdx(argsValue[i].get(), 1, 6226 argsValue[i]->GetObjectPropertyByIdx(1, propertyValue.get());
6296 propertyValue.get());
6297 if (FXJSE_Value_IsNull(propertyValue.get())) { 6227 if (FXJSE_Value_IsNull(propertyValue.get())) {
6298 for (int32_t j = 2; j < iLength; j++) { 6228 for (int32_t j = 2; j < iLength; j++) {
6299 FXJSE_Value_GetObjectPropByIdx(argsValue[i].get(), j, 6229 argsValue[i]->GetObjectPropertyByIdx(j, jsObjectValue.get());
6300 jsObjectValue.get());
6301 GetObjectDefaultValue(jsObjectValue.get(), resultValues[index]); 6230 GetObjectDefaultValue(jsObjectValue.get(), resultValues[index]);
6302 index++; 6231 index++;
6303 } 6232 }
6304 } else { 6233 } else {
6305 CFX_ByteString propertyString; 6234 CFX_ByteString propertyString;
6306 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyString); 6235 propertyValue->ToString(propertyString);
6307 for (int32_t j = 2; j < iLength; j++) { 6236 for (int32_t j = 2; j < iLength; j++) {
6308 FXJSE_Value_GetObjectPropByIdx(argsValue[i].get(), j, 6237 argsValue[i]->GetObjectPropertyByIdx(j, jsObjectValue.get());
6309 jsObjectValue.get()); 6238 jsObjectValue->GetObjectProperty(propertyString.AsStringC(),
6310 FXJSE_Value_GetObjectProp(jsObjectValue.get(), 6239 resultValues[index]);
6311 propertyString.AsStringC(),
6312 resultValues[index]);
6313 index++; 6240 index++;
6314 } 6241 }
6315 } 6242 }
6316 } 6243 }
6317 } else if (FXJSE_Value_IsObject(argsValue[i].get())) { 6244 } else if (FXJSE_Value_IsObject(argsValue[i].get())) {
6318 GetObjectDefaultValue(argsValue[i].get(), resultValues[index]); 6245 GetObjectDefaultValue(argsValue[i].get(), resultValues[index]);
6319 index++; 6246 index++;
6320 } else { 6247 } else {
6321 FXJSE_Value_Set(resultValues[index], argsValue[i].get()); 6248 resultValues[index]->Assign(argsValue[i].get());
6322 index++; 6249 index++;
6323 } 6250 }
6324 } 6251 }
6325 } 6252 }
6326 6253
6327 // static 6254 // static
6328 void CXFA_FM2JSContext::GetObjectDefaultValue(CFXJSE_Value* pValue, 6255 void CXFA_FM2JSContext::GetObjectDefaultValue(CFXJSE_Value* pValue,
6329 CFXJSE_Value* pDefaultValue) { 6256 CFXJSE_Value* pDefaultValue) {
6330 CXFA_Node* pNode = ToNode(CXFA_ScriptContext::ToObject(pValue, nullptr)); 6257 CXFA_Node* pNode = ToNode(CXFA_ScriptContext::ToObject(pValue, nullptr));
6331 if (!pNode) { 6258 if (!pNode) {
6332 FXJSE_Value_SetNull(pDefaultValue); 6259 pDefaultValue->SetNull();
6333 return; 6260 return;
6334 } 6261 }
6335 pNode->Script_Som_DefaultValue(pDefaultValue, FALSE, (XFA_ATTRIBUTE)-1); 6262 pNode->Script_Som_DefaultValue(pDefaultValue, FALSE, (XFA_ATTRIBUTE)-1);
6336 } 6263 }
6337 6264
6338 // static 6265 // static
6339 FX_BOOL CXFA_FM2JSContext::SetObjectDefaultValue(CFXJSE_Value* pValue, 6266 FX_BOOL CXFA_FM2JSContext::SetObjectDefaultValue(CFXJSE_Value* pValue,
6340 CFXJSE_Value* hNewValue) { 6267 CFXJSE_Value* hNewValue) {
6341 CXFA_Node* pNode = ToNode(CXFA_ScriptContext::ToObject(pValue, nullptr)); 6268 CXFA_Node* pNode = ToNode(CXFA_ScriptContext::ToObject(pValue, nullptr));
6342 if (!pNode) 6269 if (!pNode)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
6389 } 6316 }
6390 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); 6317 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext();
6391 XFA_RESOLVENODE_RS resoveNodeRS; 6318 XFA_RESOLVENODE_RS resoveNodeRS;
6392 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | 6319 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
6393 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; 6320 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent;
6394 int32_t iRet = pScriptContext->ResolveObjects( 6321 int32_t iRet = pScriptContext->ResolveObjects(
6395 pScriptContext->GetThisObject(), 6322 pScriptContext->GetThisObject(),
6396 CFX_WideString::FromUTF8(szAccessorName).AsStringC(), resoveNodeRS, 6323 CFX_WideString::FromUTF8(szAccessorName).AsStringC(), resoveNodeRS,
6397 dwFlags); 6324 dwFlags);
6398 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { 6325 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) {
6399 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( 6326 accessorValue->Assign(
6400 resoveNodeRS.nodes.GetAt(0))); 6327 pScriptContext->GetJSValueFromMap(resoveNodeRS.nodes.GetAt(0)));
6401 bFlags = TRUE; 6328 bFlags = TRUE;
6402 } 6329 }
6403 return bFlags; 6330 return bFlags;
6404 } 6331 }
6405 6332
6406 // static 6333 // static
6407 int32_t CXFA_FM2JSContext::ResolveObjects(CFXJSE_Value* pThis, 6334 int32_t CXFA_FM2JSContext::ResolveObjects(CFXJSE_Value* pThis,
6408 CFXJSE_Value* pRefValue, 6335 CFXJSE_Value* pRefValue,
6409 const CFX_ByteStringC& bsSomExp, 6336 const CFX_ByteStringC& bsSomExp,
6410 XFA_RESOLVENODE_RS& resoveNodeRS, 6337 XFA_RESOLVENODE_RS& resoveNodeRS,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
6465 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); 6392 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr);
6466 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); 6393 v8::Isolate* pIsolate = pContext->GetScriptRuntime();
6467 iSize = 0; 6394 iSize = 0;
6468 resultValues = nullptr; 6395 resultValues = nullptr;
6469 if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { 6396 if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) {
6470 bAttribute = FALSE; 6397 bAttribute = FALSE;
6471 iSize = resoveNodeRS.nodes.GetSize(); 6398 iSize = resoveNodeRS.nodes.GetSize();
6472 resultValues = FX_Alloc(CFXJSE_Value*, iSize); 6399 resultValues = FX_Alloc(CFXJSE_Value*, iSize);
6473 for (int32_t i = 0; i < iSize; i++) { 6400 for (int32_t i = 0; i < iSize; i++) {
6474 resultValues[i] = new CFXJSE_Value(pIsolate); 6401 resultValues[i] = new CFXJSE_Value(pIsolate);
6475 FXJSE_Value_Set( 6402 resultValues[i]->Assign(
6476 resultValues[i],
6477 pContext->GetDocument()->GetScriptContext()->GetJSValueFromMap( 6403 pContext->GetDocument()->GetScriptContext()->GetJSValueFromMap(
6478 resoveNodeRS.nodes.GetAt(i))); 6404 resoveNodeRS.nodes.GetAt(i)));
6479 } 6405 }
6480 } else { 6406 } else {
6481 CXFA_ValueArray objectProperties(pIsolate); 6407 CXFA_ValueArray objectProperties(pIsolate);
6482 int32_t iRet = resoveNodeRS.GetAttributeResult(objectProperties); 6408 int32_t iRet = resoveNodeRS.GetAttributeResult(objectProperties);
6483 bAttribute = (iRet == 0); 6409 bAttribute = (iRet == 0);
6484 if (bAttribute) { 6410 if (bAttribute) {
6485 if (FXJSE_Value_IsObject(pParentValue)) { 6411 if (FXJSE_Value_IsObject(pParentValue)) {
6486 iSize = 1; 6412 iSize = 1;
6487 resultValues = FX_Alloc(CFXJSE_Value*, 1); 6413 resultValues = FX_Alloc(CFXJSE_Value*, 1);
6488 resultValues[0] = new CFXJSE_Value(pIsolate); 6414 resultValues[0] = new CFXJSE_Value(pIsolate);
6489 FXJSE_Value_Set(resultValues[0], pParentValue); 6415 resultValues[0]->Assign(pParentValue);
6490 } 6416 }
6491 } else { 6417 } else {
6492 iSize = iRet; 6418 iSize = iRet;
6493 resultValues = FX_Alloc(CFXJSE_Value*, iSize); 6419 resultValues = FX_Alloc(CFXJSE_Value*, iSize);
6494 for (int32_t i = 0; i < iSize; i++) { 6420 for (int32_t i = 0; i < iSize; i++) {
6495 resultValues[i] = new CFXJSE_Value(pIsolate); 6421 resultValues[i] = new CFXJSE_Value(pIsolate);
6496 FXJSE_Value_Set(resultValues[i], objectProperties[i]); 6422 resultValues[i]->Assign(objectProperties[i]);
6497 } 6423 }
6498 } 6424 }
6499 } 6425 }
6500 } 6426 }
6501 6427
6502 // static 6428 // static
6503 int32_t CXFA_FM2JSContext::ValueToInteger(CFXJSE_Value* pThis, 6429 int32_t CXFA_FM2JSContext::ValueToInteger(CFXJSE_Value* pThis,
6504 CFXJSE_Value* pValue) { 6430 CFXJSE_Value* pValue) {
6505 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); 6431 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime();
6506 int32_t iValue = 0; 6432 int32_t iValue = 0;
6507 if (FXJSE_Value_IsArray(pValue)) { 6433 if (FXJSE_Value_IsArray(pValue)) {
6508 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 6434 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
6509 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 6435 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
6510 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); 6436 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate));
6511 FXJSE_Value_GetObjectPropByIdx(pValue, 1, propertyValue.get()); 6437 pValue->GetObjectPropertyByIdx(1, propertyValue.get());
6512 FXJSE_Value_GetObjectPropByIdx(pValue, 2, jsObjectValue.get()); 6438 pValue->GetObjectPropertyByIdx(2, jsObjectValue.get());
6513 if (FXJSE_Value_IsNull(propertyValue.get())) { 6439 if (FXJSE_Value_IsNull(propertyValue.get())) {
6514 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); 6440 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get());
6515 } else { 6441 } else {
6516 CFX_ByteString propertyStr; 6442 CFX_ByteString propertyStr;
6517 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); 6443 propertyValue->ToString(propertyStr);
6518 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), 6444 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
6519 newPropertyValue.get()); 6445 newPropertyValue.get());
6520 } 6446 }
6521 iValue = ValueToInteger(pThis, newPropertyValue.get()); 6447 iValue = ValueToInteger(pThis, newPropertyValue.get());
6522 return iValue; 6448 return iValue;
6523 } else if (FXJSE_Value_IsObject(pValue)) { 6449 } else if (FXJSE_Value_IsObject(pValue)) {
6524 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); 6450 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate));
6525 GetObjectDefaultValue(pValue, newPropertyValue.get()); 6451 GetObjectDefaultValue(pValue, newPropertyValue.get());
6526 iValue = ValueToInteger(pThis, newPropertyValue.get()); 6452 iValue = ValueToInteger(pThis, newPropertyValue.get());
6527 return iValue; 6453 return iValue;
6528 } else if (FXJSE_Value_IsUTF8String(pValue)) { 6454 } else if (FXJSE_Value_IsUTF8String(pValue)) {
6529 CFX_ByteString szValue; 6455 CFX_ByteString szValue;
6530 FXJSE_Value_ToUTF8String(pValue, szValue); 6456 pValue->ToString(szValue);
6531 iValue = FXSYS_atoi(szValue.c_str()); 6457 iValue = FXSYS_atoi(szValue.c_str());
6532 } else { 6458 } else {
6533 iValue = FXJSE_Value_ToInteger(pValue); 6459 iValue = pValue->ToInteger();
6534 } 6460 }
6535 return iValue; 6461 return iValue;
6536 } 6462 }
6537 6463
6538 // static 6464 // static
6539 FX_FLOAT CXFA_FM2JSContext::ValueToFloat(CFXJSE_Value* pThis, 6465 FX_FLOAT CXFA_FM2JSContext::ValueToFloat(CFXJSE_Value* pThis,
6540 CFXJSE_Value* arg) { 6466 CFXJSE_Value* arg) {
6541 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); 6467 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime();
6542 FX_FLOAT fRet = 0.0f; 6468 FX_FLOAT fRet = 0.0f;
6543 if (FXJSE_Value_IsArray(arg)) { 6469 if (FXJSE_Value_IsArray(arg)) {
6544 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 6470 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
6545 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 6471 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
6546 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); 6472 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate));
6547 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue.get()); 6473 arg->GetObjectPropertyByIdx(1, propertyValue.get());
6548 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsObjectValue.get()); 6474 arg->GetObjectPropertyByIdx(2, jsObjectValue.get());
6549 if (FXJSE_Value_IsNull(propertyValue.get())) { 6475 if (FXJSE_Value_IsNull(propertyValue.get())) {
6550 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); 6476 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get());
6551 } else { 6477 } else {
6552 CFX_ByteString propertyStr; 6478 CFX_ByteString propertyStr;
6553 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); 6479 propertyValue->ToString(propertyStr);
6554 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), 6480 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
6555 newPropertyValue.get()); 6481 newPropertyValue.get());
6556 } 6482 }
6557 fRet = ValueToFloat(pThis, newPropertyValue.get()); 6483 fRet = ValueToFloat(pThis, newPropertyValue.get());
6558 } else if (FXJSE_Value_IsObject(arg)) { 6484 } else if (FXJSE_Value_IsObject(arg)) {
6559 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); 6485 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate));
6560 GetObjectDefaultValue(arg, newPropertyValue.get()); 6486 GetObjectDefaultValue(arg, newPropertyValue.get());
6561 fRet = ValueToFloat(pThis, newPropertyValue.get()); 6487 fRet = ValueToFloat(pThis, newPropertyValue.get());
6562 } else if (FXJSE_Value_IsUTF8String(arg)) { 6488 } else if (FXJSE_Value_IsUTF8String(arg)) {
6563 CFX_ByteString bsOutput; 6489 CFX_ByteString bsOutput;
6564 FXJSE_Value_ToUTF8String(arg, bsOutput); 6490 arg->ToString(bsOutput);
6565 fRet = (FX_FLOAT)XFA_ByteStringToDouble(bsOutput.AsStringC()); 6491 fRet = (FX_FLOAT)XFA_ByteStringToDouble(bsOutput.AsStringC());
6566 } else if (FXJSE_Value_IsUndefined(arg)) { 6492 } else if (FXJSE_Value_IsUndefined(arg)) {
6567 fRet = 0; 6493 fRet = 0;
6568 } else { 6494 } else {
6569 fRet = FXJSE_Value_ToFloat(arg); 6495 fRet = arg->ToFloat();
6570 } 6496 }
6571 return fRet; 6497 return fRet;
6572 } 6498 }
6573 6499
6574 // static 6500 // static
6575 FX_DOUBLE CXFA_FM2JSContext::ValueToDouble(CFXJSE_Value* pThis, 6501 FX_DOUBLE CXFA_FM2JSContext::ValueToDouble(CFXJSE_Value* pThis,
6576 CFXJSE_Value* arg) { 6502 CFXJSE_Value* arg) {
6577 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); 6503 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime();
6578 FX_DOUBLE dRet = 0; 6504 FX_DOUBLE dRet = 0;
6579 if (FXJSE_Value_IsArray(arg)) { 6505 if (FXJSE_Value_IsArray(arg)) {
6580 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 6506 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
6581 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 6507 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
6582 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); 6508 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate));
6583 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue.get()); 6509 arg->GetObjectPropertyByIdx(1, propertyValue.get());
6584 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsObjectValue.get()); 6510 arg->GetObjectPropertyByIdx(2, jsObjectValue.get());
6585 if (FXJSE_Value_IsNull(propertyValue.get())) { 6511 if (FXJSE_Value_IsNull(propertyValue.get())) {
6586 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); 6512 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get());
6587 } else { 6513 } else {
6588 CFX_ByteString propertyStr; 6514 CFX_ByteString propertyStr;
6589 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); 6515 propertyValue->ToString(propertyStr);
6590 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), 6516 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
6591 newPropertyValue.get()); 6517 newPropertyValue.get());
6592 } 6518 }
6593 dRet = ValueToDouble(pThis, newPropertyValue.get()); 6519 dRet = ValueToDouble(pThis, newPropertyValue.get());
6594 } else if (FXJSE_Value_IsObject(arg)) { 6520 } else if (FXJSE_Value_IsObject(arg)) {
6595 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); 6521 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate));
6596 GetObjectDefaultValue(arg, newPropertyValue.get()); 6522 GetObjectDefaultValue(arg, newPropertyValue.get());
6597 dRet = ValueToDouble(pThis, newPropertyValue.get()); 6523 dRet = ValueToDouble(pThis, newPropertyValue.get());
6598 } else if (FXJSE_Value_IsUTF8String(arg)) { 6524 } else if (FXJSE_Value_IsUTF8String(arg)) {
6599 CFX_ByteString bsOutput; 6525 CFX_ByteString bsOutput;
6600 FXJSE_Value_ToUTF8String(arg, bsOutput); 6526 arg->ToString(bsOutput);
6601 dRet = XFA_ByteStringToDouble(bsOutput.AsStringC()); 6527 dRet = XFA_ByteStringToDouble(bsOutput.AsStringC());
6602 } else if (FXJSE_Value_IsUndefined(arg)) { 6528 } else if (FXJSE_Value_IsUndefined(arg)) {
6603 dRet = 0; 6529 dRet = 0;
6604 } else { 6530 } else {
6605 dRet = FXJSE_Value_ToDouble(arg); 6531 dRet = arg->ToDouble();
6606 } 6532 }
6607 return dRet; 6533 return dRet;
6608 } 6534 }
6609 6535
6610 // static. 6536 // static.
6611 double CXFA_FM2JSContext::ExtractDouble(CFXJSE_Value* pThis, 6537 double CXFA_FM2JSContext::ExtractDouble(CFXJSE_Value* pThis,
6612 CFXJSE_Value* src, 6538 CFXJSE_Value* src,
6613 bool* ret) { 6539 bool* ret) {
6614 ASSERT(ret); 6540 ASSERT(ret);
6615 6541
6616 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); 6542 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime();
6617 *ret = true; 6543 *ret = true;
6618 6544
6619 if (FXJSE_Value_IsArray(src)) { 6545 if (FXJSE_Value_IsArray(src)) {
6620 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); 6546 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate));
6621 FXJSE_Value_GetObjectProp(src, "length", lengthValue.get()); 6547 src->GetObjectProperty("length", lengthValue.get());
6622 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); 6548 int32_t iLength = lengthValue->ToInteger();
6623 if (iLength <= 2) { 6549 if (iLength <= 2) {
6624 *ret = false; 6550 *ret = false;
6625 return 0.0; 6551 return 0.0;
6626 } 6552 }
6627 6553
6628 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); 6554 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate));
6629 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); 6555 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate));
6630 FXJSE_Value_GetObjectPropByIdx(src, 1, propertyValue.get()); 6556 src->GetObjectPropertyByIdx(1, propertyValue.get());
6631 FXJSE_Value_GetObjectPropByIdx(src, 2, jsObjectValue.get()); 6557 src->GetObjectPropertyByIdx(2, jsObjectValue.get());
6632 if (FXJSE_Value_IsNull(propertyValue.get())) 6558 if (FXJSE_Value_IsNull(propertyValue.get()))
6633 return ValueToDouble(pThis, jsObjectValue.get()); 6559 return ValueToDouble(pThis, jsObjectValue.get());
6634 6560
6635 CFX_ByteString propertyStr; 6561 CFX_ByteString propertyStr;
6636 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); 6562 propertyValue->ToString(propertyStr);
6637 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); 6563 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate));
6638 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), 6564 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(),
6639 newPropertyValue.get()); 6565 newPropertyValue.get());
6640 return ValueToDouble(pThis, newPropertyValue.get()); 6566 return ValueToDouble(pThis, newPropertyValue.get());
6641 } 6567 }
6642 return ValueToDouble(pThis, src); 6568 return ValueToDouble(pThis, src);
6643 } 6569 }
6644 6570
6645 // static 6571 // static
6646 void CXFA_FM2JSContext::ValueToUTF8String(CFXJSE_Value* arg, 6572 void CXFA_FM2JSContext::ValueToUTF8String(CFXJSE_Value* arg,
6647 CFX_ByteString& szOutputString) { 6573 CFX_ByteString& szOutputString) {
6648 if (FXJSE_Value_IsNull(arg) || FXJSE_Value_IsUndefined(arg)) { 6574 if (FXJSE_Value_IsNull(arg) || FXJSE_Value_IsUndefined(arg)) {
6649 szOutputString = ""; 6575 szOutputString = "";
6650 } else if (FXJSE_Value_IsBoolean(arg)) { 6576 } else if (FXJSE_Value_IsBoolean(arg)) {
6651 szOutputString = FXJSE_Value_ToBoolean(arg) ? "1" : "0"; 6577 szOutputString = arg->ToBoolean() ? "1" : "0";
6652 } else { 6578 } else {
6653 szOutputString = ""; 6579 szOutputString = "";
6654 FXJSE_Value_ToUTF8String(arg, szOutputString); 6580 arg->ToString(szOutputString);
6655 } 6581 }
6656 } 6582 }
6657 6583
6658 // static. 6584 // static.
6659 int32_t CXFA_FM2JSContext::Translate(const CFX_WideStringC& wsFormcalc, 6585 int32_t CXFA_FM2JSContext::Translate(const CFX_WideStringC& wsFormcalc,
6660 CFX_WideTextBuf& wsJavascript, 6586 CFX_WideTextBuf& wsJavascript,
6661 CFX_WideString& wsError) { 6587 CFX_WideString& wsError) {
6662 if (wsFormcalc.IsEmpty()) { 6588 if (wsFormcalc.IsEmpty()) {
6663 wsJavascript.Clear(); 6589 wsJavascript.Clear();
6664 wsError.clear(); 6590 wsError.clear();
(...skipping 15 matching lines...) Expand all
6680 return 0; 6606 return 0;
6681 } 6607 }
6682 6608
6683 CXFA_FM2JSContext::CXFA_FM2JSContext(v8::Isolate* pScriptIsolate, 6609 CXFA_FM2JSContext::CXFA_FM2JSContext(v8::Isolate* pScriptIsolate,
6684 CFXJSE_Context* pScriptContext, 6610 CFXJSE_Context* pScriptContext,
6685 CXFA_Document* pDoc) 6611 CXFA_Document* pDoc)
6686 : m_pIsolate(pScriptIsolate), 6612 : m_pIsolate(pScriptIsolate),
6687 m_pFMClass(FXJSE_DefineClass(pScriptContext, &formcalc_fm2js_descriptor)), 6613 m_pFMClass(FXJSE_DefineClass(pScriptContext, &formcalc_fm2js_descriptor)),
6688 m_pValue(new CFXJSE_Value(pScriptIsolate)), 6614 m_pValue(new CFXJSE_Value(pScriptIsolate)),
6689 m_pDocument(pDoc) { 6615 m_pDocument(pDoc) {
6690 FXJSE_Value_SetNull(m_pValue.get()); 6616 m_pValue.get()->SetNull();
6691 FXJSE_Value_SetObject(m_pValue.get(), this, m_pFMClass); 6617 m_pValue.get()->SetObject(this, m_pFMClass);
6692 } 6618 }
6693 6619
6694 CXFA_FM2JSContext::~CXFA_FM2JSContext() {} 6620 CXFA_FM2JSContext::~CXFA_FM2JSContext() {}
6695 6621
6696 void CXFA_FM2JSContext::GlobalPropertyGetter(CFXJSE_Value* pValue) { 6622 void CXFA_FM2JSContext::GlobalPropertyGetter(CFXJSE_Value* pValue) {
6697 FXJSE_Value_Set(pValue, m_pValue.get()); 6623 pValue->Assign(m_pValue.get());
6698 } 6624 }
6699 6625
6700 void CXFA_FM2JSContext::ThrowException(int32_t iStringID, ...) { 6626 void CXFA_FM2JSContext::ThrowException(int32_t iStringID, ...) {
6701 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); 6627 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider();
6702 ASSERT(pAppProvider); 6628 ASSERT(pAppProvider);
6703 CFX_WideString wsFormat; 6629 CFX_WideString wsFormat;
6704 pAppProvider->LoadString(iStringID, wsFormat); 6630 pAppProvider->LoadString(iStringID, wsFormat);
6705 CFX_WideString wsMessage; 6631 CFX_WideString wsMessage;
6706 va_list arg_ptr; 6632 va_list arg_ptr;
6707 va_start(arg_ptr, iStringID); 6633 va_start(arg_ptr, iStringID);
6708 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); 6634 wsMessage.FormatV(wsFormat.c_str(), arg_ptr);
6709 va_end(arg_ptr); 6635 va_end(arg_ptr);
6710 FXJSE_ThrowMessage( 6636 FXJSE_ThrowMessage(
6711 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); 6637 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC());
6712 } 6638 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_ffwidgetacc.cpp ('k') | xfa/fxfa/parser/xfa_object_imp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698