| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" | 7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" |
| 8 | 8 |
| 9 #include <time.h> | 9 #include <time.h> |
| 10 | 10 |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 std::unique_ptr<CFXJSE_Value> defaultPropValue( | 568 std::unique_ptr<CFXJSE_Value> defaultPropValue( |
| 569 new CFXJSE_Value(pIsolate)); | 569 new CFXJSE_Value(pIsolate)); |
| 570 GetObjectDefaultValue(jsObjectValue.get(), defaultPropValue.get()); | 570 GetObjectDefaultValue(jsObjectValue.get(), defaultPropValue.get()); |
| 571 if (defaultPropValue->IsNull()) | 571 if (defaultPropValue->IsNull()) |
| 572 continue; | 572 continue; |
| 573 | 573 |
| 574 dSum += ValueToDouble(pThis, defaultPropValue.get()); | 574 dSum += ValueToDouble(pThis, defaultPropValue.get()); |
| 575 uCount++; | 575 uCount++; |
| 576 } | 576 } |
| 577 } else { | 577 } else { |
| 578 CFX_ByteString propertyStr; | |
| 579 propertyValue->ToString(propertyStr); | |
| 580 for (int32_t j = 2; j < iLength; j++) { | 578 for (int32_t j = 2; j < iLength; j++) { |
| 581 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); | 579 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); |
| 582 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 580 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 583 new CFXJSE_Value(pIsolate)); | 581 new CFXJSE_Value(pIsolate)); |
| 584 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), | 582 jsObjectValue->GetObjectProperty( |
| 585 newPropertyValue.get()); | 583 propertyValue->ToString().AsStringC(), newPropertyValue.get()); |
| 586 if (newPropertyValue->IsNull()) | 584 if (newPropertyValue->IsNull()) |
| 587 continue; | 585 continue; |
| 588 | 586 |
| 589 dSum += ValueToDouble(pThis, newPropertyValue.get()); | 587 dSum += ValueToDouble(pThis, newPropertyValue.get()); |
| 590 uCount++; | 588 uCount++; |
| 591 } | 589 } |
| 592 } | 590 } |
| 593 } | 591 } |
| 594 } | 592 } |
| 595 if (uCount == 0) { | 593 if (uCount == 0) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 argValue->GetObjectPropertyByIdx(1, propertyValue.get()); | 647 argValue->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 650 argValue->GetObjectPropertyByIdx(2, jsObjectValue.get()); | 648 argValue->GetObjectPropertyByIdx(2, jsObjectValue.get()); |
| 651 if (propertyValue->IsNull()) { | 649 if (propertyValue->IsNull()) { |
| 652 for (int32_t j = 2; j < iLength; j++) { | 650 for (int32_t j = 2; j < iLength; j++) { |
| 653 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); | 651 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); |
| 654 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 652 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
| 655 if (!newPropertyValue->IsNull()) | 653 if (!newPropertyValue->IsNull()) |
| 656 iCount++; | 654 iCount++; |
| 657 } | 655 } |
| 658 } else { | 656 } else { |
| 659 CFX_ByteString propertyStr; | |
| 660 propertyValue->ToString(propertyStr); | |
| 661 for (int32_t j = 2; j < iLength; j++) { | 657 for (int32_t j = 2; j < iLength; j++) { |
| 662 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); | 658 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); |
| 663 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), | 659 jsObjectValue->GetObjectProperty( |
| 664 newPropertyValue.get()); | 660 propertyValue->ToString().AsStringC(), newPropertyValue.get()); |
| 665 iCount += newPropertyValue->IsNull() ? 0 : 1; | 661 iCount += newPropertyValue->IsNull() ? 0 : 1; |
| 666 } | 662 } |
| 667 } | 663 } |
| 668 } else if (argValue->IsObject()) { | 664 } else if (argValue->IsObject()) { |
| 669 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 665 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 670 new CFXJSE_Value(pIsolate)); | 666 new CFXJSE_Value(pIsolate)); |
| 671 GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); | 667 GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); |
| 672 if (!newPropertyValue->IsNull()) | 668 if (!newPropertyValue->IsNull()) |
| 673 iCount++; | 669 iCount++; |
| 674 } else { | 670 } else { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); | 727 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); |
| 732 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 728 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
| 733 if (newPropertyValue->IsNull()) | 729 if (newPropertyValue->IsNull()) |
| 734 continue; | 730 continue; |
| 735 | 731 |
| 736 uCount++; | 732 uCount++; |
| 737 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); | 733 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); |
| 738 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); | 734 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); |
| 739 } | 735 } |
| 740 } else { | 736 } else { |
| 741 CFX_ByteString propertyStr; | |
| 742 propertyValue->ToString(propertyStr); | |
| 743 for (int32_t j = 2; j < iLength; j++) { | 737 for (int32_t j = 2; j < iLength; j++) { |
| 744 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); | 738 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); |
| 745 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), | 739 jsObjectValue->GetObjectProperty( |
| 746 newPropertyValue.get()); | 740 propertyValue->ToString().AsStringC(), newPropertyValue.get()); |
| 747 if (newPropertyValue->IsNull()) | 741 if (newPropertyValue->IsNull()) |
| 748 continue; | 742 continue; |
| 749 | 743 |
| 750 uCount++; | 744 uCount++; |
| 751 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); | 745 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); |
| 752 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); | 746 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); |
| 753 } | 747 } |
| 754 } | 748 } |
| 755 } else if (argValue->IsObject()) { | 749 } else if (argValue->IsObject()) { |
| 756 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 750 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); | 803 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); |
| 810 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 804 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
| 811 if (newPropertyValue->IsNull()) | 805 if (newPropertyValue->IsNull()) |
| 812 continue; | 806 continue; |
| 813 | 807 |
| 814 uCount++; | 808 uCount++; |
| 815 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); | 809 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); |
| 816 dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue); | 810 dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue); |
| 817 } | 811 } |
| 818 } else { | 812 } else { |
| 819 CFX_ByteString propertyStr; | |
| 820 propertyValue->ToString(propertyStr); | |
| 821 for (int32_t j = 2; j < iLength; j++) { | 813 for (int32_t j = 2; j < iLength; j++) { |
| 822 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); | 814 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); |
| 823 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), | 815 jsObjectValue->GetObjectProperty( |
| 824 newPropertyValue.get()); | 816 propertyValue->ToString().AsStringC(), newPropertyValue.get()); |
| 825 if (newPropertyValue->IsNull()) | 817 if (newPropertyValue->IsNull()) |
| 826 continue; | 818 continue; |
| 827 | 819 |
| 828 uCount++; | 820 uCount++; |
| 829 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); | 821 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); |
| 830 dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue); | 822 dMinValue = uCount == 1 ? dValue : std::min(dMinValue, dValue); |
| 831 } | 823 } |
| 832 } | 824 } |
| 833 } else if (argValue->IsObject()) { | 825 } else if (argValue->IsObject()) { |
| 834 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 826 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 for (int32_t j = 2; j < iLength; j++) { | 966 for (int32_t j = 2; j < iLength; j++) { |
| 975 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); | 967 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); |
| 976 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 968 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
| 977 if (newPropertyValue->IsNull()) | 969 if (newPropertyValue->IsNull()) |
| 978 continue; | 970 continue; |
| 979 | 971 |
| 980 dSum += ValueToDouble(pThis, jsObjectValue.get()); | 972 dSum += ValueToDouble(pThis, jsObjectValue.get()); |
| 981 uCount++; | 973 uCount++; |
| 982 } | 974 } |
| 983 } else { | 975 } else { |
| 984 CFX_ByteString propertyStr; | |
| 985 propertyValue->ToString(propertyStr); | |
| 986 for (int32_t j = 2; j < iLength; j++) { | 976 for (int32_t j = 2; j < iLength; j++) { |
| 987 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); | 977 argValue->GetObjectPropertyByIdx(j, jsObjectValue.get()); |
| 988 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), | 978 jsObjectValue->GetObjectProperty( |
| 989 newPropertyValue.get()); | 979 propertyValue->ToString().AsStringC(), newPropertyValue.get()); |
| 990 if (newPropertyValue->IsNull()) | 980 if (newPropertyValue->IsNull()) |
| 991 continue; | 981 continue; |
| 992 | 982 |
| 993 dSum += ValueToDouble(pThis, newPropertyValue.get()); | 983 dSum += ValueToDouble(pThis, newPropertyValue.get()); |
| 994 uCount++; | 984 uCount++; |
| 995 } | 985 } |
| 996 } | 986 } |
| 997 } else if (argValue->IsObject()) { | 987 } else if (argValue->IsObject()) { |
| 998 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 988 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 999 new CFXJSE_Value(pIsolate)); | 989 new CFXJSE_Value(pIsolate)); |
| (...skipping 1827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2827 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 2817 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 2828 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 2818 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 2829 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 2819 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 2830 new CFXJSE_Value(pIsolate)); | 2820 new CFXJSE_Value(pIsolate)); |
| 2831 argIndexValue->GetObjectPropertyByIdx(1, propertyValue.get()); | 2821 argIndexValue->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 2832 argIndexValue->GetObjectPropertyByIdx( | 2822 argIndexValue->GetObjectPropertyByIdx( |
| 2833 (iLength - 1) - (iValueIndex - iIndex), jsObjectValue.get()); | 2823 (iLength - 1) - (iValueIndex - iIndex), jsObjectValue.get()); |
| 2834 if (propertyValue->IsNull()) { | 2824 if (propertyValue->IsNull()) { |
| 2835 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 2825 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
| 2836 } else { | 2826 } else { |
| 2837 CFX_ByteString propStr; | 2827 jsObjectValue->GetObjectProperty( |
| 2838 propertyValue->ToString(propStr); | 2828 propertyValue->ToString().AsStringC(), newPropertyValue.get()); |
| 2839 jsObjectValue->GetObjectProperty(propStr.AsStringC(), | |
| 2840 newPropertyValue.get()); | |
| 2841 } | 2829 } |
| 2842 CFX_ByteString bsChoosed; | 2830 CFX_ByteString bsChoosed; |
| 2843 ValueToUTF8String(newPropertyValue.get(), bsChoosed); | 2831 ValueToUTF8String(newPropertyValue.get(), bsChoosed); |
| 2844 args.GetReturnValue()->SetString(bsChoosed.AsStringC()); | 2832 args.GetReturnValue()->SetString(bsChoosed.AsStringC()); |
| 2845 bFound = TRUE; | 2833 bFound = TRUE; |
| 2846 } | 2834 } |
| 2847 } else { | 2835 } else { |
| 2848 iValueIndex++; | 2836 iValueIndex++; |
| 2849 if (iValueIndex == iIndex) { | 2837 if (iValueIndex == iIndex) { |
| 2850 CFX_ByteString bsChoosed; | 2838 CFX_ByteString bsChoosed; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2881 return; | 2869 return; |
| 2882 } | 2870 } |
| 2883 | 2871 |
| 2884 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 2872 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 2885 if (!argOne->IsString()) { | 2873 if (!argOne->IsString()) { |
| 2886 args.GetReturnValue()->SetInteger(argOne->IsNumber() || | 2874 args.GetReturnValue()->SetInteger(argOne->IsNumber() || |
| 2887 argOne->IsBoolean()); | 2875 argOne->IsBoolean()); |
| 2888 return; | 2876 return; |
| 2889 } | 2877 } |
| 2890 | 2878 |
| 2891 CFX_ByteString valueStr; | 2879 CFX_ByteString valueStr = argOne->ToString(); |
| 2892 argOne->ToString(valueStr); | |
| 2893 valueStr.TrimLeft(); | 2880 valueStr.TrimLeft(); |
| 2894 args.GetReturnValue()->SetInteger(!valueStr.IsEmpty()); | 2881 args.GetReturnValue()->SetInteger(!valueStr.IsEmpty()); |
| 2895 } | 2882 } |
| 2896 | 2883 |
| 2897 // static | 2884 // static |
| 2898 void CXFA_FM2JSContext::Oneof(CFXJSE_Value* pThis, | 2885 void CXFA_FM2JSContext::Oneof(CFXJSE_Value* pThis, |
| 2899 const CFX_ByteStringC& szFuncName, | 2886 const CFX_ByteStringC& szFuncName, |
| 2900 CFXJSE_Arguments& args) { | 2887 CFXJSE_Arguments& args) { |
| 2901 if (args.GetLength() < 2) { | 2888 if (args.GetLength() < 2) { |
| 2902 ToJSContext(pThis, nullptr) | 2889 ToJSContext(pThis, nullptr) |
| (...skipping 2174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5077 lValue->GetObjectPropertyByIdx(1, propertyValue.get()); | 5064 lValue->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 5078 if (propertyValue->IsNull()) { | 5065 if (propertyValue->IsNull()) { |
| 5079 for (int32_t i = 2; i < iLeftLength; i++) { | 5066 for (int32_t i = 2; i < iLeftLength; i++) { |
| 5080 lValue->GetObjectPropertyByIdx(i, jsObjectValue.get()); | 5067 lValue->GetObjectPropertyByIdx(i, jsObjectValue.get()); |
| 5081 if (!SetObjectDefaultValue(jsObjectValue.get(), rValue.get())) { | 5068 if (!SetObjectDefaultValue(jsObjectValue.get(), rValue.get())) { |
| 5082 pContext->ThrowException(XFA_IDS_NOT_DEFAUL_VALUE); | 5069 pContext->ThrowException(XFA_IDS_NOT_DEFAUL_VALUE); |
| 5083 return; | 5070 return; |
| 5084 } | 5071 } |
| 5085 } | 5072 } |
| 5086 } else { | 5073 } else { |
| 5087 CFX_ByteString propertyStr; | |
| 5088 propertyValue->ToString(propertyStr); | |
| 5089 for (int32_t i = 2; i < iLeftLength; i++) { | 5074 for (int32_t i = 2; i < iLeftLength; i++) { |
| 5090 lValue->GetObjectPropertyByIdx(i, jsObjectValue.get()); | 5075 lValue->GetObjectPropertyByIdx(i, jsObjectValue.get()); |
| 5091 jsObjectValue->SetObjectProperty(propertyStr.AsStringC(), rValue.get()); | 5076 jsObjectValue->SetObjectProperty(propertyValue->ToString().AsStringC(), |
| 5077 rValue.get()); |
| 5092 } | 5078 } |
| 5093 } | 5079 } |
| 5094 } else if (lValue->IsObject()) { | 5080 } else if (lValue->IsObject()) { |
| 5095 if (!SetObjectDefaultValue(lValue.get(), rValue.get())) { | 5081 if (!SetObjectDefaultValue(lValue.get(), rValue.get())) { |
| 5096 pContext->ThrowException(XFA_IDS_NOT_DEFAUL_VALUE); | 5082 pContext->ThrowException(XFA_IDS_NOT_DEFAUL_VALUE); |
| 5097 return; | 5083 return; |
| 5098 } | 5084 } |
| 5099 } | 5085 } |
| 5100 args.GetReturnValue()->Assign(rValue.get()); | 5086 args.GetReturnValue()->Assign(rValue.get()); |
| 5101 } | 5087 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5158 | 5144 |
| 5159 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5145 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5160 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5146 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5161 if (argFirst->IsNull() || argSecond->IsNull()) { | 5147 if (argFirst->IsNull() || argSecond->IsNull()) { |
| 5162 args.GetReturnValue()->SetInteger( | 5148 args.GetReturnValue()->SetInteger( |
| 5163 (argFirst->IsNull() && argSecond->IsNull()) ? 1 : 0); | 5149 (argFirst->IsNull() && argSecond->IsNull()) ? 1 : 0); |
| 5164 return; | 5150 return; |
| 5165 } | 5151 } |
| 5166 | 5152 |
| 5167 if (argFirst->IsString() && argSecond->IsString()) { | 5153 if (argFirst->IsString() && argSecond->IsString()) { |
| 5168 CFX_ByteString firstOutput; | 5154 args.GetReturnValue()->SetInteger(argFirst->ToString() == |
| 5169 CFX_ByteString secondOutput; | 5155 argSecond->ToString()); |
| 5170 argFirst->ToString(firstOutput); | |
| 5171 argSecond->ToString(secondOutput); | |
| 5172 args.GetReturnValue()->SetInteger(firstOutput == secondOutput); | |
| 5173 return; | 5156 return; |
| 5174 } | 5157 } |
| 5175 | 5158 |
| 5176 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5159 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5177 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5160 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5178 args.GetReturnValue()->SetInteger((first == second) ? 1 : 0); | 5161 args.GetReturnValue()->SetInteger((first == second) ? 1 : 0); |
| 5179 } | 5162 } |
| 5180 | 5163 |
| 5181 // static | 5164 // static |
| 5182 void CXFA_FM2JSContext::notequality_operator(CFXJSE_Value* pThis, | 5165 void CXFA_FM2JSContext::notequality_operator(CFXJSE_Value* pThis, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 5194 | 5177 |
| 5195 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5178 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5196 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5179 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5197 if (argFirst->IsNull() || argSecond->IsNull()) { | 5180 if (argFirst->IsNull() || argSecond->IsNull()) { |
| 5198 args.GetReturnValue()->SetInteger( | 5181 args.GetReturnValue()->SetInteger( |
| 5199 (argFirst->IsNull() && argSecond->IsNull()) ? 0 : 1); | 5182 (argFirst->IsNull() && argSecond->IsNull()) ? 0 : 1); |
| 5200 return; | 5183 return; |
| 5201 } | 5184 } |
| 5202 | 5185 |
| 5203 if (argFirst->IsString() && argSecond->IsString()) { | 5186 if (argFirst->IsString() && argSecond->IsString()) { |
| 5204 CFX_ByteString firstOutput; | 5187 args.GetReturnValue()->SetInteger(argFirst->ToString() != |
| 5205 CFX_ByteString secondOutput; | 5188 argSecond->ToString()); |
| 5206 argFirst->ToString(firstOutput); | |
| 5207 argSecond->ToString(secondOutput); | |
| 5208 args.GetReturnValue()->SetInteger(firstOutput != secondOutput); | |
| 5209 return; | 5189 return; |
| 5210 } | 5190 } |
| 5211 | 5191 |
| 5212 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5192 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5213 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5193 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5214 args.GetReturnValue()->SetInteger(first != second); | 5194 args.GetReturnValue()->SetInteger(first != second); |
| 5215 } | 5195 } |
| 5216 | 5196 |
| 5217 // static | 5197 // static |
| 5218 FX_BOOL CXFA_FM2JSContext::fm_ref_equal(CFXJSE_Value* pThis, | 5198 FX_BOOL CXFA_FM2JSContext::fm_ref_equal(CFXJSE_Value* pThis, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5251 } | 5231 } |
| 5252 | 5232 |
| 5253 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5233 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5254 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5234 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5255 if (argFirst->IsNull() || argSecond->IsNull()) { | 5235 if (argFirst->IsNull() || argSecond->IsNull()) { |
| 5256 args.GetReturnValue()->SetInteger(0); | 5236 args.GetReturnValue()->SetInteger(0); |
| 5257 return; | 5237 return; |
| 5258 } | 5238 } |
| 5259 | 5239 |
| 5260 if (argFirst->IsString() && argSecond->IsString()) { | 5240 if (argFirst->IsString() && argSecond->IsString()) { |
| 5261 CFX_ByteString firstOutput; | |
| 5262 CFX_ByteString secondOutput; | |
| 5263 argFirst->ToString(firstOutput); | |
| 5264 argSecond->ToString(secondOutput); | |
| 5265 args.GetReturnValue()->SetInteger( | 5241 args.GetReturnValue()->SetInteger( |
| 5266 firstOutput.Compare(secondOutput.AsStringC()) == -1); | 5242 argFirst->ToString().Compare(argSecond->ToString().AsStringC()) == -1); |
| 5267 return; | 5243 return; |
| 5268 } | 5244 } |
| 5269 | 5245 |
| 5270 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5246 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5271 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5247 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5272 args.GetReturnValue()->SetInteger((first < second) ? 1 : 0); | 5248 args.GetReturnValue()->SetInteger((first < second) ? 1 : 0); |
| 5273 } | 5249 } |
| 5274 | 5250 |
| 5275 // static | 5251 // static |
| 5276 void CXFA_FM2JSContext::lessequal_operator(CFXJSE_Value* pThis, | 5252 void CXFA_FM2JSContext::lessequal_operator(CFXJSE_Value* pThis, |
| 5277 const CFX_ByteStringC& szFuncName, | 5253 const CFX_ByteStringC& szFuncName, |
| 5278 CFXJSE_Arguments& args) { | 5254 CFXJSE_Arguments& args) { |
| 5279 if (args.GetLength() != 2) { | 5255 if (args.GetLength() != 2) { |
| 5280 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5256 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5281 return; | 5257 return; |
| 5282 } | 5258 } |
| 5283 | 5259 |
| 5284 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5260 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5285 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5261 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5286 if (argFirst->IsNull() || argSecond->IsNull()) { | 5262 if (argFirst->IsNull() || argSecond->IsNull()) { |
| 5287 args.GetReturnValue()->SetInteger( | 5263 args.GetReturnValue()->SetInteger( |
| 5288 (argFirst->IsNull() && argSecond->IsNull()) ? 1 : 0); | 5264 (argFirst->IsNull() && argSecond->IsNull()) ? 1 : 0); |
| 5289 return; | 5265 return; |
| 5290 } | 5266 } |
| 5291 | 5267 |
| 5292 if (argFirst->IsString() && argSecond->IsString()) { | 5268 if (argFirst->IsString() && argSecond->IsString()) { |
| 5293 CFX_ByteString firstOutput; | |
| 5294 CFX_ByteString secondOutput; | |
| 5295 argFirst->ToString(firstOutput); | |
| 5296 argSecond->ToString(secondOutput); | |
| 5297 args.GetReturnValue()->SetInteger( | 5269 args.GetReturnValue()->SetInteger( |
| 5298 firstOutput.Compare(secondOutput.AsStringC()) != 1); | 5270 argFirst->ToString().Compare(argSecond->ToString().AsStringC()) != 1); |
| 5299 return; | 5271 return; |
| 5300 } | 5272 } |
| 5301 | 5273 |
| 5302 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5274 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5303 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5275 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5304 args.GetReturnValue()->SetInteger((first <= second) ? 1 : 0); | 5276 args.GetReturnValue()->SetInteger((first <= second) ? 1 : 0); |
| 5305 } | 5277 } |
| 5306 | 5278 |
| 5307 // static | 5279 // static |
| 5308 void CXFA_FM2JSContext::greater_operator(CFXJSE_Value* pThis, | 5280 void CXFA_FM2JSContext::greater_operator(CFXJSE_Value* pThis, |
| 5309 const CFX_ByteStringC& szFuncName, | 5281 const CFX_ByteStringC& szFuncName, |
| 5310 CFXJSE_Arguments& args) { | 5282 CFXJSE_Arguments& args) { |
| 5311 if (args.GetLength() != 2) { | 5283 if (args.GetLength() != 2) { |
| 5312 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5284 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5313 return; | 5285 return; |
| 5314 } | 5286 } |
| 5315 | 5287 |
| 5316 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5288 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5317 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5289 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5318 if (argFirst->IsNull() || argSecond->IsNull()) { | 5290 if (argFirst->IsNull() || argSecond->IsNull()) { |
| 5319 args.GetReturnValue()->SetInteger(0); | 5291 args.GetReturnValue()->SetInteger(0); |
| 5320 return; | 5292 return; |
| 5321 } | 5293 } |
| 5322 | 5294 |
| 5323 if (argFirst->IsString() && argSecond->IsString()) { | 5295 if (argFirst->IsString() && argSecond->IsString()) { |
| 5324 CFX_ByteString firstOutput; | |
| 5325 CFX_ByteString secondOutput; | |
| 5326 argFirst->ToString(firstOutput); | |
| 5327 argSecond->ToString(secondOutput); | |
| 5328 args.GetReturnValue()->SetInteger( | 5296 args.GetReturnValue()->SetInteger( |
| 5329 firstOutput.Compare(secondOutput.AsStringC()) == 1); | 5297 argFirst->ToString().Compare(argSecond->ToString().AsStringC()) == 1); |
| 5330 return; | 5298 return; |
| 5331 } | 5299 } |
| 5332 | 5300 |
| 5333 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5301 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5334 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5302 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5335 args.GetReturnValue()->SetInteger((first > second) ? 1 : 0); | 5303 args.GetReturnValue()->SetInteger((first > second) ? 1 : 0); |
| 5336 } | 5304 } |
| 5337 | 5305 |
| 5338 // static | 5306 // static |
| 5339 void CXFA_FM2JSContext::greaterequal_operator(CFXJSE_Value* pThis, | 5307 void CXFA_FM2JSContext::greaterequal_operator(CFXJSE_Value* pThis, |
| 5340 const CFX_ByteStringC& szFuncName, | 5308 const CFX_ByteStringC& szFuncName, |
| 5341 CFXJSE_Arguments& args) { | 5309 CFXJSE_Arguments& args) { |
| 5342 if (args.GetLength() != 2) { | 5310 if (args.GetLength() != 2) { |
| 5343 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5311 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5344 return; | 5312 return; |
| 5345 } | 5313 } |
| 5346 | 5314 |
| 5347 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5315 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5348 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5316 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5349 if (argFirst->IsNull() || argSecond->IsNull()) { | 5317 if (argFirst->IsNull() || argSecond->IsNull()) { |
| 5350 args.GetReturnValue()->SetInteger( | 5318 args.GetReturnValue()->SetInteger( |
| 5351 (argFirst->IsNull() && argSecond->IsNull()) ? 1 : 0); | 5319 (argFirst->IsNull() && argSecond->IsNull()) ? 1 : 0); |
| 5352 return; | 5320 return; |
| 5353 } | 5321 } |
| 5354 | 5322 |
| 5355 if (argFirst->IsString() && argSecond->IsString()) { | 5323 if (argFirst->IsString() && argSecond->IsString()) { |
| 5356 CFX_ByteString firstOutput; | |
| 5357 CFX_ByteString secondOutput; | |
| 5358 argFirst->ToString(firstOutput); | |
| 5359 argSecond->ToString(secondOutput); | |
| 5360 args.GetReturnValue()->SetInteger( | 5324 args.GetReturnValue()->SetInteger( |
| 5361 firstOutput.Compare(secondOutput.AsStringC()) != -1); | 5325 argFirst->ToString().Compare(argSecond->ToString().AsStringC()) != -1); |
| 5362 return; | 5326 return; |
| 5363 } | 5327 } |
| 5364 | 5328 |
| 5365 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5329 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5366 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5330 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5367 args.GetReturnValue()->SetInteger((first >= second) ? 1 : 0); | 5331 args.GetReturnValue()->SetInteger((first >= second) ? 1 : 0); |
| 5368 } | 5332 } |
| 5369 | 5333 |
| 5370 // static | 5334 // static |
| 5371 void CXFA_FM2JSContext::plus_operator(CFXJSE_Value* pThis, | 5335 void CXFA_FM2JSContext::plus_operator(CFXJSE_Value* pThis, |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5871 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 5835 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 5872 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 5836 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 5873 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 5837 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 5874 argOne->GetObjectPropertyByIdx(1, propertyValue.get()); | 5838 argOne->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 5875 argOne->GetObjectPropertyByIdx(2, jsObjectValue.get()); | 5839 argOne->GetObjectPropertyByIdx(2, jsObjectValue.get()); |
| 5876 if (propertyValue->IsNull()) { | 5840 if (propertyValue->IsNull()) { |
| 5877 GetObjectDefaultValue(jsObjectValue.get(), args.GetReturnValue()); | 5841 GetObjectDefaultValue(jsObjectValue.get(), args.GetReturnValue()); |
| 5878 return; | 5842 return; |
| 5879 } | 5843 } |
| 5880 | 5844 |
| 5881 CFX_ByteString propertyStr; | 5845 jsObjectValue->GetObjectProperty(propertyValue->ToString().AsStringC(), |
| 5882 propertyValue->ToString(propertyStr); | |
| 5883 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), | |
| 5884 args.GetReturnValue()); | 5846 args.GetReturnValue()); |
| 5885 return; | 5847 return; |
| 5886 } | 5848 } |
| 5887 | 5849 |
| 5888 if (argOne->IsObject()) { | 5850 if (argOne->IsObject()) { |
| 5889 GetObjectDefaultValue(argOne.get(), args.GetReturnValue()); | 5851 GetObjectDefaultValue(argOne.get(), args.GetReturnValue()); |
| 5890 return; | 5852 return; |
| 5891 } | 5853 } |
| 5892 | 5854 |
| 5893 args.GetReturnValue()->Assign(argOne.get()); | 5855 args.GetReturnValue()->Assign(argOne.get()); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6044 | 6006 |
| 6045 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 6007 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 6046 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 6008 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 6047 argIndex->GetObjectPropertyByIdx(1, propertyValue.get()); | 6009 argIndex->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 6048 argIndex->GetObjectPropertyByIdx(2, jsObjectValue.get()); | 6010 argIndex->GetObjectPropertyByIdx(2, jsObjectValue.get()); |
| 6049 if (propertyValue->IsNull()) { | 6011 if (propertyValue->IsNull()) { |
| 6050 GetObjectDefaultValue(jsObjectValue.get(), simpleValue.get()); | 6012 GetObjectDefaultValue(jsObjectValue.get(), simpleValue.get()); |
| 6051 return simpleValue; | 6013 return simpleValue; |
| 6052 } | 6014 } |
| 6053 | 6015 |
| 6054 CFX_ByteString propertyStr; | 6016 jsObjectValue->GetObjectProperty(propertyValue->ToString().AsStringC(), |
| 6055 propertyValue->ToString(propertyStr); | |
| 6056 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), | |
| 6057 simpleValue.get()); | 6017 simpleValue.get()); |
| 6058 return simpleValue; | 6018 return simpleValue; |
| 6059 } | 6019 } |
| 6060 | 6020 |
| 6061 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); | 6021 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); |
| 6062 GetObjectDefaultValue(argIndex.get(), defaultValue.get()); | 6022 GetObjectDefaultValue(argIndex.get(), defaultValue.get()); |
| 6063 return defaultValue; | 6023 return defaultValue; |
| 6064 } | 6024 } |
| 6065 | 6025 |
| 6066 // static | 6026 // static |
| (...skipping 13 matching lines...) Expand all Loading... |
| 6080 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 6040 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 6081 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 6041 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 6082 arg->GetObjectPropertyByIdx(1, propertyValue.get()); | 6042 arg->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 6083 arg->GetObjectPropertyByIdx(2, jsObjectValue.get()); | 6043 arg->GetObjectPropertyByIdx(2, jsObjectValue.get()); |
| 6084 if (propertyValue->IsNull()) { | 6044 if (propertyValue->IsNull()) { |
| 6085 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); | 6045 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); |
| 6086 GetObjectDefaultValue(jsObjectValue.get(), defaultValue.get()); | 6046 GetObjectDefaultValue(jsObjectValue.get(), defaultValue.get()); |
| 6087 return defaultValue->IsNull(); | 6047 return defaultValue->IsNull(); |
| 6088 } | 6048 } |
| 6089 | 6049 |
| 6090 CFX_ByteString propertyStr; | |
| 6091 propertyValue->ToString(propertyStr); | |
| 6092 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 6050 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
| 6093 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), | 6051 jsObjectValue->GetObjectProperty(propertyValue->ToString().AsStringC(), |
| 6094 newPropertyValue.get()); | 6052 newPropertyValue.get()); |
| 6095 return newPropertyValue->IsNull(); | 6053 return newPropertyValue->IsNull(); |
| 6096 } | 6054 } |
| 6097 | 6055 |
| 6098 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); | 6056 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); |
| 6099 GetObjectDefaultValue(arg, defaultValue.get()); | 6057 GetObjectDefaultValue(arg, defaultValue.get()); |
| 6100 return defaultValue->IsNull(); | 6058 return defaultValue->IsNull(); |
| 6101 } | 6059 } |
| 6102 | 6060 |
| 6103 // static | 6061 // static |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6174 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 6132 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 6175 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 6133 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 6176 argsValue[i]->GetObjectPropertyByIdx(1, propertyValue.get()); | 6134 argsValue[i]->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 6177 if (propertyValue->IsNull()) { | 6135 if (propertyValue->IsNull()) { |
| 6178 for (int32_t j = 2; j < iLength; j++) { | 6136 for (int32_t j = 2; j < iLength; j++) { |
| 6179 argsValue[i]->GetObjectPropertyByIdx(j, jsObjectValue.get()); | 6137 argsValue[i]->GetObjectPropertyByIdx(j, jsObjectValue.get()); |
| 6180 GetObjectDefaultValue(jsObjectValue.get(), resultValues[index]); | 6138 GetObjectDefaultValue(jsObjectValue.get(), resultValues[index]); |
| 6181 index++; | 6139 index++; |
| 6182 } | 6140 } |
| 6183 } else { | 6141 } else { |
| 6184 CFX_ByteString propertyString; | |
| 6185 propertyValue->ToString(propertyString); | |
| 6186 for (int32_t j = 2; j < iLength; j++) { | 6142 for (int32_t j = 2; j < iLength; j++) { |
| 6187 argsValue[i]->GetObjectPropertyByIdx(j, jsObjectValue.get()); | 6143 argsValue[i]->GetObjectPropertyByIdx(j, jsObjectValue.get()); |
| 6188 jsObjectValue->GetObjectProperty(propertyString.AsStringC(), | 6144 jsObjectValue->GetObjectProperty( |
| 6189 resultValues[index]); | 6145 propertyValue->ToString().AsStringC(), resultValues[index]); |
| 6190 index++; | 6146 index++; |
| 6191 } | 6147 } |
| 6192 } | 6148 } |
| 6193 } else if (argsValue[i]->IsObject()) { | 6149 } else if (argsValue[i]->IsObject()) { |
| 6194 GetObjectDefaultValue(argsValue[i].get(), resultValues[index]); | 6150 GetObjectDefaultValue(argsValue[i].get(), resultValues[index]); |
| 6195 index++; | 6151 index++; |
| 6196 } else { | 6152 } else { |
| 6197 resultValues[index]->Assign(argsValue[i].get()); | 6153 resultValues[index]->Assign(argsValue[i].get()); |
| 6198 index++; | 6154 index++; |
| 6199 } | 6155 } |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6386 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 6342 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 6387 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 6343 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 6388 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 6344 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
| 6389 pValue->GetObjectPropertyByIdx(1, propertyValue.get()); | 6345 pValue->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 6390 pValue->GetObjectPropertyByIdx(2, jsObjectValue.get()); | 6346 pValue->GetObjectPropertyByIdx(2, jsObjectValue.get()); |
| 6391 if (propertyValue->IsNull()) { | 6347 if (propertyValue->IsNull()) { |
| 6392 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 6348 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
| 6393 return ValueToInteger(pThis, newPropertyValue.get()); | 6349 return ValueToInteger(pThis, newPropertyValue.get()); |
| 6394 } | 6350 } |
| 6395 | 6351 |
| 6396 CFX_ByteString propertyStr; | 6352 jsObjectValue->GetObjectProperty(propertyValue->ToString().AsStringC(), |
| 6397 propertyValue->ToString(propertyStr); | |
| 6398 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), | |
| 6399 newPropertyValue.get()); | 6353 newPropertyValue.get()); |
| 6400 return ValueToInteger(pThis, newPropertyValue.get()); | 6354 return ValueToInteger(pThis, newPropertyValue.get()); |
| 6401 } | 6355 } |
| 6402 if (pValue->IsObject()) { | 6356 if (pValue->IsObject()) { |
| 6403 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 6357 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
| 6404 GetObjectDefaultValue(pValue, newPropertyValue.get()); | 6358 GetObjectDefaultValue(pValue, newPropertyValue.get()); |
| 6405 return ValueToInteger(pThis, newPropertyValue.get()); | 6359 return ValueToInteger(pThis, newPropertyValue.get()); |
| 6406 } | 6360 } |
| 6407 if (pValue->IsString()) { | 6361 if (pValue->IsString()) |
| 6408 CFX_ByteString szValue; | 6362 return FXSYS_atoi(pValue->ToString().c_str()); |
| 6409 pValue->ToString(szValue); | |
| 6410 return FXSYS_atoi(szValue.c_str()); | |
| 6411 } | |
| 6412 return pValue->ToInteger(); | 6363 return pValue->ToInteger(); |
| 6413 } | 6364 } |
| 6414 | 6365 |
| 6415 // static | 6366 // static |
| 6416 FX_FLOAT CXFA_FM2JSContext::ValueToFloat(CFXJSE_Value* pThis, | 6367 FX_FLOAT CXFA_FM2JSContext::ValueToFloat(CFXJSE_Value* pThis, |
| 6417 CFXJSE_Value* arg) { | 6368 CFXJSE_Value* arg) { |
| 6418 if (!arg) | 6369 if (!arg) |
| 6419 return 0.0f; | 6370 return 0.0f; |
| 6420 | 6371 |
| 6421 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); | 6372 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); |
| 6422 if (arg->IsArray()) { | 6373 if (arg->IsArray()) { |
| 6423 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 6374 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 6424 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 6375 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 6425 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 6376 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
| 6426 arg->GetObjectPropertyByIdx(1, propertyValue.get()); | 6377 arg->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 6427 arg->GetObjectPropertyByIdx(2, jsObjectValue.get()); | 6378 arg->GetObjectPropertyByIdx(2, jsObjectValue.get()); |
| 6428 if (propertyValue->IsNull()) { | 6379 if (propertyValue->IsNull()) { |
| 6429 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 6380 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
| 6430 return ValueToFloat(pThis, newPropertyValue.get()); | 6381 return ValueToFloat(pThis, newPropertyValue.get()); |
| 6431 } | 6382 } |
| 6432 CFX_ByteString propertyStr; | 6383 jsObjectValue->GetObjectProperty(propertyValue->ToString().AsStringC(), |
| 6433 propertyValue->ToString(propertyStr); | |
| 6434 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), | |
| 6435 newPropertyValue.get()); | 6384 newPropertyValue.get()); |
| 6436 return ValueToFloat(pThis, newPropertyValue.get()); | 6385 return ValueToFloat(pThis, newPropertyValue.get()); |
| 6437 } | 6386 } |
| 6438 if (arg->IsObject()) { | 6387 if (arg->IsObject()) { |
| 6439 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 6388 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
| 6440 GetObjectDefaultValue(arg, newPropertyValue.get()); | 6389 GetObjectDefaultValue(arg, newPropertyValue.get()); |
| 6441 return ValueToFloat(pThis, newPropertyValue.get()); | 6390 return ValueToFloat(pThis, newPropertyValue.get()); |
| 6442 } | 6391 } |
| 6443 if (arg->IsString()) { | 6392 if (arg->IsString()) |
| 6444 CFX_ByteString bsOutput; | 6393 return (FX_FLOAT)XFA_ByteStringToDouble(arg->ToString().AsStringC()); |
| 6445 arg->ToString(bsOutput); | |
| 6446 return (FX_FLOAT)XFA_ByteStringToDouble(bsOutput.AsStringC()); | |
| 6447 } | |
| 6448 if (arg->IsUndefined()) | 6394 if (arg->IsUndefined()) |
| 6449 return 0; | 6395 return 0; |
| 6450 | 6396 |
| 6451 return arg->ToFloat(); | 6397 return arg->ToFloat(); |
| 6452 } | 6398 } |
| 6453 | 6399 |
| 6454 // static | 6400 // static |
| 6455 FX_DOUBLE CXFA_FM2JSContext::ValueToDouble(CFXJSE_Value* pThis, | 6401 FX_DOUBLE CXFA_FM2JSContext::ValueToDouble(CFXJSE_Value* pThis, |
| 6456 CFXJSE_Value* arg) { | 6402 CFXJSE_Value* arg) { |
| 6457 if (!arg) | 6403 if (!arg) |
| 6458 return 0; | 6404 return 0; |
| 6459 | 6405 |
| 6460 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); | 6406 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); |
| 6461 if (arg->IsArray()) { | 6407 if (arg->IsArray()) { |
| 6462 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 6408 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 6463 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 6409 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 6464 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 6410 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
| 6465 arg->GetObjectPropertyByIdx(1, propertyValue.get()); | 6411 arg->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 6466 arg->GetObjectPropertyByIdx(2, jsObjectValue.get()); | 6412 arg->GetObjectPropertyByIdx(2, jsObjectValue.get()); |
| 6467 if (propertyValue->IsNull()) { | 6413 if (propertyValue->IsNull()) { |
| 6468 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 6414 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
| 6469 return ValueToDouble(pThis, newPropertyValue.get()); | 6415 return ValueToDouble(pThis, newPropertyValue.get()); |
| 6470 } | 6416 } |
| 6471 CFX_ByteString propertyStr; | 6417 jsObjectValue->GetObjectProperty(propertyValue->ToString().AsStringC(), |
| 6472 propertyValue->ToString(propertyStr); | |
| 6473 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), | |
| 6474 newPropertyValue.get()); | 6418 newPropertyValue.get()); |
| 6475 return ValueToDouble(pThis, newPropertyValue.get()); | 6419 return ValueToDouble(pThis, newPropertyValue.get()); |
| 6476 } | 6420 } |
| 6477 if (arg->IsObject()) { | 6421 if (arg->IsObject()) { |
| 6478 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 6422 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
| 6479 GetObjectDefaultValue(arg, newPropertyValue.get()); | 6423 GetObjectDefaultValue(arg, newPropertyValue.get()); |
| 6480 return ValueToDouble(pThis, newPropertyValue.get()); | 6424 return ValueToDouble(pThis, newPropertyValue.get()); |
| 6481 } | 6425 } |
| 6482 if (arg->IsString()) { | 6426 if (arg->IsString()) |
| 6483 CFX_ByteString bsOutput; | 6427 return XFA_ByteStringToDouble(arg->ToString().AsStringC()); |
| 6484 arg->ToString(bsOutput); | |
| 6485 return XFA_ByteStringToDouble(bsOutput.AsStringC()); | |
| 6486 } | |
| 6487 if (arg->IsUndefined()) | 6428 if (arg->IsUndefined()) |
| 6488 return 0; | 6429 return 0; |
| 6489 return arg->ToDouble(); | 6430 return arg->ToDouble(); |
| 6490 } | 6431 } |
| 6491 | 6432 |
| 6492 // static. | 6433 // static. |
| 6493 double CXFA_FM2JSContext::ExtractDouble(CFXJSE_Value* pThis, | 6434 double CXFA_FM2JSContext::ExtractDouble(CFXJSE_Value* pThis, |
| 6494 CFXJSE_Value* src, | 6435 CFXJSE_Value* src, |
| 6495 bool* ret) { | 6436 bool* ret) { |
| 6496 ASSERT(ret); | 6437 ASSERT(ret); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 6511 return 0.0; | 6452 return 0.0; |
| 6512 } | 6453 } |
| 6513 | 6454 |
| 6514 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 6455 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 6515 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 6456 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 6516 src->GetObjectPropertyByIdx(1, propertyValue.get()); | 6457 src->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 6517 src->GetObjectPropertyByIdx(2, jsObjectValue.get()); | 6458 src->GetObjectPropertyByIdx(2, jsObjectValue.get()); |
| 6518 if (propertyValue->IsNull()) | 6459 if (propertyValue->IsNull()) |
| 6519 return ValueToDouble(pThis, jsObjectValue.get()); | 6460 return ValueToDouble(pThis, jsObjectValue.get()); |
| 6520 | 6461 |
| 6521 CFX_ByteString propertyStr; | |
| 6522 propertyValue->ToString(propertyStr); | |
| 6523 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 6462 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
| 6524 jsObjectValue->GetObjectProperty(propertyStr.AsStringC(), | 6463 jsObjectValue->GetObjectProperty(propertyValue->ToString().AsStringC(), |
| 6525 newPropertyValue.get()); | 6464 newPropertyValue.get()); |
| 6526 return ValueToDouble(pThis, newPropertyValue.get()); | 6465 return ValueToDouble(pThis, newPropertyValue.get()); |
| 6527 } | 6466 } |
| 6528 | 6467 |
| 6529 // static | 6468 // static |
| 6530 void CXFA_FM2JSContext::ValueToUTF8String(CFXJSE_Value* arg, | 6469 void CXFA_FM2JSContext::ValueToUTF8String(CFXJSE_Value* arg, |
| 6531 CFX_ByteString& szOutputString) { | 6470 CFX_ByteString& szOutputString) { |
| 6532 if (!arg) | 6471 if (!arg) |
| 6533 return; | 6472 return; |
| 6534 | 6473 |
| 6535 if (arg->IsNull() || arg->IsUndefined()) { | 6474 if (arg->IsNull() || arg->IsUndefined()) |
| 6536 szOutputString = ""; | 6475 szOutputString = ""; |
| 6537 } else if (arg->IsBoolean()) { | 6476 else if (arg->IsBoolean()) |
| 6538 szOutputString = arg->ToBoolean() ? "1" : "0"; | 6477 szOutputString = arg->ToBoolean() ? "1" : "0"; |
| 6539 } else { | 6478 else |
| 6540 szOutputString = ""; | 6479 szOutputString = arg->ToString(); |
| 6541 arg->ToString(szOutputString); | |
| 6542 } | |
| 6543 } | 6480 } |
| 6544 | 6481 |
| 6545 // static. | 6482 // static. |
| 6546 int32_t CXFA_FM2JSContext::Translate(const CFX_WideStringC& wsFormcalc, | 6483 int32_t CXFA_FM2JSContext::Translate(const CFX_WideStringC& wsFormcalc, |
| 6547 CFX_WideTextBuf& wsJavascript, | 6484 CFX_WideTextBuf& wsJavascript, |
| 6548 CFX_WideString& wsError) { | 6485 CFX_WideString& wsError) { |
| 6549 if (wsFormcalc.IsEmpty()) { | 6486 if (wsFormcalc.IsEmpty()) { |
| 6550 wsJavascript.Clear(); | 6487 wsJavascript.Clear(); |
| 6551 wsError.clear(); | 6488 wsError.clear(); |
| 6552 return 0; | 6489 return 0; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6591 CFX_WideString wsFormat; | 6528 CFX_WideString wsFormat; |
| 6592 pAppProvider->LoadString(iStringID, wsFormat); | 6529 pAppProvider->LoadString(iStringID, wsFormat); |
| 6593 CFX_WideString wsMessage; | 6530 CFX_WideString wsMessage; |
| 6594 va_list arg_ptr; | 6531 va_list arg_ptr; |
| 6595 va_start(arg_ptr, iStringID); | 6532 va_start(arg_ptr, iStringID); |
| 6596 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); | 6533 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); |
| 6597 va_end(arg_ptr); | 6534 va_end(arg_ptr); |
| 6598 FXJSE_ThrowMessage( | 6535 FXJSE_ThrowMessage( |
| 6599 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); | 6536 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); |
| 6600 } | 6537 } |
| OLD | NEW |