| 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 4762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4773 "five", "six", "seven", "eight", "nine"}; | 4773 "five", "six", "seven", "eight", "nine"}; |
| 4774 CFX_ByteStringC pCapUnits[] = {"Zero", "One", "Two", "Three", "Four", | 4774 CFX_ByteStringC pCapUnits[] = {"Zero", "One", "Two", "Three", "Four", |
| 4775 "Five", "Six", "Seven", "Eight", "Nine"}; | 4775 "Five", "Six", "Seven", "Eight", "Nine"}; |
| 4776 CFX_ByteStringC pTens[] = {"Ten", "Eleven", "Twelve", "Thirteen", | 4776 CFX_ByteStringC pTens[] = {"Ten", "Eleven", "Twelve", "Thirteen", |
| 4777 "Fourteen", "Fifteen", "Sixteen", "Seventeen", | 4777 "Fourteen", "Fifteen", "Sixteen", "Seventeen", |
| 4778 "Eighteen", "Nineteen"}; | 4778 "Eighteen", "Nineteen"}; |
| 4779 CFX_ByteStringC pLastTens[] = {"Twenty", "Thirty", "Forty", "Fifty", | 4779 CFX_ByteStringC pLastTens[] = {"Twenty", "Thirty", "Forty", "Fifty", |
| 4780 "Sixty", "Seventy", "Eighty", "Ninety"}; | 4780 "Sixty", "Seventy", "Eighty", "Ninety"}; |
| 4781 CFX_ByteStringC pComm[] = {" Hundred ", " Thousand ", " Million ", | 4781 CFX_ByteStringC pComm[] = {" Hundred ", " Thousand ", " Million ", |
| 4782 " Billion ", "Trillion"}; | 4782 " Billion ", "Trillion"}; |
| 4783 int32_t iComm = 0; | |
| 4784 const FX_CHAR* pData = szData.c_str(); | 4783 const FX_CHAR* pData = szData.c_str(); |
| 4785 int32_t iLength = szData.GetLength(); | 4784 int32_t iLength = szData.GetLength(); |
| 4786 if (iLength > 12) { | 4785 int32_t iComm = 0; |
| 4786 if (iLength > 12) |
| 4787 iComm = 4; | 4787 iComm = 4; |
| 4788 } else if (iLength > 9) { | 4788 else if (iLength > 9) |
| 4789 iComm = 3; | 4789 iComm = 3; |
| 4790 } else if (iLength > 6) { | 4790 else if (iLength > 6) |
| 4791 iComm = 2; | 4791 iComm = 2; |
| 4792 } else if (iLength > 3) { | 4792 else if (iLength > 3) |
| 4793 iComm = 1; | 4793 iComm = 1; |
| 4794 } | 4794 |
| 4795 int32_t iFirstCount = iLength % 3; |
| 4796 if (iFirstCount == 0) |
| 4797 iFirstCount = 3; |
| 4798 |
| 4795 int32_t iIndex = 0; | 4799 int32_t iIndex = 0; |
| 4796 int32_t iFirstCount = iLength % 3; | |
| 4797 if (iFirstCount == 0) { | |
| 4798 iFirstCount = 3; | |
| 4799 } | |
| 4800 if (iFirstCount == 3) { | 4800 if (iFirstCount == 3) { |
| 4801 if (pData[iIndex] != '0') { | 4801 if (pData[iIndex] != '0') { |
| 4802 strBuf << pCapUnits[pData[iIndex] - '0']; | 4802 strBuf << pCapUnits[pData[iIndex] - '0']; |
| 4803 strBuf << pComm[0]; | 4803 strBuf << pComm[0]; |
| 4804 } | 4804 } |
| 4805 if (pData[iIndex + 1] == '0') { | 4805 if (pData[iIndex + 1] == '0') { |
| 4806 strBuf << pCapUnits[pData[iIndex + 2] - '0']; | 4806 strBuf << pCapUnits[pData[iIndex + 2] - '0']; |
| 4807 } else { | 4807 } else { |
| 4808 if (pData[iIndex + 1] > '1') { | 4808 if (pData[iIndex + 1] > '1') { |
| 4809 strBuf << pLastTens[pData[iIndex + 1] - '2']; | 4809 strBuf << pLastTens[pData[iIndex + 1] - '2']; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4864 iIndex += 3; | 4864 iIndex += 3; |
| 4865 } | 4865 } |
| 4866 } | 4866 } |
| 4867 | 4867 |
| 4868 // static | 4868 // static |
| 4869 void CXFA_FM2JSContext::WordUS(const CFX_ByteStringC& szData, | 4869 void CXFA_FM2JSContext::WordUS(const CFX_ByteStringC& szData, |
| 4870 int32_t iStyle, | 4870 int32_t iStyle, |
| 4871 CFX_ByteTextBuf& strBuf) { | 4871 CFX_ByteTextBuf& strBuf) { |
| 4872 const FX_CHAR* pData = szData.c_str(); | 4872 const FX_CHAR* pData = szData.c_str(); |
| 4873 int32_t iLength = szData.GetLength(); | 4873 int32_t iLength = szData.GetLength(); |
| 4874 switch (iStyle) { | 4874 if (iStyle < 0 || iStyle > 2) { |
| 4875 case 0: { | 4875 return; |
| 4876 int32_t iIndex = 0; | 4876 } |
| 4877 while (iIndex < iLength) { | 4877 |
| 4878 if (pData[iIndex] == '.') { | 4878 int32_t iIndex = 0; |
| 4879 break; | 4879 while (iIndex < iLength) { |
| 4880 } | 4880 if (pData[iIndex] == '.') |
| 4881 ++iIndex; | |
| 4882 } | |
| 4883 iLength = iIndex; | |
| 4884 iIndex = 0; | |
| 4885 int32_t iCount = 0; | |
| 4886 while (iIndex < iLength) { | |
| 4887 iCount = (iLength - iIndex) % 12; | |
| 4888 if (!iCount && iLength - iIndex > 0) { | |
| 4889 iCount = 12; | |
| 4890 } | |
| 4891 TrillionUS(CFX_ByteStringC(pData + iIndex, iCount), strBuf); | |
| 4892 iIndex += iCount; | |
| 4893 if (iIndex < iLength) { | |
| 4894 strBuf << " Trillion "; | |
| 4895 } | |
| 4896 } | |
| 4897 } break; | |
| 4898 case 1: { | |
| 4899 int32_t iIndex = 0; | |
| 4900 while (iIndex < iLength) { | |
| 4901 if (pData[iIndex] == '.') { | |
| 4902 break; | |
| 4903 } | |
| 4904 ++iIndex; | |
| 4905 } | |
| 4906 iLength = iIndex; | |
| 4907 iIndex = 0; | |
| 4908 int32_t iCount = 0; | |
| 4909 while (iIndex < iLength) { | |
| 4910 iCount = (iLength - iIndex) % 12; | |
| 4911 if (!iCount && iLength - iIndex > 0) { | |
| 4912 iCount = 12; | |
| 4913 } | |
| 4914 TrillionUS(CFX_ByteStringC(pData + iIndex, iCount), strBuf); | |
| 4915 iIndex += iCount; | |
| 4916 if (iIndex < iLength) { | |
| 4917 strBuf << " Trillion "; | |
| 4918 } | |
| 4919 } | |
| 4920 strBuf << " Dollars"; | |
| 4921 } break; | |
| 4922 case 2: { | |
| 4923 int32_t iIndex = 0; | |
| 4924 while (iIndex < iLength) { | |
| 4925 if (pData[iIndex] == '.') { | |
| 4926 break; | |
| 4927 } | |
| 4928 ++iIndex; | |
| 4929 } | |
| 4930 int32_t iInteger = iIndex; | |
| 4931 iIndex = 0; | |
| 4932 int32_t iCount = 0; | |
| 4933 while (iIndex < iInteger) { | |
| 4934 iCount = (iInteger - iIndex) % 12; | |
| 4935 if (!iCount && iLength - iIndex > 0) { | |
| 4936 iCount = 12; | |
| 4937 } | |
| 4938 TrillionUS(CFX_ByteStringC(pData + iIndex, iCount), strBuf); | |
| 4939 iIndex += iCount; | |
| 4940 if (iIndex < iInteger) { | |
| 4941 strBuf << " Trillion "; | |
| 4942 } | |
| 4943 } | |
| 4944 strBuf << " Dollars"; | |
| 4945 if (iInteger < iLength) { | |
| 4946 strBuf << " And "; | |
| 4947 iIndex = iInteger + 1; | |
| 4948 while (iIndex < iLength) { | |
| 4949 int32_t iSize = (iLength - iIndex) % 12; | |
| 4950 if (!iSize && iLength - iIndex > 0) | |
| 4951 iSize = 12; | |
| 4952 TrillionUS(CFX_ByteStringC(pData + iIndex, iSize), strBuf); | |
| 4953 iIndex += iSize; | |
| 4954 if (iIndex < iLength) { | |
| 4955 strBuf << " Trillion "; | |
| 4956 } | |
| 4957 } | |
| 4958 strBuf << " Cents"; | |
| 4959 } | |
| 4960 } break; | |
| 4961 default: | |
| 4962 break; | 4881 break; |
| 4882 ++iIndex; |
| 4883 } |
| 4884 int32_t iInteger = iIndex; |
| 4885 iIndex = 0; |
| 4886 while (iIndex < iInteger) { |
| 4887 int32_t iCount = (iInteger - iIndex) % 12; |
| 4888 if (!iCount && iInteger - iIndex > 0) |
| 4889 iCount = 12; |
| 4890 |
| 4891 TrillionUS(CFX_ByteStringC(pData + iIndex, iCount), strBuf); |
| 4892 iIndex += iCount; |
| 4893 if (iIndex < iInteger) |
| 4894 strBuf << " Trillion "; |
| 4895 } |
| 4896 |
| 4897 if (iStyle > 0) |
| 4898 strBuf << " Dollars"; |
| 4899 |
| 4900 if (iStyle > 1 && iInteger < iLength) { |
| 4901 strBuf << " And "; |
| 4902 iIndex = iInteger + 1; |
| 4903 while (iIndex < iLength) { |
| 4904 int32_t iCount = (iLength - iIndex) % 12; |
| 4905 if (!iCount && iLength - iIndex > 0) |
| 4906 iCount = 12; |
| 4907 |
| 4908 TrillionUS(CFX_ByteStringC(pData + iIndex, iCount), strBuf); |
| 4909 iIndex += iCount; |
| 4910 if (iIndex < iLength) |
| 4911 strBuf << " Trillion "; |
| 4912 } |
| 4913 strBuf << " Cents"; |
| 4963 } | 4914 } |
| 4964 } | 4915 } |
| 4965 | 4916 |
| 4966 // static | 4917 // static |
| 4967 void CXFA_FM2JSContext::Get(CFXJSE_Value* pThis, | 4918 void CXFA_FM2JSContext::Get(CFXJSE_Value* pThis, |
| 4968 const CFX_ByteStringC& szFuncName, | 4919 const CFX_ByteStringC& szFuncName, |
| 4969 CFXJSE_Arguments& args) { | 4920 CFXJSE_Arguments& args) { |
| 4970 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); | 4921 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); |
| 4971 if (args.GetLength() == 1) { | 4922 if (args.GetLength() != 1) { |
| 4972 CXFA_Document* pDoc = pContext->GetDocument(); | |
| 4973 if (!pDoc) { | |
| 4974 return; | |
| 4975 } | |
| 4976 IXFA_AppProvider* pAppProvider = | |
| 4977 pDoc->GetParser()->GetNotify()->GetAppProvider(); | |
| 4978 if (!pAppProvider) { | |
| 4979 return; | |
| 4980 } | |
| 4981 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | |
| 4982 CFX_ByteString urlString; | |
| 4983 ValueToUTF8String(argOne.get(), urlString); | |
| 4984 IFX_FileRead* pFile = pAppProvider->DownloadURL( | |
| 4985 CFX_WideString::FromUTF8(urlString.AsStringC())); | |
| 4986 if (pFile) { | |
| 4987 int32_t size = pFile->GetSize(); | |
| 4988 uint8_t* pData = FX_Alloc(uint8_t, size); | |
| 4989 pFile->ReadBlock(pData, size); | |
| 4990 args.GetReturnValue()->SetString(CFX_ByteStringC(pData, size)); | |
| 4991 FX_Free(pData); | |
| 4992 pFile->Release(); | |
| 4993 } | |
| 4994 } else { | |
| 4995 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Get"); | 4923 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Get"); |
| 4924 return; |
| 4996 } | 4925 } |
| 4926 |
| 4927 CXFA_Document* pDoc = pContext->GetDocument(); |
| 4928 if (!pDoc) |
| 4929 return; |
| 4930 |
| 4931 IXFA_AppProvider* pAppProvider = |
| 4932 pDoc->GetParser()->GetNotify()->GetAppProvider(); |
| 4933 if (!pAppProvider) |
| 4934 return; |
| 4935 |
| 4936 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 4937 CFX_ByteString urlString; |
| 4938 ValueToUTF8String(argOne.get(), urlString); |
| 4939 IFX_FileRead* pFile = pAppProvider->DownloadURL( |
| 4940 CFX_WideString::FromUTF8(urlString.AsStringC())); |
| 4941 if (!pFile) |
| 4942 return; |
| 4943 |
| 4944 int32_t size = pFile->GetSize(); |
| 4945 std::unique_ptr<uint8_t> pData(FX_Alloc(uint8_t, size)); |
| 4946 pFile->ReadBlock(pData.get(), size); |
| 4947 args.GetReturnValue()->SetString(CFX_ByteStringC(pData.get(), size)); |
| 4948 pFile->Release(); |
| 4997 } | 4949 } |
| 4998 | 4950 |
| 4999 // static | 4951 // static |
| 5000 void CXFA_FM2JSContext::Post(CFXJSE_Value* pThis, | 4952 void CXFA_FM2JSContext::Post(CFXJSE_Value* pThis, |
| 5001 const CFX_ByteStringC& szFuncName, | 4953 const CFX_ByteStringC& szFuncName, |
| 5002 CFXJSE_Arguments& args) { | 4954 CFXJSE_Arguments& args) { |
| 5003 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); | 4955 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); |
| 5004 int32_t argc = args.GetLength(); | 4956 int32_t argc = args.GetLength(); |
| 5005 if ((argc >= 2) && (argc <= 5)) { | 4957 if (argc < 2 || argc > 5) { |
| 5006 CXFA_Document* pDoc = pContext->GetDocument(); | |
| 5007 if (!pDoc) { | |
| 5008 return; | |
| 5009 } | |
| 5010 IXFA_AppProvider* pAppProvider = | |
| 5011 pDoc->GetParser()->GetNotify()->GetAppProvider(); | |
| 5012 if (!pAppProvider) { | |
| 5013 return; | |
| 5014 } | |
| 5015 CFX_ByteString bsURL; | |
| 5016 CFX_ByteString bsData; | |
| 5017 CFX_ByteString bsContentType; | |
| 5018 CFX_ByteString bsEncode; | |
| 5019 CFX_ByteString bsHeader; | |
| 5020 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | |
| 5021 ValueToUTF8String(argOne.get(), bsURL); | |
| 5022 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | |
| 5023 ValueToUTF8String(argTwo.get(), bsData); | |
| 5024 if (argc > 2) { | |
| 5025 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); | |
| 5026 ValueToUTF8String(argThree.get(), bsContentType); | |
| 5027 } | |
| 5028 if (argc > 3) { | |
| 5029 std::unique_ptr<CFXJSE_Value> argFour = GetSimpleValue(pThis, args, 3); | |
| 5030 ValueToUTF8String(argFour.get(), bsEncode); | |
| 5031 } | |
| 5032 if (argc > 4) { | |
| 5033 std::unique_ptr<CFXJSE_Value> argFive = GetSimpleValue(pThis, args, 4); | |
| 5034 ValueToUTF8String(argFive.get(), bsHeader); | |
| 5035 } | |
| 5036 CFX_WideString decodedResponse; | |
| 5037 FX_BOOL bFlags = pAppProvider->PostRequestURL( | |
| 5038 CFX_WideString::FromUTF8(bsURL.AsStringC()), | |
| 5039 CFX_WideString::FromUTF8(bsData.AsStringC()), | |
| 5040 CFX_WideString::FromUTF8(bsContentType.AsStringC()), | |
| 5041 CFX_WideString::FromUTF8(bsEncode.AsStringC()), | |
| 5042 CFX_WideString::FromUTF8(bsHeader.AsStringC()), decodedResponse); | |
| 5043 if (bFlags) { | |
| 5044 args.GetReturnValue()->SetString( | |
| 5045 FX_UTF8Encode(decodedResponse.c_str(), decodedResponse.GetLength()) | |
| 5046 .AsStringC()); | |
| 5047 } else { | |
| 5048 pContext->ThrowException(XFA_IDS_SERVER_DENY); | |
| 5049 } | |
| 5050 } else { | |
| 5051 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Post"); | 4958 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Post"); |
| 4959 return; |
| 5052 } | 4960 } |
| 4961 |
| 4962 CXFA_Document* pDoc = pContext->GetDocument(); |
| 4963 if (!pDoc) |
| 4964 return; |
| 4965 |
| 4966 IXFA_AppProvider* pAppProvider = |
| 4967 pDoc->GetParser()->GetNotify()->GetAppProvider(); |
| 4968 if (!pAppProvider) |
| 4969 return; |
| 4970 |
| 4971 CFX_ByteString bsURL; |
| 4972 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 4973 ValueToUTF8String(argOne.get(), bsURL); |
| 4974 |
| 4975 CFX_ByteString bsData; |
| 4976 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
| 4977 ValueToUTF8String(argTwo.get(), bsData); |
| 4978 |
| 4979 CFX_ByteString bsContentType; |
| 4980 if (argc > 2) { |
| 4981 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); |
| 4982 ValueToUTF8String(argThree.get(), bsContentType); |
| 4983 } |
| 4984 |
| 4985 CFX_ByteString bsEncode; |
| 4986 if (argc > 3) { |
| 4987 std::unique_ptr<CFXJSE_Value> argFour = GetSimpleValue(pThis, args, 3); |
| 4988 ValueToUTF8String(argFour.get(), bsEncode); |
| 4989 } |
| 4990 |
| 4991 CFX_ByteString bsHeader; |
| 4992 if (argc > 4) { |
| 4993 std::unique_ptr<CFXJSE_Value> argFive = GetSimpleValue(pThis, args, 4); |
| 4994 ValueToUTF8String(argFive.get(), bsHeader); |
| 4995 } |
| 4996 |
| 4997 CFX_WideString decodedResponse; |
| 4998 if (!pAppProvider->PostRequestURL( |
| 4999 CFX_WideString::FromUTF8(bsURL.AsStringC()), |
| 5000 CFX_WideString::FromUTF8(bsData.AsStringC()), |
| 5001 CFX_WideString::FromUTF8(bsContentType.AsStringC()), |
| 5002 CFX_WideString::FromUTF8(bsEncode.AsStringC()), |
| 5003 CFX_WideString::FromUTF8(bsHeader.AsStringC()), decodedResponse)) { |
| 5004 pContext->ThrowException(XFA_IDS_SERVER_DENY); |
| 5005 return; |
| 5006 } |
| 5007 |
| 5008 args.GetReturnValue()->SetString( |
| 5009 FX_UTF8Encode(decodedResponse.c_str(), decodedResponse.GetLength()) |
| 5010 .AsStringC()); |
| 5053 } | 5011 } |
| 5054 | 5012 |
| 5055 // static | 5013 // static |
| 5056 void CXFA_FM2JSContext::Put(CFXJSE_Value* pThis, | 5014 void CXFA_FM2JSContext::Put(CFXJSE_Value* pThis, |
| 5057 const CFX_ByteStringC& szFuncName, | 5015 const CFX_ByteStringC& szFuncName, |
| 5058 CFXJSE_Arguments& args) { | 5016 CFXJSE_Arguments& args) { |
| 5059 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); | 5017 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); |
| 5060 int32_t argc = args.GetLength(); | 5018 int32_t argc = args.GetLength(); |
| 5061 if ((argc == 2) || (argc == 3)) { | 5019 if (argc < 2 || argc > 3) { |
| 5062 CXFA_Document* pDoc = pContext->GetDocument(); | |
| 5063 if (!pDoc) { | |
| 5064 return; | |
| 5065 } | |
| 5066 IXFA_AppProvider* pAppProvider = | |
| 5067 pDoc->GetParser()->GetNotify()->GetAppProvider(); | |
| 5068 if (!pAppProvider) { | |
| 5069 return; | |
| 5070 } | |
| 5071 CFX_ByteString bsURL; | |
| 5072 CFX_ByteString bsData; | |
| 5073 CFX_ByteString bsEncode; | |
| 5074 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | |
| 5075 ValueToUTF8String(argOne.get(), bsURL); | |
| 5076 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | |
| 5077 ValueToUTF8String(argTwo.get(), bsData); | |
| 5078 if (argc > 2) { | |
| 5079 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); | |
| 5080 ValueToUTF8String(argThree.get(), bsEncode); | |
| 5081 } | |
| 5082 FX_BOOL bFlags = pAppProvider->PutRequestURL( | |
| 5083 CFX_WideString::FromUTF8(bsURL.AsStringC()), | |
| 5084 CFX_WideString::FromUTF8(bsData.AsStringC()), | |
| 5085 CFX_WideString::FromUTF8(bsEncode.AsStringC())); | |
| 5086 if (bFlags) { | |
| 5087 args.GetReturnValue()->SetString(""); | |
| 5088 } else { | |
| 5089 pContext->ThrowException(XFA_IDS_SERVER_DENY); | |
| 5090 } | |
| 5091 } else { | |
| 5092 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Put"); | 5020 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Put"); |
| 5021 return; |
| 5093 } | 5022 } |
| 5023 |
| 5024 CXFA_Document* pDoc = pContext->GetDocument(); |
| 5025 if (!pDoc) |
| 5026 return; |
| 5027 |
| 5028 IXFA_AppProvider* pAppProvider = |
| 5029 pDoc->GetParser()->GetNotify()->GetAppProvider(); |
| 5030 if (!pAppProvider) |
| 5031 return; |
| 5032 |
| 5033 CFX_ByteString bsURL; |
| 5034 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 5035 ValueToUTF8String(argOne.get(), bsURL); |
| 5036 |
| 5037 CFX_ByteString bsData; |
| 5038 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
| 5039 ValueToUTF8String(argTwo.get(), bsData); |
| 5040 |
| 5041 CFX_ByteString bsEncode; |
| 5042 if (argc > 2) { |
| 5043 std::unique_ptr<CFXJSE_Value> argThree = GetSimpleValue(pThis, args, 2); |
| 5044 ValueToUTF8String(argThree.get(), bsEncode); |
| 5045 } |
| 5046 |
| 5047 if (!pAppProvider->PutRequestURL( |
| 5048 CFX_WideString::FromUTF8(bsURL.AsStringC()), |
| 5049 CFX_WideString::FromUTF8(bsData.AsStringC()), |
| 5050 CFX_WideString::FromUTF8(bsEncode.AsStringC()))) { |
| 5051 pContext->ThrowException(XFA_IDS_SERVER_DENY); |
| 5052 return; |
| 5053 } |
| 5054 |
| 5055 args.GetReturnValue()->SetString(""); |
| 5094 } | 5056 } |
| 5095 | 5057 |
| 5096 // static | 5058 // static |
| 5097 void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis, | 5059 void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis, |
| 5098 const CFX_ByteStringC& szFuncName, | 5060 const CFX_ByteStringC& szFuncName, |
| 5099 CFXJSE_Arguments& args) { | 5061 CFXJSE_Arguments& args) { |
| 5100 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); | 5062 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); |
| 5101 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 5063 if (args.GetLength() != 2) { |
| 5102 if (args.GetLength() == 2) { | 5064 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5103 std::unique_ptr<CFXJSE_Value> lValue = args.GetValue(0); | 5065 return; |
| 5104 std::unique_ptr<CFXJSE_Value> rValue = GetSimpleValue(pThis, args, 1); | 5066 } |
| 5105 FX_BOOL bSetStatus = TRUE; | 5067 |
| 5106 if (lValue->IsArray()) { | 5068 std::unique_ptr<CFXJSE_Value> lValue = args.GetValue(0); |
| 5107 std::unique_ptr<CFXJSE_Value> leftLengthValue(new CFXJSE_Value(pIsolate)); | 5069 std::unique_ptr<CFXJSE_Value> rValue = GetSimpleValue(pThis, args, 1); |
| 5108 lValue->GetObjectProperty("length", leftLengthValue.get()); | 5070 if (lValue->IsArray()) { |
| 5109 int32_t iLeftLength = leftLengthValue->ToInteger(); | 5071 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 5110 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 5072 std::unique_ptr<CFXJSE_Value> leftLengthValue(new CFXJSE_Value(pIsolate)); |
| 5111 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 5073 lValue->GetObjectProperty("length", leftLengthValue.get()); |
| 5112 lValue->GetObjectPropertyByIdx(1, propertyValue.get()); | 5074 int32_t iLeftLength = leftLengthValue->ToInteger(); |
| 5113 if (propertyValue->IsNull()) { | 5075 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 5114 for (int32_t i = 2; i < iLeftLength; i++) { | 5076 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 5115 lValue->GetObjectPropertyByIdx(i, jsObjectValue.get()); | 5077 lValue->GetObjectPropertyByIdx(1, propertyValue.get()); |
| 5116 bSetStatus = SetObjectDefaultValue(jsObjectValue.get(), rValue.get()); | 5078 if (propertyValue->IsNull()) { |
| 5117 if (!bSetStatus) { | 5079 for (int32_t i = 2; i < iLeftLength; i++) { |
| 5118 pContext->ThrowException(XFA_IDS_NOT_DEFAUL_VALUE); | 5080 lValue->GetObjectPropertyByIdx(i, jsObjectValue.get()); |
| 5119 break; | 5081 if (!SetObjectDefaultValue(jsObjectValue.get(), rValue.get())) { |
| 5120 } | 5082 pContext->ThrowException(XFA_IDS_NOT_DEFAUL_VALUE); |
| 5121 } | 5083 return; |
| 5122 } else { | |
| 5123 CFX_ByteString propertyStr; | |
| 5124 propertyValue->ToString(propertyStr); | |
| 5125 for (int32_t i = 2; i < iLeftLength; i++) { | |
| 5126 lValue->GetObjectPropertyByIdx(i, jsObjectValue.get()); | |
| 5127 jsObjectValue->SetObjectProperty(propertyStr.AsStringC(), | |
| 5128 rValue.get()); | |
| 5129 } | 5084 } |
| 5130 } | 5085 } |
| 5131 } else if (lValue->IsObject()) { | 5086 } else { |
| 5132 bSetStatus = SetObjectDefaultValue(lValue.get(), rValue.get()); | 5087 CFX_ByteString propertyStr; |
| 5133 if (!bSetStatus) { | 5088 propertyValue->ToString(propertyStr); |
| 5134 pContext->ThrowException(XFA_IDS_NOT_DEFAUL_VALUE); | 5089 for (int32_t i = 2; i < iLeftLength; i++) { |
| 5090 lValue->GetObjectPropertyByIdx(i, jsObjectValue.get()); |
| 5091 jsObjectValue->SetObjectProperty(propertyStr.AsStringC(), rValue.get()); |
| 5135 } | 5092 } |
| 5136 } | 5093 } |
| 5137 args.GetReturnValue()->Assign(rValue.get()); | 5094 } else if (lValue->IsObject()) { |
| 5138 } else { | 5095 if (!SetObjectDefaultValue(lValue.get(), rValue.get())) { |
| 5139 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); | 5096 pContext->ThrowException(XFA_IDS_NOT_DEFAUL_VALUE); |
| 5140 } | 5097 return; |
| 5098 } |
| 5099 } |
| 5100 args.GetReturnValue()->Assign(rValue.get()); |
| 5141 } | 5101 } |
| 5142 | 5102 |
| 5143 // static | 5103 // static |
| 5144 void CXFA_FM2JSContext::logical_or_operator(CFXJSE_Value* pThis, | 5104 void CXFA_FM2JSContext::logical_or_operator(CFXJSE_Value* pThis, |
| 5145 const CFX_ByteStringC& szFuncName, | 5105 const CFX_ByteStringC& szFuncName, |
| 5146 CFXJSE_Arguments& args) { | 5106 CFXJSE_Arguments& args) { |
| 5147 if (args.GetLength() == 2) { | 5107 if (args.GetLength() != 2) { |
| 5148 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5108 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5149 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5109 return; |
| 5150 if (argFirst->IsNull() && argSecond->IsNull()) { | 5110 } |
| 5151 args.GetReturnValue()->SetNull(); | 5111 |
| 5152 } else { | 5112 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5153 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); | 5113 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5154 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); | 5114 if (argFirst->IsNull() && argSecond->IsNull()) { |
| 5155 args.GetReturnValue()->SetInteger((first || second) ? 1 : 0); | 5115 args.GetReturnValue()->SetNull(); |
| 5156 } | 5116 return; |
| 5157 } else { | 5117 } |
| 5158 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5118 |
| 5159 } | 5119 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); |
| 5120 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); |
| 5121 args.GetReturnValue()->SetInteger((first || second) ? 1 : 0); |
| 5160 } | 5122 } |
| 5161 | 5123 |
| 5162 // static | 5124 // static |
| 5163 void CXFA_FM2JSContext::logical_and_operator(CFXJSE_Value* pThis, | 5125 void CXFA_FM2JSContext::logical_and_operator(CFXJSE_Value* pThis, |
| 5164 const CFX_ByteStringC& szFuncName, | 5126 const CFX_ByteStringC& szFuncName, |
| 5165 CFXJSE_Arguments& args) { | 5127 CFXJSE_Arguments& args) { |
| 5166 if (args.GetLength() == 2) { | 5128 if (args.GetLength() != 2) { |
| 5167 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5129 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5168 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5130 return; |
| 5169 if (argFirst->IsNull() && argSecond->IsNull()) { | 5131 } |
| 5170 args.GetReturnValue()->SetNull(); | 5132 |
| 5171 } else { | 5133 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5172 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); | 5134 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5173 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); | 5135 if (argFirst->IsNull() && argSecond->IsNull()) { |
| 5174 args.GetReturnValue()->SetInteger((first && second) ? 1 : 0); | 5136 args.GetReturnValue()->SetNull(); |
| 5175 } | 5137 return; |
| 5176 } else { | 5138 } |
| 5177 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5139 |
| 5178 } | 5140 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); |
| 5141 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); |
| 5142 args.GetReturnValue()->SetInteger((first && second) ? 1 : 0); |
| 5179 } | 5143 } |
| 5180 | 5144 |
| 5181 // static | 5145 // static |
| 5182 void CXFA_FM2JSContext::equality_operator(CFXJSE_Value* pThis, | 5146 void CXFA_FM2JSContext::equality_operator(CFXJSE_Value* pThis, |
| 5183 const CFX_ByteStringC& szFuncName, | 5147 const CFX_ByteStringC& szFuncName, |
| 5184 CFXJSE_Arguments& args) { | 5148 CFXJSE_Arguments& args) { |
| 5185 if (args.GetLength() == 2) { | 5149 if (args.GetLength() != 2) { |
| 5186 if (fm_ref_equal(pThis, args)) { | 5150 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5187 args.GetReturnValue()->SetInteger(1); | 5151 return; |
| 5188 } else { | 5152 } |
| 5189 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5153 |
| 5190 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5154 if (fm_ref_equal(pThis, args)) { |
| 5191 if (argFirst->IsNull() || argSecond->IsNull()) { | 5155 args.GetReturnValue()->SetInteger(1); |
| 5192 args.GetReturnValue()->SetInteger( | 5156 return; |
| 5193 (argFirst->IsNull() && argSecond->IsNull()) ? 1 : 0); | 5157 } |
| 5194 } else if (argFirst->IsString() && argSecond->IsString()) { | 5158 |
| 5195 CFX_ByteString firstOutput; | 5159 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5196 CFX_ByteString secondOutput; | 5160 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5197 argFirst->ToString(firstOutput); | 5161 if (argFirst->IsNull() || argSecond->IsNull()) { |
| 5198 argSecond->ToString(secondOutput); | 5162 args.GetReturnValue()->SetInteger( |
| 5199 args.GetReturnValue()->SetInteger(firstOutput == secondOutput); | 5163 (argFirst->IsNull() && argSecond->IsNull()) ? 1 : 0); |
| 5200 } else { | 5164 return; |
| 5201 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5165 } |
| 5202 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5166 |
| 5203 args.GetReturnValue()->SetInteger((first == second) ? 1 : 0); | 5167 if (argFirst->IsString() && argSecond->IsString()) { |
| 5204 } | 5168 CFX_ByteString firstOutput; |
| 5205 } | 5169 CFX_ByteString secondOutput; |
| 5206 } else { | 5170 argFirst->ToString(firstOutput); |
| 5207 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5171 argSecond->ToString(secondOutput); |
| 5208 } | 5172 args.GetReturnValue()->SetInteger(firstOutput == secondOutput); |
| 5173 return; |
| 5174 } |
| 5175 |
| 5176 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5177 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5178 args.GetReturnValue()->SetInteger((first == second) ? 1 : 0); |
| 5209 } | 5179 } |
| 5210 | 5180 |
| 5211 // static | 5181 // static |
| 5212 void CXFA_FM2JSContext::notequality_operator(CFXJSE_Value* pThis, | 5182 void CXFA_FM2JSContext::notequality_operator(CFXJSE_Value* pThis, |
| 5213 const CFX_ByteStringC& szFuncName, | 5183 const CFX_ByteStringC& szFuncName, |
| 5214 CFXJSE_Arguments& args) { | 5184 CFXJSE_Arguments& args) { |
| 5215 if (args.GetLength() == 2) { | 5185 if (args.GetLength() != 2) { |
| 5216 if (fm_ref_equal(pThis, args)) { | 5186 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5217 args.GetReturnValue()->SetInteger(0); | 5187 return; |
| 5218 } else { | 5188 } |
| 5219 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5189 |
| 5220 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5190 if (fm_ref_equal(pThis, args)) { |
| 5221 if (argFirst->IsNull() || argSecond->IsNull()) { | 5191 args.GetReturnValue()->SetInteger(0); |
| 5222 args.GetReturnValue()->SetInteger( | 5192 return; |
| 5223 (argFirst->IsNull() && argSecond->IsNull()) ? 0 : 1); | 5193 } |
| 5224 } else if (argFirst->IsString() && argSecond->IsString()) { | 5194 |
| 5225 CFX_ByteString firstOutput; | 5195 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5226 CFX_ByteString secondOutput; | 5196 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5227 argFirst->ToString(firstOutput); | 5197 if (argFirst->IsNull() || argSecond->IsNull()) { |
| 5228 argSecond->ToString(secondOutput); | 5198 args.GetReturnValue()->SetInteger( |
| 5229 args.GetReturnValue()->SetInteger(firstOutput != secondOutput); | 5199 (argFirst->IsNull() && argSecond->IsNull()) ? 0 : 1); |
| 5230 } else { | 5200 return; |
| 5231 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5201 } |
| 5232 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5202 |
| 5233 args.GetReturnValue()->SetInteger(first != second); | 5203 if (argFirst->IsString() && argSecond->IsString()) { |
| 5234 } | 5204 CFX_ByteString firstOutput; |
| 5235 } | 5205 CFX_ByteString secondOutput; |
| 5236 } else { | 5206 argFirst->ToString(firstOutput); |
| 5237 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5207 argSecond->ToString(secondOutput); |
| 5238 } | 5208 args.GetReturnValue()->SetInteger(firstOutput != secondOutput); |
| 5209 return; |
| 5210 } |
| 5211 |
| 5212 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5213 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5214 args.GetReturnValue()->SetInteger(first != second); |
| 5239 } | 5215 } |
| 5240 | 5216 |
| 5241 // static | 5217 // static |
| 5242 FX_BOOL CXFA_FM2JSContext::fm_ref_equal(CFXJSE_Value* pThis, | 5218 FX_BOOL CXFA_FM2JSContext::fm_ref_equal(CFXJSE_Value* pThis, |
| 5243 CFXJSE_Arguments& args) { | 5219 CFXJSE_Arguments& args) { |
| 5244 FX_BOOL bRet = FALSE; | |
| 5245 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); | |
| 5246 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0); | 5220 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0); |
| 5247 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1); | 5221 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1); |
| 5248 if (argFirst->IsArray() && argSecond->IsArray()) { | 5222 if (!argFirst->IsArray() || !argSecond->IsArray()) |
| 5249 std::unique_ptr<CFXJSE_Value> firstFlagValue(new CFXJSE_Value(pIsolate)); | 5223 return FALSE; |
| 5250 std::unique_ptr<CFXJSE_Value> secondFlagValue(new CFXJSE_Value(pIsolate)); | 5224 |
| 5251 argFirst->GetObjectPropertyByIdx(0, firstFlagValue.get()); | 5225 v8::Isolate* pIsolate = ToJSContext(pThis, nullptr)->GetScriptRuntime(); |
| 5252 argSecond->GetObjectPropertyByIdx(0, secondFlagValue.get()); | 5226 std::unique_ptr<CFXJSE_Value> firstFlagValue(new CFXJSE_Value(pIsolate)); |
| 5253 if (firstFlagValue->ToInteger() == 3 && secondFlagValue->ToInteger() == 3) { | 5227 std::unique_ptr<CFXJSE_Value> secondFlagValue(new CFXJSE_Value(pIsolate)); |
| 5254 std::unique_ptr<CFXJSE_Value> firstJSObject(new CFXJSE_Value(pIsolate)); | 5228 argFirst->GetObjectPropertyByIdx(0, firstFlagValue.get()); |
| 5255 std::unique_ptr<CFXJSE_Value> secondJSObject(new CFXJSE_Value(pIsolate)); | 5229 argSecond->GetObjectPropertyByIdx(0, secondFlagValue.get()); |
| 5256 argFirst->GetObjectPropertyByIdx(2, firstJSObject.get()); | 5230 if (firstFlagValue->ToInteger() != 3 || secondFlagValue->ToInteger() != 3) |
| 5257 argSecond->GetObjectPropertyByIdx(2, secondJSObject.get()); | 5231 return FALSE; |
| 5258 if (!firstJSObject->IsNull() && !secondJSObject->IsNull()) { | 5232 |
| 5259 bRet = (firstJSObject->ToHostObject(nullptr) == | 5233 std::unique_ptr<CFXJSE_Value> firstJSObject(new CFXJSE_Value(pIsolate)); |
| 5260 secondJSObject->ToHostObject(nullptr)); | 5234 std::unique_ptr<CFXJSE_Value> secondJSObject(new CFXJSE_Value(pIsolate)); |
| 5261 } | 5235 argFirst->GetObjectPropertyByIdx(2, firstJSObject.get()); |
| 5262 } | 5236 argSecond->GetObjectPropertyByIdx(2, secondJSObject.get()); |
| 5263 } | 5237 if (firstJSObject->IsNull() || secondJSObject->IsNull()) |
| 5264 return bRet; | 5238 return FALSE; |
| 5239 |
| 5240 return (firstJSObject->ToHostObject(nullptr) == |
| 5241 secondJSObject->ToHostObject(nullptr)); |
| 5265 } | 5242 } |
| 5266 | 5243 |
| 5267 // static | 5244 // static |
| 5268 void CXFA_FM2JSContext::less_operator(CFXJSE_Value* pThis, | 5245 void CXFA_FM2JSContext::less_operator(CFXJSE_Value* pThis, |
| 5269 const CFX_ByteStringC& szFuncName, | 5246 const CFX_ByteStringC& szFuncName, |
| 5270 CFXJSE_Arguments& args) { | 5247 CFXJSE_Arguments& args) { |
| 5271 if (args.GetLength() == 2) { | 5248 if (args.GetLength() != 2) { |
| 5272 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5249 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5273 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5250 return; |
| 5274 if (argFirst->IsNull() || argSecond->IsNull()) { | 5251 } |
| 5275 args.GetReturnValue()->SetInteger(0); | 5252 |
| 5276 } else if (argFirst->IsString() && argSecond->IsString()) { | 5253 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5277 CFX_ByteString firstOutput; | 5254 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5278 CFX_ByteString secondOutput; | 5255 if (argFirst->IsNull() || argSecond->IsNull()) { |
| 5279 argFirst->ToString(firstOutput); | 5256 args.GetReturnValue()->SetInteger(0); |
| 5280 argSecond->ToString(secondOutput); | 5257 return; |
| 5281 args.GetReturnValue()->SetInteger( | 5258 } |
| 5282 firstOutput.Compare(secondOutput.AsStringC()) == -1); | 5259 |
| 5283 } else { | 5260 if (argFirst->IsString() && argSecond->IsString()) { |
| 5284 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5261 CFX_ByteString firstOutput; |
| 5285 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5262 CFX_ByteString secondOutput; |
| 5286 args.GetReturnValue()->SetInteger((first < second) ? 1 : 0); | 5263 argFirst->ToString(firstOutput); |
| 5287 } | 5264 argSecond->ToString(secondOutput); |
| 5288 } else { | 5265 args.GetReturnValue()->SetInteger( |
| 5289 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5266 firstOutput.Compare(secondOutput.AsStringC()) == -1); |
| 5290 } | 5267 return; |
| 5268 } |
| 5269 |
| 5270 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5271 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5272 args.GetReturnValue()->SetInteger((first < second) ? 1 : 0); |
| 5291 } | 5273 } |
| 5292 | 5274 |
| 5293 // static | 5275 // static |
| 5294 void CXFA_FM2JSContext::lessequal_operator(CFXJSE_Value* pThis, | 5276 void CXFA_FM2JSContext::lessequal_operator(CFXJSE_Value* pThis, |
| 5295 const CFX_ByteStringC& szFuncName, | 5277 const CFX_ByteStringC& szFuncName, |
| 5296 CFXJSE_Arguments& args) { | 5278 CFXJSE_Arguments& args) { |
| 5297 if (args.GetLength() == 2) { | 5279 if (args.GetLength() != 2) { |
| 5298 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5280 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5299 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5281 return; |
| 5300 if (argFirst->IsNull() || argSecond->IsNull()) { | 5282 } |
| 5301 args.GetReturnValue()->SetInteger( | 5283 |
| 5302 (argFirst->IsNull() && argSecond->IsNull()) ? 1 : 0); | 5284 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5303 } else if (argFirst->IsString() && argSecond->IsString()) { | 5285 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5304 CFX_ByteString firstOutput; | 5286 if (argFirst->IsNull() || argSecond->IsNull()) { |
| 5305 CFX_ByteString secondOutput; | 5287 args.GetReturnValue()->SetInteger( |
| 5306 argFirst->ToString(firstOutput); | 5288 (argFirst->IsNull() && argSecond->IsNull()) ? 1 : 0); |
| 5307 argSecond->ToString(secondOutput); | 5289 return; |
| 5308 args.GetReturnValue()->SetInteger( | 5290 } |
| 5309 firstOutput.Compare(secondOutput.AsStringC()) != 1); | 5291 |
| 5310 } else { | 5292 if (argFirst->IsString() && argSecond->IsString()) { |
| 5311 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5293 CFX_ByteString firstOutput; |
| 5312 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5294 CFX_ByteString secondOutput; |
| 5313 args.GetReturnValue()->SetInteger((first <= second) ? 1 : 0); | 5295 argFirst->ToString(firstOutput); |
| 5314 } | 5296 argSecond->ToString(secondOutput); |
| 5315 } else { | 5297 args.GetReturnValue()->SetInteger( |
| 5316 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5298 firstOutput.Compare(secondOutput.AsStringC()) != 1); |
| 5317 } | 5299 return; |
| 5300 } |
| 5301 |
| 5302 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5303 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5304 args.GetReturnValue()->SetInteger((first <= second) ? 1 : 0); |
| 5318 } | 5305 } |
| 5319 | 5306 |
| 5320 // static | 5307 // static |
| 5321 void CXFA_FM2JSContext::greater_operator(CFXJSE_Value* pThis, | 5308 void CXFA_FM2JSContext::greater_operator(CFXJSE_Value* pThis, |
| 5322 const CFX_ByteStringC& szFuncName, | 5309 const CFX_ByteStringC& szFuncName, |
| 5323 CFXJSE_Arguments& args) { | 5310 CFXJSE_Arguments& args) { |
| 5324 if (args.GetLength() == 2) { | 5311 if (args.GetLength() != 2) { |
| 5325 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5312 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5326 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5313 return; |
| 5327 if (argFirst->IsNull() || argSecond->IsNull()) { | 5314 } |
| 5328 args.GetReturnValue()->SetInteger(0); | 5315 |
| 5329 } else if (argFirst->IsString() && argSecond->IsString()) { | 5316 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5330 CFX_ByteString firstOutput; | 5317 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5331 CFX_ByteString secondOutput; | 5318 if (argFirst->IsNull() || argSecond->IsNull()) { |
| 5332 argFirst->ToString(firstOutput); | 5319 args.GetReturnValue()->SetInteger(0); |
| 5333 argSecond->ToString(secondOutput); | 5320 return; |
| 5334 args.GetReturnValue()->SetInteger( | 5321 } |
| 5335 firstOutput.Compare(secondOutput.AsStringC()) == 1); | 5322 |
| 5336 } else { | 5323 if (argFirst->IsString() && argSecond->IsString()) { |
| 5337 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5324 CFX_ByteString firstOutput; |
| 5338 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5325 CFX_ByteString secondOutput; |
| 5339 args.GetReturnValue()->SetInteger((first > second) ? 1 : 0); | 5326 argFirst->ToString(firstOutput); |
| 5340 } | 5327 argSecond->ToString(secondOutput); |
| 5341 } else { | 5328 args.GetReturnValue()->SetInteger( |
| 5342 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5329 firstOutput.Compare(secondOutput.AsStringC()) == 1); |
| 5343 } | 5330 return; |
| 5331 } |
| 5332 |
| 5333 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5334 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5335 args.GetReturnValue()->SetInteger((first > second) ? 1 : 0); |
| 5344 } | 5336 } |
| 5345 | 5337 |
| 5346 // static | 5338 // static |
| 5347 void CXFA_FM2JSContext::greaterequal_operator(CFXJSE_Value* pThis, | 5339 void CXFA_FM2JSContext::greaterequal_operator(CFXJSE_Value* pThis, |
| 5348 const CFX_ByteStringC& szFuncName, | 5340 const CFX_ByteStringC& szFuncName, |
| 5349 CFXJSE_Arguments& args) { | 5341 CFXJSE_Arguments& args) { |
| 5350 if (args.GetLength() == 2) { | 5342 if (args.GetLength() != 2) { |
| 5351 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5343 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5352 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5344 return; |
| 5353 if (argFirst->IsNull() || argSecond->IsNull()) { | 5345 } |
| 5354 args.GetReturnValue()->SetInteger( | 5346 |
| 5355 (argFirst->IsNull() && argSecond->IsNull()) ? 1 : 0); | 5347 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5356 } else if (argFirst->IsString() && argSecond->IsString()) { | 5348 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5357 CFX_ByteString firstOutput; | 5349 if (argFirst->IsNull() || argSecond->IsNull()) { |
| 5358 CFX_ByteString secondOutput; | 5350 args.GetReturnValue()->SetInteger( |
| 5359 argFirst->ToString(firstOutput); | 5351 (argFirst->IsNull() && argSecond->IsNull()) ? 1 : 0); |
| 5360 argSecond->ToString(secondOutput); | 5352 return; |
| 5361 args.GetReturnValue()->SetInteger( | 5353 } |
| 5362 firstOutput.Compare(secondOutput.AsStringC()) != -1); | 5354 |
| 5363 } else { | 5355 if (argFirst->IsString() && argSecond->IsString()) { |
| 5364 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5356 CFX_ByteString firstOutput; |
| 5365 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5357 CFX_ByteString secondOutput; |
| 5366 args.GetReturnValue()->SetInteger((first >= second) ? 1 : 0); | 5358 argFirst->ToString(firstOutput); |
| 5367 } | 5359 argSecond->ToString(secondOutput); |
| 5368 } else { | 5360 args.GetReturnValue()->SetInteger( |
| 5369 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5361 firstOutput.Compare(secondOutput.AsStringC()) != -1); |
| 5370 } | 5362 return; |
| 5363 } |
| 5364 |
| 5365 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5366 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5367 args.GetReturnValue()->SetInteger((first >= second) ? 1 : 0); |
| 5371 } | 5368 } |
| 5372 | 5369 |
| 5373 // static | 5370 // static |
| 5374 void CXFA_FM2JSContext::plus_operator(CFXJSE_Value* pThis, | 5371 void CXFA_FM2JSContext::plus_operator(CFXJSE_Value* pThis, |
| 5375 const CFX_ByteStringC& szFuncName, | 5372 const CFX_ByteStringC& szFuncName, |
| 5376 CFXJSE_Arguments& args) { | 5373 CFXJSE_Arguments& args) { |
| 5377 if (args.GetLength() == 2) { | 5374 if (args.GetLength() != 2) { |
| 5378 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0); | 5375 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5379 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1); | 5376 return; |
| 5380 if (ValueIsNull(pThis, argFirst.get()) && | 5377 } |
| 5381 ValueIsNull(pThis, argSecond.get())) { | 5378 |
| 5382 args.GetReturnValue()->SetNull(); | 5379 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0); |
| 5383 } else { | 5380 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1); |
| 5384 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5381 if (ValueIsNull(pThis, argFirst.get()) && |
| 5385 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5382 ValueIsNull(pThis, argSecond.get())) { |
| 5386 args.GetReturnValue()->SetDouble(first + second); | 5383 args.GetReturnValue()->SetNull(); |
| 5387 } | 5384 return; |
| 5388 } else { | 5385 } |
| 5389 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5386 |
| 5390 } | 5387 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5388 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5389 args.GetReturnValue()->SetDouble(first + second); |
| 5391 } | 5390 } |
| 5392 | 5391 |
| 5393 // static | 5392 // static |
| 5394 void CXFA_FM2JSContext::minus_operator(CFXJSE_Value* pThis, | 5393 void CXFA_FM2JSContext::minus_operator(CFXJSE_Value* pThis, |
| 5395 const CFX_ByteStringC& szFuncName, | 5394 const CFX_ByteStringC& szFuncName, |
| 5396 CFXJSE_Arguments& args) { | 5395 CFXJSE_Arguments& args) { |
| 5397 if (args.GetLength() == 2) { | 5396 if (args.GetLength() != 2) { |
| 5398 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5397 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5399 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5398 return; |
| 5400 if (argFirst->IsNull() && argSecond->IsNull()) { | 5399 } |
| 5401 args.GetReturnValue()->SetNull(); | 5400 |
| 5402 } else { | 5401 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5403 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5402 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5404 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5403 if (argFirst->IsNull() && argSecond->IsNull()) { |
| 5405 args.GetReturnValue()->SetDouble(first - second); | 5404 args.GetReturnValue()->SetNull(); |
| 5406 } | 5405 return; |
| 5407 } else { | 5406 } |
| 5408 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5407 |
| 5409 } | 5408 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5409 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5410 args.GetReturnValue()->SetDouble(first - second); |
| 5410 } | 5411 } |
| 5411 | 5412 |
| 5412 // static | 5413 // static |
| 5413 void CXFA_FM2JSContext::multiple_operator(CFXJSE_Value* pThis, | 5414 void CXFA_FM2JSContext::multiple_operator(CFXJSE_Value* pThis, |
| 5414 const CFX_ByteStringC& szFuncName, | 5415 const CFX_ByteStringC& szFuncName, |
| 5415 CFXJSE_Arguments& args) { | 5416 CFXJSE_Arguments& args) { |
| 5416 if (args.GetLength() == 2) { | 5417 if (args.GetLength() != 2) { |
| 5417 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5418 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5418 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5419 return; |
| 5419 if (argFirst->IsNull() && argSecond->IsNull()) { | 5420 } |
| 5420 args.GetReturnValue()->SetNull(); | 5421 |
| 5421 } else { | 5422 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5422 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5423 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5423 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5424 if (argFirst->IsNull() && argSecond->IsNull()) { |
| 5424 args.GetReturnValue()->SetDouble(first * second); | 5425 args.GetReturnValue()->SetNull(); |
| 5425 } | 5426 return; |
| 5426 } else { | 5427 } |
| 5427 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5428 |
| 5428 } | 5429 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5429 } | 5430 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5430 | 5431 args.GetReturnValue()->SetDouble(first * second); |
| 5431 // static | 5432 } |
| 5433 |
| 5434 // static |
| 5432 void CXFA_FM2JSContext::divide_operator(CFXJSE_Value* pThis, | 5435 void CXFA_FM2JSContext::divide_operator(CFXJSE_Value* pThis, |
| 5433 const CFX_ByteStringC& szFuncName, | 5436 const CFX_ByteStringC& szFuncName, |
| 5434 CFXJSE_Arguments& args) { | 5437 CFXJSE_Arguments& args) { |
| 5435 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); | 5438 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); |
| 5436 if (args.GetLength() == 2) { | 5439 if (args.GetLength() != 2) { |
| 5437 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | |
| 5438 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | |
| 5439 if (argFirst->IsNull() && argSecond->IsNull()) { | |
| 5440 args.GetReturnValue()->SetNull(); | |
| 5441 } else { | |
| 5442 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | |
| 5443 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | |
| 5444 if (second == 0.0) { | |
| 5445 pContext->ThrowException(XFA_IDS_DIVIDE_ZERO); | |
| 5446 } else { | |
| 5447 args.GetReturnValue()->SetDouble(first / second); | |
| 5448 } | |
| 5449 } | |
| 5450 } else { | |
| 5451 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); | 5440 pContext->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5441 return; |
| 5452 } | 5442 } |
| 5443 |
| 5444 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5445 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5446 if (argFirst->IsNull() && argSecond->IsNull()) { |
| 5447 args.GetReturnValue()->SetNull(); |
| 5448 return; |
| 5449 } |
| 5450 |
| 5451 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5452 if (second == 0.0) { |
| 5453 pContext->ThrowException(XFA_IDS_DIVIDE_ZERO); |
| 5454 return; |
| 5455 } |
| 5456 |
| 5457 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5458 args.GetReturnValue()->SetDouble(first / second); |
| 5453 } | 5459 } |
| 5454 | 5460 |
| 5455 // static | 5461 // static |
| 5456 void CXFA_FM2JSContext::positive_operator(CFXJSE_Value* pThis, | 5462 void CXFA_FM2JSContext::positive_operator(CFXJSE_Value* pThis, |
| 5457 const CFX_ByteStringC& szFuncName, | 5463 const CFX_ByteStringC& szFuncName, |
| 5458 CFXJSE_Arguments& args) { | 5464 CFXJSE_Arguments& args) { |
| 5459 if (args.GetLength() == 1) { | 5465 if (args.GetLength() != 1) { |
| 5460 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | |
| 5461 if (argOne->IsNull()) { | |
| 5462 args.GetReturnValue()->SetNull(); | |
| 5463 } else { | |
| 5464 args.GetReturnValue()->SetDouble(0.0 + | |
| 5465 ValueToDouble(pThis, argOne.get())); | |
| 5466 } | |
| 5467 } else { | |
| 5468 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5466 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5467 return; |
| 5469 } | 5468 } |
| 5469 |
| 5470 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 5471 if (argOne->IsNull()) { |
| 5472 args.GetReturnValue()->SetNull(); |
| 5473 return; |
| 5474 } |
| 5475 args.GetReturnValue()->SetDouble(0.0 + ValueToDouble(pThis, argOne.get())); |
| 5470 } | 5476 } |
| 5471 | 5477 |
| 5472 // static | 5478 // static |
| 5473 void CXFA_FM2JSContext::negative_operator(CFXJSE_Value* pThis, | 5479 void CXFA_FM2JSContext::negative_operator(CFXJSE_Value* pThis, |
| 5474 const CFX_ByteStringC& szFuncName, | 5480 const CFX_ByteStringC& szFuncName, |
| 5475 CFXJSE_Arguments& args) { | 5481 CFXJSE_Arguments& args) { |
| 5476 if (args.GetLength() == 1) { | 5482 if (args.GetLength() != 1) { |
| 5477 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | |
| 5478 if (argOne->IsNull()) { | |
| 5479 args.GetReturnValue()->SetNull(); | |
| 5480 } else { | |
| 5481 args.GetReturnValue()->SetDouble(0.0 - | |
| 5482 ValueToDouble(pThis, argOne.get())); | |
| 5483 } | |
| 5484 } else { | |
| 5485 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5483 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5484 return; |
| 5486 } | 5485 } |
| 5486 |
| 5487 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 5488 if (argOne->IsNull()) { |
| 5489 args.GetReturnValue()->SetNull(); |
| 5490 return; |
| 5491 } |
| 5492 args.GetReturnValue()->SetDouble(0.0 - ValueToDouble(pThis, argOne.get())); |
| 5487 } | 5493 } |
| 5488 | 5494 |
| 5489 // static | 5495 // static |
| 5490 void CXFA_FM2JSContext::logical_not_operator(CFXJSE_Value* pThis, | 5496 void CXFA_FM2JSContext::logical_not_operator(CFXJSE_Value* pThis, |
| 5491 const CFX_ByteStringC& szFuncName, | 5497 const CFX_ByteStringC& szFuncName, |
| 5492 CFXJSE_Arguments& args) { | 5498 CFXJSE_Arguments& args) { |
| 5493 if (args.GetLength() == 1) { | 5499 if (args.GetLength() != 1) { |
| 5494 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | |
| 5495 if (argOne->IsNull()) { | |
| 5496 args.GetReturnValue()->SetNull(); | |
| 5497 } else { | |
| 5498 FX_DOUBLE first = ValueToDouble(pThis, argOne.get()); | |
| 5499 args.GetReturnValue()->SetInteger((first == 0.0) ? 1 : 0); | |
| 5500 } | |
| 5501 } else { | |
| 5502 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); | 5500 ToJSContext(pThis, nullptr)->ThrowException(XFA_IDS_COMPILER_ERROR); |
| 5501 return; |
| 5503 } | 5502 } |
| 5503 |
| 5504 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 5505 if (argOne->IsNull()) { |
| 5506 args.GetReturnValue()->SetNull(); |
| 5507 return; |
| 5508 } |
| 5509 |
| 5510 FX_DOUBLE first = ValueToDouble(pThis, argOne.get()); |
| 5511 args.GetReturnValue()->SetInteger((first == 0.0) ? 1 : 0); |
| 5504 } | 5512 } |
| 5505 | 5513 |
| 5506 // static | 5514 // static |
| 5507 void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis, | 5515 void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis, |
| 5508 const CFX_ByteStringC& szFuncName, | 5516 const CFX_ByteStringC& szFuncName, |
| 5509 CFXJSE_Arguments& args) { | 5517 CFXJSE_Arguments& args) { |
| 5510 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); | 5518 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); |
| 5511 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 5519 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 5512 int32_t argc = args.GetLength(); | 5520 int32_t argc = args.GetLength(); |
| 5513 if ((argc == 4) || (argc == 5)) { | 5521 if ((argc == 4) || (argc == 5)) { |
| (...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6570 CFX_WideString wsFormat; | 6578 CFX_WideString wsFormat; |
| 6571 pAppProvider->LoadString(iStringID, wsFormat); | 6579 pAppProvider->LoadString(iStringID, wsFormat); |
| 6572 CFX_WideString wsMessage; | 6580 CFX_WideString wsMessage; |
| 6573 va_list arg_ptr; | 6581 va_list arg_ptr; |
| 6574 va_start(arg_ptr, iStringID); | 6582 va_start(arg_ptr, iStringID); |
| 6575 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); | 6583 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); |
| 6576 va_end(arg_ptr); | 6584 va_end(arg_ptr); |
| 6577 FXJSE_ThrowMessage( | 6585 FXJSE_ThrowMessage( |
| 6578 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); | 6586 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); |
| 6579 } | 6587 } |
| OLD | NEW |