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