| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" | 7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" |
| 8 | 8 |
| 9 #include <time.h> | 9 #include <time.h> |
| 10 | 10 |
| 11 #include "core/fxcrt/include/fx_ext.h" | 11 #include "core/fxcrt/include/fx_ext.h" |
| 12 #include "xfa/fgas/localization/fgas_locale.h" | 12 #include "xfa/fgas/localization/fgas_locale.h" |
| 13 #include "xfa/fxfa/app/xfa_ffnotify.h" | 13 #include "xfa/fxfa/app/xfa_ffnotify.h" |
| 14 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" | 14 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" |
| 15 #include "xfa/fxfa/parser/xfa_document.h" | 15 #include "xfa/fxfa/parser/xfa_document.h" |
| 16 #include "xfa/fxfa/parser/xfa_localevalue.h" | 16 #include "xfa/fxfa/parser/xfa_localevalue.h" |
| 17 #include "xfa/fxfa/parser/xfa_parser.h" | 17 #include "xfa/fxfa/parser/xfa_parser.h" |
| 18 #include "xfa/fxfa/parser/xfa_parser_imp.h" | 18 #include "xfa/fxfa/parser/xfa_parser_imp.h" |
| 19 #include "xfa/fxfa/parser/xfa_script_imp.h" | 19 #include "xfa/fxfa/parser/xfa_script_imp.h" |
| 20 #include "xfa/fxjse/cfxjse_arguments.h" | 20 #include "xfa/fxjse/cfxjse_arguments.h" |
| 21 #include "xfa/fxjse/value.h" | 21 #include "xfa/fxjse/value.h" |
| 22 | 22 |
| 23 #define FINANCIAL_PRECISION 0.00000001 | 23 namespace { |
| 24 | 24 |
| 25 namespace { | 25 const double kFinancialPrecision = 0.00000001; |
| 26 | 26 |
| 27 struct XFA_FMHtmlReserveCode { | 27 struct XFA_FMHtmlReserveCode { |
| 28 uint32_t m_uCode; | 28 uint32_t m_uCode; |
| 29 const FX_WCHAR* m_htmlReserve; | 29 const FX_WCHAR* m_htmlReserve; |
| 30 }; | 30 }; |
| 31 |
| 31 struct XFA_FMHtmlHashedReserveCode { | 32 struct XFA_FMHtmlHashedReserveCode { |
| 32 uint32_t m_uHash; | 33 uint32_t m_uHash; |
| 33 const FX_WCHAR* m_htmlReserve; | 34 const FX_WCHAR* m_htmlReserve; |
| 34 uint32_t m_uCode; | 35 uint32_t m_uCode; |
| 35 }; | 36 }; |
| 36 | 37 |
| 37 const XFA_FMHtmlHashedReserveCode reservesForDecode[] = { | 38 const XFA_FMHtmlHashedReserveCode reservesForDecode[] = { |
| 38 {0x00018b62, L"Mu", 924}, {0x00019083, L"Nu", 925}, | 39 {0x00018b62, L"Mu", 924}, {0x00019083, L"Nu", 925}, |
| 39 {0x00019ab9, L"Pi", 928}, {0x0001c3c1, L"Xi", 926}, | 40 {0x00019ab9, L"Pi", 928}, {0x0001c3c1, L"Xi", 926}, |
| 40 {0x000210ac, L"ge", 8805}, {0x000210bb, L"gt", 62}, | 41 {0x000210ac, L"ge", 8805}, {0x000210bb, L"gt", 62}, |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 i++; | 390 i++; |
| 390 } else { | 391 } else { |
| 391 wsPattern.Delete(i); | 392 wsPattern.Delete(i); |
| 392 nLength--; | 393 nLength--; |
| 393 } | 394 } |
| 394 bEscape = !bEscape; | 395 bEscape = !bEscape; |
| 395 continue; | 396 continue; |
| 396 } | 397 } |
| 397 if (!bInConstRange && (n = wc - L'A') >= 0 && n <= (L'a' - L'A')) { | 398 if (!bInConstRange && (n = wc - L'A') >= 0 && n <= (L'a' - L'A')) { |
| 398 int32_t nAlt = (int32_t)pAltTable[n]; | 399 int32_t nAlt = (int32_t)pAltTable[n]; |
| 399 if (nAlt != 255) { | 400 if (nAlt != 255) |
| 400 wsPattern.SetAt(i, wsAltSymbols[nAlt]); | 401 wsPattern.SetAt(i, wsAltSymbols[nAlt]); |
| 401 } | |
| 402 } | 402 } |
| 403 i++; | 403 i++; |
| 404 bEscape = FALSE; | 404 bEscape = FALSE; |
| 405 } | 405 } |
| 406 } | 406 } |
| 407 | 407 |
| 408 bool PatternStringType(const CFX_ByteStringC& szPattern, |
| 409 uint32_t& patternType) { |
| 410 CFX_WideString wsPattern = CFX_WideString::FromUTF8(szPattern); |
| 411 if (FX_WSTRC(L"datetime") == wsPattern.Left(8)) { |
| 412 patternType = XFA_VT_DATETIME; |
| 413 return true; |
| 414 } |
| 415 if (FX_WSTRC(L"date") == wsPattern.Left(4)) { |
| 416 patternType = wsPattern.Find(L"time") > 0 ? XFA_VT_DATETIME : XFA_VT_DATE; |
| 417 return true; |
| 418 } |
| 419 if (FX_WSTRC(L"time") == wsPattern.Left(4)) { |
| 420 patternType = XFA_VT_TIME; |
| 421 return true; |
| 422 } |
| 423 if (FX_WSTRC(L"text") == wsPattern.Left(4)) { |
| 424 patternType = XFA_VT_TEXT; |
| 425 return true; |
| 426 } |
| 427 if (FX_WSTRC(L"num") == wsPattern.Left(3)) { |
| 428 if (FX_WSTRC(L"integer") == wsPattern.Mid(4, 7)) { |
| 429 patternType = XFA_VT_INTEGER; |
| 430 } else if (FX_WSTRC(L"decimal") == wsPattern.Mid(4, 7)) { |
| 431 patternType = XFA_VT_DECIMAL; |
| 432 } else if (FX_WSTRC(L"currency") == wsPattern.Mid(4, 8)) { |
| 433 patternType = XFA_VT_FLOAT; |
| 434 } else if (FX_WSTRC(L"percent") == wsPattern.Mid(4, 7)) { |
| 435 patternType = XFA_VT_FLOAT; |
| 436 } else { |
| 437 patternType = XFA_VT_FLOAT; |
| 438 } |
| 439 return true; |
| 440 } |
| 441 |
| 442 patternType = XFA_VT_NULL; |
| 443 wsPattern.MakeLower(); |
| 444 const FX_WCHAR* pData = wsPattern.c_str(); |
| 445 int32_t iLength = wsPattern.GetLength(); |
| 446 int32_t iIndex = 0; |
| 447 FX_BOOL bSingleQuotation = FALSE; |
| 448 FX_WCHAR patternChar; |
| 449 while (iIndex < iLength) { |
| 450 patternChar = *(pData + iIndex); |
| 451 if (patternChar == 0x27) { |
| 452 bSingleQuotation = !bSingleQuotation; |
| 453 } else if (!bSingleQuotation && |
| 454 (patternChar == 'y' || patternChar == 'j')) { |
| 455 patternType = XFA_VT_DATE; |
| 456 iIndex++; |
| 457 FX_WCHAR timePatternChar; |
| 458 while (iIndex < iLength) { |
| 459 timePatternChar = *(pData + iIndex); |
| 460 if (timePatternChar == 0x27) { |
| 461 bSingleQuotation = !bSingleQuotation; |
| 462 } else if (!bSingleQuotation && timePatternChar == 't') { |
| 463 patternType = XFA_VT_DATETIME; |
| 464 break; |
| 465 } |
| 466 iIndex++; |
| 467 } |
| 468 break; |
| 469 } else if (!bSingleQuotation && |
| 470 (patternChar == 'h' || patternChar == 'k')) { |
| 471 patternType = XFA_VT_TIME; |
| 472 break; |
| 473 } else if (!bSingleQuotation && |
| 474 (patternChar == 'a' || patternChar == 'x' || |
| 475 patternChar == 'o' || patternChar == '0')) { |
| 476 patternType = XFA_VT_TEXT; |
| 477 if (patternChar == 'x' || patternChar == 'o' || patternChar == '0') { |
| 478 break; |
| 479 } |
| 480 } else if (!bSingleQuotation && |
| 481 (patternChar == 'z' || patternChar == 's' || |
| 482 patternChar == 'e' || patternChar == 'v' || |
| 483 patternChar == '8' || patternChar == ',' || |
| 484 patternChar == '.' || patternChar == '$')) { |
| 485 patternType = XFA_VT_FLOAT; |
| 486 if (patternChar == 'v' || patternChar == '8' || patternChar == '$') { |
| 487 break; |
| 488 } |
| 489 } |
| 490 iIndex++; |
| 491 } |
| 492 if (patternType == XFA_VT_NULL) { |
| 493 patternType = XFA_VT_TEXT | XFA_VT_FLOAT; |
| 494 } |
| 495 return false; |
| 496 } |
| 497 |
| 408 } // namespace | 498 } // namespace |
| 409 | 499 |
| 500 // static |
| 410 void CXFA_FM2JSContext::Abs(CFXJSE_Value* pThis, | 501 void CXFA_FM2JSContext::Abs(CFXJSE_Value* pThis, |
| 411 const CFX_ByteStringC& szFuncName, | 502 const CFX_ByteStringC& szFuncName, |
| 412 CFXJSE_Arguments& args) { | 503 CFXJSE_Arguments& args) { |
| 413 if (args.GetLength() == 1) { | 504 if (args.GetLength() == 1) { |
| 414 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 505 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 415 if (ValueIsNull(pThis, argOne.get())) { | 506 if (ValueIsNull(pThis, argOne.get())) { |
| 416 FXJSE_Value_SetNull(args.GetReturnValue()); | 507 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 417 } else { | 508 } else { |
| 418 FX_DOUBLE dValue = ValueToDouble(pThis, argOne.get()); | 509 FX_DOUBLE dValue = ValueToDouble(pThis, argOne.get()); |
| 419 if (dValue < 0) { | 510 if (dValue < 0) { |
| 420 dValue = -dValue; | 511 dValue = -dValue; |
| 421 } | 512 } |
| 422 FXJSE_Value_SetDouble(args.GetReturnValue(), dValue); | 513 FXJSE_Value_SetDouble(args.GetReturnValue(), dValue); |
| 423 } | 514 } |
| 424 } else { | 515 } else { |
| 425 CXFA_FM2JSContext* pContext = | 516 CXFA_FM2JSContext* pContext = |
| 426 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 517 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 427 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 518 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 428 L"Abs"); | 519 L"Abs"); |
| 429 } | 520 } |
| 430 } | 521 } |
| 522 |
| 523 // static |
| 431 void CXFA_FM2JSContext::Avg(CFXJSE_Value* pThis, | 524 void CXFA_FM2JSContext::Avg(CFXJSE_Value* pThis, |
| 432 const CFX_ByteStringC& szFuncName, | 525 const CFX_ByteStringC& szFuncName, |
| 433 CFXJSE_Arguments& args) { | 526 CFXJSE_Arguments& args) { |
| 434 CXFA_FM2JSContext* pContext = | 527 CXFA_FM2JSContext* pContext = |
| 435 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 528 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 436 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 529 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 437 int32_t argc = args.GetLength(); | 530 int32_t argc = args.GetLength(); |
| 438 uint32_t uCount = 0; | 531 uint32_t uCount = 0; |
| 439 FX_DOUBLE dSum = 0.0; | 532 FX_DOUBLE dSum = 0.0; |
| 440 if (argc >= 1) { | 533 if (argc >= 1) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 uCount++; | 583 uCount++; |
| 491 } | 584 } |
| 492 } | 585 } |
| 493 } | 586 } |
| 494 if (0 == uCount) { | 587 if (0 == uCount) { |
| 495 FXJSE_Value_SetNull(args.GetReturnValue()); | 588 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 496 } else { | 589 } else { |
| 497 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum / uCount); | 590 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum / uCount); |
| 498 } | 591 } |
| 499 } | 592 } |
| 593 |
| 594 // static |
| 500 void CXFA_FM2JSContext::Ceil(CFXJSE_Value* pThis, | 595 void CXFA_FM2JSContext::Ceil(CFXJSE_Value* pThis, |
| 501 const CFX_ByteStringC& szFuncName, | 596 const CFX_ByteStringC& szFuncName, |
| 502 CFXJSE_Arguments& args) { | 597 CFXJSE_Arguments& args) { |
| 503 CXFA_FM2JSContext* pContext = | |
| 504 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
| 505 if (args.GetLength() == 1) { | 598 if (args.GetLength() == 1) { |
| 506 std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, args, 0); | 599 std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, args, 0); |
| 507 if (ValueIsNull(pThis, argValue.get())) { | 600 if (ValueIsNull(pThis, argValue.get())) { |
| 508 FXJSE_Value_SetNull(args.GetReturnValue()); | 601 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 509 } else { | 602 } else { |
| 510 FXJSE_Value_SetFloat(args.GetReturnValue(), | 603 FXJSE_Value_SetFloat(args.GetReturnValue(), |
| 511 FXSYS_ceil(ValueToFloat(pThis, argValue.get()))); | 604 FXSYS_ceil(ValueToFloat(pThis, argValue.get()))); |
| 512 } | 605 } |
| 513 } else { | 606 } else { |
| 607 CXFA_FM2JSContext* pContext = |
| 608 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 514 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 609 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 515 L"Ceil"); | 610 L"Ceil"); |
| 516 } | 611 } |
| 517 } | 612 } |
| 613 |
| 614 // static |
| 518 void CXFA_FM2JSContext::Count(CFXJSE_Value* pThis, | 615 void CXFA_FM2JSContext::Count(CFXJSE_Value* pThis, |
| 519 const CFX_ByteStringC& szFuncName, | 616 const CFX_ByteStringC& szFuncName, |
| 520 CFXJSE_Arguments& args) { | 617 CFXJSE_Arguments& args) { |
| 521 CXFA_FM2JSContext* pContext = | 618 CXFA_FM2JSContext* pContext = |
| 522 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 619 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 523 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 620 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 524 int32_t argc = args.GetLength(); | |
| 525 uint32_t uCount = 0; | 621 uint32_t uCount = 0; |
| 526 for (int32_t i = 0; i < argc; i++) { | 622 for (int32_t i = 0; i < args.GetLength(); i++) { |
| 527 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); | 623 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); |
| 528 if (FXJSE_Value_IsNull(argValue.get())) { | 624 if (FXJSE_Value_IsNull(argValue.get())) { |
| 529 continue; | 625 continue; |
| 530 } else if (FXJSE_Value_IsArray(argValue.get())) { | 626 } else if (FXJSE_Value_IsArray(argValue.get())) { |
| 531 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 627 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 532 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); | 628 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); |
| 533 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); | 629 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); |
| 534 | 630 |
| 535 if (iLength > 2) { | 631 if (iLength > 2) { |
| 536 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 632 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); | 665 GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); |
| 570 if (!FXJSE_Value_IsNull(newPropertyValue.get())) { | 666 if (!FXJSE_Value_IsNull(newPropertyValue.get())) { |
| 571 uCount++; | 667 uCount++; |
| 572 } | 668 } |
| 573 } else { | 669 } else { |
| 574 uCount++; | 670 uCount++; |
| 575 } | 671 } |
| 576 } | 672 } |
| 577 FXJSE_Value_SetInteger(args.GetReturnValue(), (int32_t)uCount); | 673 FXJSE_Value_SetInteger(args.GetReturnValue(), (int32_t)uCount); |
| 578 } | 674 } |
| 675 |
| 676 // static |
| 579 void CXFA_FM2JSContext::Floor(CFXJSE_Value* pThis, | 677 void CXFA_FM2JSContext::Floor(CFXJSE_Value* pThis, |
| 580 const CFX_ByteStringC& szFuncName, | 678 const CFX_ByteStringC& szFuncName, |
| 581 CFXJSE_Arguments& args) { | 679 CFXJSE_Arguments& args) { |
| 582 CXFA_FM2JSContext* pContext = | |
| 583 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
| 584 if (args.GetLength() == 1) { | 680 if (args.GetLength() == 1) { |
| 585 std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, args, 0); | 681 std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, args, 0); |
| 586 if (ValueIsNull(pThis, argValue.get())) { | 682 if (ValueIsNull(pThis, argValue.get())) { |
| 587 FXJSE_Value_SetNull(args.GetReturnValue()); | 683 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 588 } else { | 684 } else { |
| 589 FXJSE_Value_SetFloat(args.GetReturnValue(), | 685 FXJSE_Value_SetFloat(args.GetReturnValue(), |
| 590 FXSYS_floor(ValueToFloat(pThis, argValue.get()))); | 686 FXSYS_floor(ValueToFloat(pThis, argValue.get()))); |
| 591 } | 687 } |
| 592 } else { | 688 } else { |
| 689 CXFA_FM2JSContext* pContext = |
| 690 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 593 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 691 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 594 L"Floor"); | 692 L"Floor"); |
| 595 } | 693 } |
| 596 } | 694 } |
| 695 |
| 696 // static |
| 597 void CXFA_FM2JSContext::Max(CFXJSE_Value* pThis, | 697 void CXFA_FM2JSContext::Max(CFXJSE_Value* pThis, |
| 598 const CFX_ByteStringC& szFuncName, | 698 const CFX_ByteStringC& szFuncName, |
| 599 CFXJSE_Arguments& args) { | 699 CFXJSE_Arguments& args) { |
| 600 CXFA_FM2JSContext* pContext = | 700 CXFA_FM2JSContext* pContext = |
| 601 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 701 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 602 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 702 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 603 int32_t argc = args.GetLength(); | |
| 604 uint32_t uCount = 0; | 703 uint32_t uCount = 0; |
| 605 FX_DOUBLE dMaxValue = 0.0; | 704 FX_DOUBLE dMaxValue = 0.0; |
| 606 for (int32_t i = 0; i < argc; i++) { | 705 for (int32_t i = 0; i < args.GetLength(); i++) { |
| 607 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); | 706 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); |
| 608 if (FXJSE_Value_IsNull(argValue.get())) { | 707 if (FXJSE_Value_IsNull(argValue.get())) { |
| 609 continue; | 708 continue; |
| 610 } else if (FXJSE_Value_IsArray(argValue.get())) { | 709 } else if (FXJSE_Value_IsArray(argValue.get())) { |
| 611 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 710 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 612 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); | 711 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); |
| 613 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); | 712 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); |
| 614 | 713 |
| 615 if (iLength > 2) { | 714 if (iLength > 2) { |
| 616 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 715 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 } | 787 } |
| 689 } | 788 } |
| 690 } | 789 } |
| 691 | 790 |
| 692 if (uCount) { | 791 if (uCount) { |
| 693 FXJSE_Value_SetDouble(args.GetReturnValue(), dMaxValue); | 792 FXJSE_Value_SetDouble(args.GetReturnValue(), dMaxValue); |
| 694 } else { | 793 } else { |
| 695 FXJSE_Value_SetNull(args.GetReturnValue()); | 794 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 696 } | 795 } |
| 697 } | 796 } |
| 797 |
| 798 // static |
| 698 void CXFA_FM2JSContext::Min(CFXJSE_Value* pThis, | 799 void CXFA_FM2JSContext::Min(CFXJSE_Value* pThis, |
| 699 const CFX_ByteStringC& szFuncName, | 800 const CFX_ByteStringC& szFuncName, |
| 700 CFXJSE_Arguments& args) { | 801 CFXJSE_Arguments& args) { |
| 701 CXFA_FM2JSContext* pContext = | 802 CXFA_FM2JSContext* pContext = |
| 702 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 803 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 703 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 804 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 704 int32_t argc = args.GetLength(); | |
| 705 uint32_t uCount = 0; | 805 uint32_t uCount = 0; |
| 706 FX_DOUBLE dMinValue = 0.0; | 806 FX_DOUBLE dMinValue = 0.0; |
| 707 for (int32_t i = 0; i < argc; i++) { | 807 for (int32_t i = 0; i < args.GetLength(); i++) { |
| 708 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); | 808 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); |
| 709 if (FXJSE_Value_IsNull(argValue.get())) { | 809 if (FXJSE_Value_IsNull(argValue.get())) { |
| 710 continue; | 810 continue; |
| 711 } else if (FXJSE_Value_IsArray(argValue.get())) { | 811 } else if (FXJSE_Value_IsArray(argValue.get())) { |
| 712 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 812 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 713 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); | 813 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); |
| 714 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); | 814 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); |
| 715 if (iLength > 2) { | 815 if (iLength > 2) { |
| 716 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 816 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 717 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 817 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 } | 888 } |
| 789 } | 889 } |
| 790 } | 890 } |
| 791 | 891 |
| 792 if (uCount) { | 892 if (uCount) { |
| 793 FXJSE_Value_SetDouble(args.GetReturnValue(), dMinValue); | 893 FXJSE_Value_SetDouble(args.GetReturnValue(), dMinValue); |
| 794 } else { | 894 } else { |
| 795 FXJSE_Value_SetNull(args.GetReturnValue()); | 895 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 796 } | 896 } |
| 797 } | 897 } |
| 898 |
| 899 // static |
| 798 void CXFA_FM2JSContext::Mod(CFXJSE_Value* pThis, | 900 void CXFA_FM2JSContext::Mod(CFXJSE_Value* pThis, |
| 799 const CFX_ByteStringC& szFuncName, | 901 const CFX_ByteStringC& szFuncName, |
| 800 CFXJSE_Arguments& args) { | 902 CFXJSE_Arguments& args) { |
| 801 CXFA_FM2JSContext* pContext = | 903 CXFA_FM2JSContext* pContext = |
| 802 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 904 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 803 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 905 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 804 if (args.GetLength() == 2) { | 906 if (args.GetLength() == 2) { |
| 805 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 907 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 806 std::unique_ptr<CFXJSE_Value> argTwo = args.GetValue(1); | 908 std::unique_ptr<CFXJSE_Value> argTwo = args.GetValue(1); |
| 807 if (FXJSE_Value_IsNull(argOne.get()) || FXJSE_Value_IsNull(argTwo.get())) { | 909 if (FXJSE_Value_IsNull(argOne.get()) || FXJSE_Value_IsNull(argTwo.get())) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 dDividend - dDividor * (int32_t)(dDividend / dDividor)); | 975 dDividend - dDividor * (int32_t)(dDividend / dDividor)); |
| 874 } else { | 976 } else { |
| 875 pContext->ThrowScriptErrorMessage(XFA_IDS_DIVIDE_ZERO); | 977 pContext->ThrowScriptErrorMessage(XFA_IDS_DIVIDE_ZERO); |
| 876 } | 978 } |
| 877 } | 979 } |
| 878 } else { | 980 } else { |
| 879 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 981 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 880 L"Mod"); | 982 L"Mod"); |
| 881 } | 983 } |
| 882 } | 984 } |
| 985 |
| 986 // static |
| 883 void CXFA_FM2JSContext::Round(CFXJSE_Value* pThis, | 987 void CXFA_FM2JSContext::Round(CFXJSE_Value* pThis, |
| 884 const CFX_ByteStringC& szFuncName, | 988 const CFX_ByteStringC& szFuncName, |
| 885 CFXJSE_Arguments& args) { | 989 CFXJSE_Arguments& args) { |
| 886 CXFA_FM2JSContext* pContext = | 990 CXFA_FM2JSContext* pContext = |
| 887 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 991 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 888 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 992 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 889 int32_t argc = args.GetLength(); | 993 int32_t argc = args.GetLength(); |
| 890 uint8_t uPrecision = 0; | 994 uint8_t uPrecision = 0; |
| 891 if (argc == 1) { | 995 if (argc == 1) { |
| 892 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 996 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 CFX_Decimal decimalValue((FX_FLOAT)dValue, uPrecision); | 1081 CFX_Decimal decimalValue((FX_FLOAT)dValue, uPrecision); |
| 978 CFX_WideString wsValue = decimalValue; | 1082 CFX_WideString wsValue = decimalValue; |
| 979 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 1083 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 980 wsValue.UTF8Encode().AsStringC()); | 1084 wsValue.UTF8Encode().AsStringC()); |
| 981 } | 1085 } |
| 982 } else { | 1086 } else { |
| 983 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1087 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 984 L"Round"); | 1088 L"Round"); |
| 985 } | 1089 } |
| 986 } | 1090 } |
| 1091 |
| 1092 // static |
| 987 void CXFA_FM2JSContext::Sum(CFXJSE_Value* pThis, | 1093 void CXFA_FM2JSContext::Sum(CFXJSE_Value* pThis, |
| 988 const CFX_ByteStringC& szFuncName, | 1094 const CFX_ByteStringC& szFuncName, |
| 989 CFXJSE_Arguments& args) { | 1095 CFXJSE_Arguments& args) { |
| 990 CXFA_FM2JSContext* pContext = | 1096 CXFA_FM2JSContext* pContext = |
| 991 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 1097 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 992 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 1098 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 993 int32_t argc = args.GetLength(); | 1099 int32_t argc = args.GetLength(); |
| 994 uint32_t uCount = 0; | 1100 uint32_t uCount = 0; |
| 995 FX_DOUBLE dSum = 0.0; | 1101 FX_DOUBLE dSum = 0.0; |
| 996 if (argc) { | 1102 if (argc) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1053 uCount++; | 1159 uCount++; |
| 1054 } | 1160 } |
| 1055 } | 1161 } |
| 1056 } | 1162 } |
| 1057 if (uCount < 1) { | 1163 if (uCount < 1) { |
| 1058 FXJSE_Value_SetNull(args.GetReturnValue()); | 1164 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1059 } else { | 1165 } else { |
| 1060 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum); | 1166 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum); |
| 1061 } | 1167 } |
| 1062 } | 1168 } |
| 1169 |
| 1170 // static |
| 1063 void CXFA_FM2JSContext::Date(CFXJSE_Value* pThis, | 1171 void CXFA_FM2JSContext::Date(CFXJSE_Value* pThis, |
| 1064 const CFX_ByteStringC& szFuncName, | 1172 const CFX_ByteStringC& szFuncName, |
| 1065 CFXJSE_Arguments& args) { | 1173 CFXJSE_Arguments& args) { |
| 1066 if (args.GetLength() == 0) { | 1174 if (args.GetLength() == 0) { |
| 1067 struct tm* pTmStruct = 0; | 1175 struct tm* pTmStruct = 0; |
| 1068 time_t currentTime; | 1176 time_t currentTime; |
| 1069 time(¤tTime); | 1177 time(¤tTime); |
| 1070 pTmStruct = gmtime(¤tTime); | 1178 pTmStruct = gmtime(¤tTime); |
| 1071 CFX_ByteString bufferYear; | 1179 CFX_ByteString bufferYear; |
| 1072 CFX_ByteString bufferMon; | 1180 CFX_ByteString bufferMon; |
| 1073 CFX_ByteString bufferDay; | 1181 CFX_ByteString bufferDay; |
| 1074 bufferYear.Format("%d", pTmStruct->tm_year + 1900); | 1182 bufferYear.Format("%d", pTmStruct->tm_year + 1900); |
| 1075 bufferMon.Format("%02d", pTmStruct->tm_mon + 1); | 1183 bufferMon.Format("%02d", pTmStruct->tm_mon + 1); |
| 1076 bufferDay.Format("%02d", pTmStruct->tm_mday); | 1184 bufferDay.Format("%02d", pTmStruct->tm_mday); |
| 1077 CFX_ByteString bufferCurrent = bufferYear + bufferMon + bufferDay; | 1185 CFX_ByteString bufferCurrent = bufferYear + bufferMon + bufferDay; |
| 1078 int32_t dDays = DateString2Num(bufferCurrent.AsStringC()); | 1186 int32_t dDays = DateString2Num(bufferCurrent.AsStringC()); |
| 1079 FXJSE_Value_SetInteger(args.GetReturnValue(), dDays); | 1187 FXJSE_Value_SetInteger(args.GetReturnValue(), dDays); |
| 1080 } else { | 1188 } else { |
| 1081 CXFA_FM2JSContext* pContext = | 1189 CXFA_FM2JSContext* pContext = |
| 1082 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 1190 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1083 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1191 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1084 L"Date"); | 1192 L"Date"); |
| 1085 } | 1193 } |
| 1086 } | 1194 } |
| 1195 |
| 1196 // static |
| 1087 void CXFA_FM2JSContext::Date2Num(CFXJSE_Value* pThis, | 1197 void CXFA_FM2JSContext::Date2Num(CFXJSE_Value* pThis, |
| 1088 const CFX_ByteStringC& szFuncName, | 1198 const CFX_ByteStringC& szFuncName, |
| 1089 CFXJSE_Arguments& args) { | 1199 CFXJSE_Arguments& args) { |
| 1090 int32_t argc = args.GetLength(); | 1200 int32_t argc = args.GetLength(); |
| 1091 if ((argc > 0) && (argc < 4)) { | 1201 if ((argc > 0) && (argc < 4)) { |
| 1092 FX_BOOL bFlags = FALSE; | 1202 FX_BOOL bFlags = FALSE; |
| 1093 CFX_ByteString dateString; | 1203 CFX_ByteString dateString; |
| 1094 CFX_ByteString formatString; | 1204 CFX_ByteString formatString; |
| 1095 CFX_ByteString localString; | 1205 CFX_ByteString localString; |
| 1096 std::unique_ptr<CFXJSE_Value> dateValue = GetSimpleValue(pThis, args, 0); | 1206 std::unique_ptr<CFXJSE_Value> dateValue = GetSimpleValue(pThis, args, 0); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 } else { | 1240 } else { |
| 1131 FXJSE_Value_SetNull(args.GetReturnValue()); | 1241 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1132 } | 1242 } |
| 1133 } else { | 1243 } else { |
| 1134 CXFA_FM2JSContext* pContext = | 1244 CXFA_FM2JSContext* pContext = |
| 1135 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 1245 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1136 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1246 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1137 L"Date2Num"); | 1247 L"Date2Num"); |
| 1138 } | 1248 } |
| 1139 } | 1249 } |
| 1250 |
| 1251 // static |
| 1140 void CXFA_FM2JSContext::DateFmt(CFXJSE_Value* pThis, | 1252 void CXFA_FM2JSContext::DateFmt(CFXJSE_Value* pThis, |
| 1141 const CFX_ByteStringC& szFuncName, | 1253 const CFX_ByteStringC& szFuncName, |
| 1142 CFXJSE_Arguments& args) { | 1254 CFXJSE_Arguments& args) { |
| 1143 int32_t argc = args.GetLength(); | 1255 int32_t argc = args.GetLength(); |
| 1144 if (argc < 3) { | 1256 if (argc < 3) { |
| 1145 FX_BOOL bFlags = FALSE; | 1257 FX_BOOL bFlags = FALSE; |
| 1146 int32_t iStyle = 0; | 1258 int32_t iStyle = 0; |
| 1147 CFX_ByteString szLocal; | 1259 CFX_ByteString szLocal; |
| 1148 if (argc > 0) { | 1260 if (argc > 0) { |
| 1149 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0); | 1261 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1173 } else { | 1285 } else { |
| 1174 FXJSE_Value_SetNull(args.GetReturnValue()); | 1286 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1175 } | 1287 } |
| 1176 } else { | 1288 } else { |
| 1177 CXFA_FM2JSContext* pContext = | 1289 CXFA_FM2JSContext* pContext = |
| 1178 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 1290 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1179 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1291 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1180 L"Date2Num"); | 1292 L"Date2Num"); |
| 1181 } | 1293 } |
| 1182 } | 1294 } |
| 1295 |
| 1296 // static |
| 1183 void CXFA_FM2JSContext::IsoDate2Num(CFXJSE_Value* pThis, | 1297 void CXFA_FM2JSContext::IsoDate2Num(CFXJSE_Value* pThis, |
| 1184 const CFX_ByteStringC& szFuncName, | 1298 const CFX_ByteStringC& szFuncName, |
| 1185 CFXJSE_Arguments& args) { | 1299 CFXJSE_Arguments& args) { |
| 1186 if (args.GetLength() == 1) { | 1300 if (args.GetLength() == 1) { |
| 1187 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 1301 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 1188 if (FXJSE_Value_IsNull(argOne.get())) { | 1302 if (FXJSE_Value_IsNull(argOne.get())) { |
| 1189 FXJSE_Value_SetNull(args.GetReturnValue()); | 1303 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1190 } else { | 1304 } else { |
| 1191 CFX_ByteString szArgString; | 1305 CFX_ByteString szArgString; |
| 1192 ValueToUTF8String(argOne.get(), szArgString); | 1306 ValueToUTF8String(argOne.get(), szArgString); |
| 1193 int32_t dDays = DateString2Num(szArgString.AsStringC()); | 1307 int32_t dDays = DateString2Num(szArgString.AsStringC()); |
| 1194 FXJSE_Value_SetInteger(args.GetReturnValue(), (int32_t)dDays); | 1308 FXJSE_Value_SetInteger(args.GetReturnValue(), (int32_t)dDays); |
| 1195 } | 1309 } |
| 1196 } else { | 1310 } else { |
| 1197 CXFA_FM2JSContext* pContext = | 1311 CXFA_FM2JSContext* pContext = |
| 1198 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 1312 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1199 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1313 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1200 L"IsoDate2Num"); | 1314 L"IsoDate2Num"); |
| 1201 } | 1315 } |
| 1202 } | 1316 } |
| 1317 |
| 1318 // static |
| 1203 void CXFA_FM2JSContext::IsoTime2Num(CFXJSE_Value* pThis, | 1319 void CXFA_FM2JSContext::IsoTime2Num(CFXJSE_Value* pThis, |
| 1204 const CFX_ByteStringC& szFuncName, | 1320 const CFX_ByteStringC& szFuncName, |
| 1205 CFXJSE_Arguments& args) { | 1321 CFXJSE_Arguments& args) { |
| 1206 CXFA_FM2JSContext* pContext = | 1322 CXFA_FM2JSContext* pContext = |
| 1207 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 1323 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1208 if (args.GetLength() == 1) { | 1324 if (args.GetLength() == 1) { |
| 1209 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 1325 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 1210 if (ValueIsNull(pThis, argOne.get())) { | 1326 if (ValueIsNull(pThis, argOne.get())) { |
| 1211 FXJSE_Value_SetNull(args.GetReturnValue()); | 1327 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1212 } else { | 1328 } else { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 FXJSE_Value_SetInteger(args.GetReturnValue(), iResult); | 1364 FXJSE_Value_SetInteger(args.GetReturnValue(), iResult); |
| 1249 } else { | 1365 } else { |
| 1250 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 1366 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
| 1251 } | 1367 } |
| 1252 } | 1368 } |
| 1253 } else { | 1369 } else { |
| 1254 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1370 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1255 L"IsoTime2Num"); | 1371 L"IsoTime2Num"); |
| 1256 } | 1372 } |
| 1257 } | 1373 } |
| 1374 |
| 1375 // static |
| 1258 void CXFA_FM2JSContext::LocalDateFmt(CFXJSE_Value* pThis, | 1376 void CXFA_FM2JSContext::LocalDateFmt(CFXJSE_Value* pThis, |
| 1259 const CFX_ByteStringC& szFuncName, | 1377 const CFX_ByteStringC& szFuncName, |
| 1260 CFXJSE_Arguments& args) { | 1378 CFXJSE_Arguments& args) { |
| 1261 int32_t argc = args.GetLength(); | 1379 int32_t argc = args.GetLength(); |
| 1262 if (argc < 3) { | 1380 if (argc < 3) { |
| 1263 FX_BOOL bFlags = FALSE; | 1381 FX_BOOL bFlags = FALSE; |
| 1264 int32_t iStyle = 0; | 1382 int32_t iStyle = 0; |
| 1265 CFX_ByteString szLocal; | 1383 CFX_ByteString szLocal; |
| 1266 if (argc > 0) { | 1384 if (argc > 0) { |
| 1267 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0); | 1385 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1291 } else { | 1409 } else { |
| 1292 FXJSE_Value_SetNull(args.GetReturnValue()); | 1410 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1293 } | 1411 } |
| 1294 } else { | 1412 } else { |
| 1295 CXFA_FM2JSContext* pContext = | 1413 CXFA_FM2JSContext* pContext = |
| 1296 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 1414 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1297 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1415 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1298 L"LocalDateFmt"); | 1416 L"LocalDateFmt"); |
| 1299 } | 1417 } |
| 1300 } | 1418 } |
| 1419 |
| 1420 // static |
| 1301 void CXFA_FM2JSContext::LocalTimeFmt(CFXJSE_Value* pThis, | 1421 void CXFA_FM2JSContext::LocalTimeFmt(CFXJSE_Value* pThis, |
| 1302 const CFX_ByteStringC& szFuncName, | 1422 const CFX_ByteStringC& szFuncName, |
| 1303 CFXJSE_Arguments& args) { | 1423 CFXJSE_Arguments& args) { |
| 1304 int32_t argc = args.GetLength(); | 1424 int32_t argc = args.GetLength(); |
| 1305 if (argc < 3) { | 1425 if (argc < 3) { |
| 1306 FX_BOOL bFlags = FALSE; | 1426 FX_BOOL bFlags = FALSE; |
| 1307 int32_t iStyle = 0; | 1427 int32_t iStyle = 0; |
| 1308 CFX_ByteString szLocal; | 1428 CFX_ByteString szLocal; |
| 1309 if (argc > 0) { | 1429 if (argc > 0) { |
| 1310 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0); | 1430 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1334 } else { | 1454 } else { |
| 1335 FXJSE_Value_SetNull(args.GetReturnValue()); | 1455 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1336 } | 1456 } |
| 1337 } else { | 1457 } else { |
| 1338 CXFA_FM2JSContext* pContext = | 1458 CXFA_FM2JSContext* pContext = |
| 1339 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 1459 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1340 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1460 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1341 L"LocalTimeFmt"); | 1461 L"LocalTimeFmt"); |
| 1342 } | 1462 } |
| 1343 } | 1463 } |
| 1464 |
| 1465 // static |
| 1344 void CXFA_FM2JSContext::Num2Date(CFXJSE_Value* pThis, | 1466 void CXFA_FM2JSContext::Num2Date(CFXJSE_Value* pThis, |
| 1345 const CFX_ByteStringC& szFuncName, | 1467 const CFX_ByteStringC& szFuncName, |
| 1346 CFXJSE_Arguments& args) { | 1468 CFXJSE_Arguments& args) { |
| 1347 int32_t argc = args.GetLength(); | 1469 int32_t argc = args.GetLength(); |
| 1348 if ((argc > 0) && (argc < 4)) { | 1470 if ((argc > 0) && (argc < 4)) { |
| 1349 FX_BOOL bFlags = FALSE; | 1471 FX_BOOL bFlags = FALSE; |
| 1350 int32_t dDate = 0; | 1472 int32_t dDate = 0; |
| 1351 CFX_ByteString formatString; | 1473 CFX_ByteString formatString; |
| 1352 CFX_ByteString localString; | 1474 CFX_ByteString localString; |
| 1353 std::unique_ptr<CFXJSE_Value> dateValue = GetSimpleValue(pThis, args, 0); | 1475 std::unique_ptr<CFXJSE_Value> dateValue = GetSimpleValue(pThis, args, 0); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1481 } else { | 1603 } else { |
| 1482 FXJSE_Value_SetNull(args.GetReturnValue()); | 1604 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1483 } | 1605 } |
| 1484 } else { | 1606 } else { |
| 1485 CXFA_FM2JSContext* pContext = | 1607 CXFA_FM2JSContext* pContext = |
| 1486 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 1608 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1487 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1609 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1488 L"Num2Date"); | 1610 L"Num2Date"); |
| 1489 } | 1611 } |
| 1490 } | 1612 } |
| 1613 |
| 1614 // static |
| 1491 void CXFA_FM2JSContext::Num2GMTime(CFXJSE_Value* pThis, | 1615 void CXFA_FM2JSContext::Num2GMTime(CFXJSE_Value* pThis, |
| 1492 const CFX_ByteStringC& szFuncName, | 1616 const CFX_ByteStringC& szFuncName, |
| 1493 CFXJSE_Arguments& args) { | 1617 CFXJSE_Arguments& args) { |
| 1494 int32_t argc = args.GetLength(); | 1618 int32_t argc = args.GetLength(); |
| 1495 if ((argc > 0) && (argc < 4)) { | 1619 if ((argc > 0) && (argc < 4)) { |
| 1496 FX_BOOL bFlags = FALSE; | 1620 FX_BOOL bFlags = FALSE; |
| 1497 int32_t iTime = 0; | 1621 int32_t iTime = 0; |
| 1498 CFX_ByteString formatString; | 1622 CFX_ByteString formatString; |
| 1499 CFX_ByteString localString; | 1623 CFX_ByteString localString; |
| 1500 std::unique_ptr<CFXJSE_Value> timeValue = GetSimpleValue(pThis, args, 0); | 1624 std::unique_ptr<CFXJSE_Value> timeValue = GetSimpleValue(pThis, args, 0); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1535 } else { | 1659 } else { |
| 1536 FXJSE_Value_SetNull(args.GetReturnValue()); | 1660 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1537 } | 1661 } |
| 1538 } else { | 1662 } else { |
| 1539 CXFA_FM2JSContext* pContext = | 1663 CXFA_FM2JSContext* pContext = |
| 1540 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 1664 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1541 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1665 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1542 L"Num2GMTime"); | 1666 L"Num2GMTime"); |
| 1543 } | 1667 } |
| 1544 } | 1668 } |
| 1669 |
| 1670 // static |
| 1545 void CXFA_FM2JSContext::Num2Time(CFXJSE_Value* pThis, | 1671 void CXFA_FM2JSContext::Num2Time(CFXJSE_Value* pThis, |
| 1546 const CFX_ByteStringC& szFuncName, | 1672 const CFX_ByteStringC& szFuncName, |
| 1547 CFXJSE_Arguments& args) { | 1673 CFXJSE_Arguments& args) { |
| 1548 int32_t argc = args.GetLength(); | 1674 int32_t argc = args.GetLength(); |
| 1549 if ((argc > 0) && (argc < 4)) { | 1675 if ((argc > 0) && (argc < 4)) { |
| 1550 FX_BOOL bFlags = FALSE; | 1676 FX_BOOL bFlags = FALSE; |
| 1551 FX_FLOAT fTime = 0.0f; | 1677 FX_FLOAT fTime = 0.0f; |
| 1552 CFX_ByteString formatString; | 1678 CFX_ByteString formatString; |
| 1553 CFX_ByteString localString; | 1679 CFX_ByteString localString; |
| 1554 std::unique_ptr<CFXJSE_Value> timeValue = GetSimpleValue(pThis, args, 0); | 1680 std::unique_ptr<CFXJSE_Value> timeValue = GetSimpleValue(pThis, args, 0); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1589 } else { | 1715 } else { |
| 1590 FXJSE_Value_SetNull(args.GetReturnValue()); | 1716 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1591 } | 1717 } |
| 1592 } else { | 1718 } else { |
| 1593 CXFA_FM2JSContext* pContext = | 1719 CXFA_FM2JSContext* pContext = |
| 1594 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 1720 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1595 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1721 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1596 L"Num2Time"); | 1722 L"Num2Time"); |
| 1597 } | 1723 } |
| 1598 } | 1724 } |
| 1725 |
| 1726 // static |
| 1599 void CXFA_FM2JSContext::Time(CFXJSE_Value* pThis, | 1727 void CXFA_FM2JSContext::Time(CFXJSE_Value* pThis, |
| 1600 const CFX_ByteStringC& szFuncName, | 1728 const CFX_ByteStringC& szFuncName, |
| 1601 CFXJSE_Arguments& args) { | 1729 CFXJSE_Arguments& args) { |
| 1602 if (args.GetLength() == 0) { | 1730 if (args.GetLength() == 0) { |
| 1603 time_t now; | 1731 time_t now; |
| 1604 time(&now); | 1732 time(&now); |
| 1605 struct tm* pGmt = gmtime(&now); | 1733 struct tm* pGmt = gmtime(&now); |
| 1606 int32_t iGMHour = pGmt->tm_hour; | 1734 int32_t iGMHour = pGmt->tm_hour; |
| 1607 int32_t iGMMin = pGmt->tm_min; | 1735 int32_t iGMMin = pGmt->tm_min; |
| 1608 int32_t iGMSec = pGmt->tm_sec; | 1736 int32_t iGMSec = pGmt->tm_sec; |
| 1609 FXJSE_Value_SetInteger(args.GetReturnValue(), | 1737 FXJSE_Value_SetInteger(args.GetReturnValue(), |
| 1610 ((iGMHour * 3600 + iGMMin * 60 + iGMSec) * 1000)); | 1738 ((iGMHour * 3600 + iGMMin * 60 + iGMSec) * 1000)); |
| 1611 } else { | 1739 } else { |
| 1612 CXFA_FM2JSContext* pContext = | 1740 CXFA_FM2JSContext* pContext = |
| 1613 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 1741 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1614 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1742 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1615 L"Time"); | 1743 L"Time"); |
| 1616 } | 1744 } |
| 1617 } | 1745 } |
| 1746 |
| 1747 // static |
| 1618 void CXFA_FM2JSContext::Time2Num(CFXJSE_Value* pThis, | 1748 void CXFA_FM2JSContext::Time2Num(CFXJSE_Value* pThis, |
| 1619 const CFX_ByteStringC& szFuncName, | 1749 const CFX_ByteStringC& szFuncName, |
| 1620 CFXJSE_Arguments& args) { | 1750 CFXJSE_Arguments& args) { |
| 1621 int32_t argc = args.GetLength(); | 1751 int32_t argc = args.GetLength(); |
| 1622 if ((argc > 0) && (argc < 4)) { | 1752 if ((argc > 0) && (argc < 4)) { |
| 1623 FX_BOOL bFlags = FALSE; | 1753 FX_BOOL bFlags = FALSE; |
| 1624 CFX_ByteString timeString; | 1754 CFX_ByteString timeString; |
| 1625 CFX_ByteString formatString; | 1755 CFX_ByteString formatString; |
| 1626 CFX_ByteString localString; | 1756 CFX_ByteString localString; |
| 1627 std::unique_ptr<CFXJSE_Value> timeValue = GetSimpleValue(pThis, args, 0); | 1757 std::unique_ptr<CFXJSE_Value> timeValue = GetSimpleValue(pThis, args, 0); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1645 bFlags = TRUE; | 1775 bFlags = TRUE; |
| 1646 } else { | 1776 } else { |
| 1647 ValueToUTF8String(localValue.get(), localString); | 1777 ValueToUTF8String(localValue.get(), localString); |
| 1648 } | 1778 } |
| 1649 } | 1779 } |
| 1650 if (!bFlags) { | 1780 if (!bFlags) { |
| 1651 CXFA_FM2JSContext* pContext = | 1781 CXFA_FM2JSContext* pContext = |
| 1652 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 1782 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1653 CXFA_Document* pDoc = pContext->GetDocument(); | 1783 CXFA_Document* pDoc = pContext->GetDocument(); |
| 1654 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 1784 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 1655 IFX_Locale* pLocale = NULL; | 1785 IFX_Locale* pLocale = nullptr; |
| 1656 if (localString.IsEmpty()) { | 1786 if (localString.IsEmpty()) { |
| 1657 CXFA_Node* pThisNode = | 1787 CXFA_Node* pThisNode = |
| 1658 ToNode(pDoc->GetScriptContext()->GetThisObject()); | 1788 ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 1659 ASSERT(pThisNode); | 1789 ASSERT(pThisNode); |
| 1660 CXFA_WidgetData widgetData(pThisNode); | 1790 CXFA_WidgetData widgetData(pThisNode); |
| 1661 pLocale = widgetData.GetLocal(); | 1791 pLocale = widgetData.GetLocal(); |
| 1662 } else { | 1792 } else { |
| 1663 pLocale = pMgr->GetLocaleByName( | 1793 pLocale = pMgr->GetLocaleByName( |
| 1664 CFX_WideString::FromUTF8(localString.AsStringC())); | 1794 CFX_WideString::FromUTF8(localString.AsStringC())); |
| 1665 } | 1795 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1704 } else { | 1834 } else { |
| 1705 FXJSE_Value_SetNull(args.GetReturnValue()); | 1835 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1706 } | 1836 } |
| 1707 } else { | 1837 } else { |
| 1708 CXFA_FM2JSContext* pContext = | 1838 CXFA_FM2JSContext* pContext = |
| 1709 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 1839 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1710 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1840 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1711 L"Time2Num"); | 1841 L"Time2Num"); |
| 1712 } | 1842 } |
| 1713 } | 1843 } |
| 1844 |
| 1845 // static |
| 1714 void CXFA_FM2JSContext::TimeFmt(CFXJSE_Value* pThis, | 1846 void CXFA_FM2JSContext::TimeFmt(CFXJSE_Value* pThis, |
| 1715 const CFX_ByteStringC& szFuncName, | 1847 const CFX_ByteStringC& szFuncName, |
| 1716 CFXJSE_Arguments& args) { | 1848 CFXJSE_Arguments& args) { |
| 1717 int32_t argc = args.GetLength(); | 1849 int32_t argc = args.GetLength(); |
| 1718 if (argc < 3) { | 1850 if (argc < 3) { |
| 1719 FX_BOOL bFlags = FALSE; | 1851 FX_BOOL bFlags = FALSE; |
| 1720 int32_t iStyle = 0; | 1852 int32_t iStyle = 0; |
| 1721 CFX_ByteString szLocal; | 1853 CFX_ByteString szLocal; |
| 1722 if (argc > 0) { | 1854 if (argc > 0) { |
| 1723 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0); | 1855 std::unique_ptr<CFXJSE_Value> argStyle = GetSimpleValue(pThis, args, 0); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1747 } else { | 1879 } else { |
| 1748 FXJSE_Value_SetNull(args.GetReturnValue()); | 1880 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 1749 } | 1881 } |
| 1750 } else { | 1882 } else { |
| 1751 CXFA_FM2JSContext* pContext = | 1883 CXFA_FM2JSContext* pContext = |
| 1752 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 1884 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 1753 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 1885 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 1754 L"TimeFmt"); | 1886 L"TimeFmt"); |
| 1755 } | 1887 } |
| 1756 } | 1888 } |
| 1889 |
| 1890 // static |
| 1757 FX_BOOL CXFA_FM2JSContext::IsIsoDateFormat(const FX_CHAR* pData, | 1891 FX_BOOL CXFA_FM2JSContext::IsIsoDateFormat(const FX_CHAR* pData, |
| 1758 int32_t iLength, | 1892 int32_t iLength, |
| 1759 int32_t& iStyle, | 1893 int32_t& iStyle, |
| 1760 int32_t& iYear, | 1894 int32_t& iYear, |
| 1761 int32_t& iMonth, | 1895 int32_t& iMonth, |
| 1762 int32_t& iDay) { | 1896 int32_t& iDay) { |
| 1763 iYear = 0; | 1897 iYear = 0; |
| 1764 iMonth = 1; | 1898 iMonth = 1; |
| 1765 iDay = 1; | 1899 iDay = 1; |
| 1766 FX_BOOL iRet = FALSE; | 1900 FX_BOOL iRet = FALSE; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1866 } else { | 2000 } else { |
| 1867 if (iDay > (iMonth % 2 == 0 ? 31 : 30)) { | 2001 if (iDay > (iMonth % 2 == 0 ? 31 : 30)) { |
| 1868 return iRet; | 2002 return iRet; |
| 1869 } | 2003 } |
| 1870 } | 2004 } |
| 1871 } | 2005 } |
| 1872 } | 2006 } |
| 1873 iRet = TRUE; | 2007 iRet = TRUE; |
| 1874 return iRet; | 2008 return iRet; |
| 1875 } | 2009 } |
| 2010 |
| 2011 // static |
| 1876 FX_BOOL CXFA_FM2JSContext::IsIsoTimeFormat(const FX_CHAR* pData, | 2012 FX_BOOL CXFA_FM2JSContext::IsIsoTimeFormat(const FX_CHAR* pData, |
| 1877 int32_t iLength, | 2013 int32_t iLength, |
| 1878 int32_t& iHour, | 2014 int32_t& iHour, |
| 1879 int32_t& iMinute, | 2015 int32_t& iMinute, |
| 1880 int32_t& iSecond, | 2016 int32_t& iSecond, |
| 1881 int32_t& iMilliSecond, | 2017 int32_t& iMilliSecond, |
| 1882 int32_t& iZoneHour, | 2018 int32_t& iZoneHour, |
| 1883 int32_t& iZoneMinute) { | 2019 int32_t& iZoneMinute) { |
| 1884 iHour = 0; | 2020 iHour = 0; |
| 1885 iMinute = 0; | 2021 iMinute = 0; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2014 iIndex += 2; | 2150 iIndex += 2; |
| 2015 } | 2151 } |
| 2016 } | 2152 } |
| 2017 if (iIndex < iLength) { | 2153 if (iIndex < iLength) { |
| 2018 return iRet; | 2154 return iRet; |
| 2019 } | 2155 } |
| 2020 iZoneHour *= iSign; | 2156 iZoneHour *= iSign; |
| 2021 iRet = TRUE; | 2157 iRet = TRUE; |
| 2022 return iRet; | 2158 return iRet; |
| 2023 } | 2159 } |
| 2160 |
| 2161 // static |
| 2024 FX_BOOL CXFA_FM2JSContext::IsIsoDateTimeFormat(const FX_CHAR* pData, | 2162 FX_BOOL CXFA_FM2JSContext::IsIsoDateTimeFormat(const FX_CHAR* pData, |
| 2025 int32_t iLength, | 2163 int32_t iLength, |
| 2026 int32_t& iYear, | 2164 int32_t& iYear, |
| 2027 int32_t& iMonth, | 2165 int32_t& iMonth, |
| 2028 int32_t& iDay, | 2166 int32_t& iDay, |
| 2029 int32_t& iHour, | 2167 int32_t& iHour, |
| 2030 int32_t& iMinute, | 2168 int32_t& iMinute, |
| 2031 int32_t& iSecond, | 2169 int32_t& iSecond, |
| 2032 int32_t& iMillionSecond, | 2170 int32_t& iMillionSecond, |
| 2033 int32_t& iZoneHour, | 2171 int32_t& iZoneHour, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2066 return iRet; | 2204 return iRet; |
| 2067 } | 2205 } |
| 2068 iRet = IsIsoTimeFormat(pData + iIndex, iLength - iIndex, iHour, iMinute, | 2206 iRet = IsIsoTimeFormat(pData + iIndex, iLength - iIndex, iHour, iMinute, |
| 2069 iSecond, iMillionSecond, iZoneHour, iZoneMinute); | 2207 iSecond, iMillionSecond, iZoneHour, iZoneMinute); |
| 2070 if (!iRet) { | 2208 if (!iRet) { |
| 2071 return iRet; | 2209 return iRet; |
| 2072 } | 2210 } |
| 2073 iRet = TRUE; | 2211 iRet = TRUE; |
| 2074 return iRet; | 2212 return iRet; |
| 2075 } | 2213 } |
| 2214 |
| 2215 // static |
| 2076 FX_BOOL CXFA_FM2JSContext::Local2IsoDate(CFXJSE_Value* pThis, | 2216 FX_BOOL CXFA_FM2JSContext::Local2IsoDate(CFXJSE_Value* pThis, |
| 2077 const CFX_ByteStringC& szDate, | 2217 const CFX_ByteStringC& szDate, |
| 2078 const CFX_ByteStringC& szFormat, | 2218 const CFX_ByteStringC& szFormat, |
| 2079 const CFX_ByteStringC& szLocale, | 2219 const CFX_ByteStringC& szLocale, |
| 2080 CFX_ByteString& strIsoDate) { | 2220 CFX_ByteString& strIsoDate) { |
| 2081 CXFA_FM2JSContext* pContext = | 2221 CXFA_FM2JSContext* pContext = |
| 2082 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 2222 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2083 CXFA_Document* pDoc = pContext->GetDocument(); | 2223 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2084 if (!pDoc) { | 2224 if (!pDoc) { |
| 2085 return FALSE; | 2225 return FALSE; |
| 2086 } | 2226 } |
| 2087 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2227 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2088 IFX_Locale* pLocale = NULL; | 2228 IFX_Locale* pLocale = nullptr; |
| 2089 if (szLocale.IsEmpty()) { | 2229 if (szLocale.IsEmpty()) { |
| 2090 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2230 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2091 ASSERT(pThisNode); | 2231 ASSERT(pThisNode); |
| 2092 CXFA_WidgetData widgetData(pThisNode); | 2232 CXFA_WidgetData widgetData(pThisNode); |
| 2093 pLocale = widgetData.GetLocal(); | 2233 pLocale = widgetData.GetLocal(); |
| 2094 } else { | 2234 } else { |
| 2095 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale)); | 2235 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale)); |
| 2096 } | 2236 } |
| 2097 if (!pLocale) { | 2237 if (!pLocale) { |
| 2098 return FALSE; | 2238 return FALSE; |
| 2099 } | 2239 } |
| 2100 CFX_WideString wsFormat; | 2240 CFX_WideString wsFormat; |
| 2101 if (szFormat.IsEmpty()) { | 2241 if (szFormat.IsEmpty()) { |
| 2102 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2242 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
| 2103 } else { | 2243 } else { |
| 2104 wsFormat = CFX_WideString::FromUTF8(szFormat); | 2244 wsFormat = CFX_WideString::FromUTF8(szFormat); |
| 2105 } | 2245 } |
| 2106 CXFA_LocaleValue widgetValue(XFA_VT_DATE, CFX_WideString::FromUTF8(szDate), | 2246 CXFA_LocaleValue widgetValue(XFA_VT_DATE, CFX_WideString::FromUTF8(szDate), |
| 2107 wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr); | 2247 wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr); |
| 2108 CFX_Unitime dt = widgetValue.GetDate(); | 2248 CFX_Unitime dt = widgetValue.GetDate(); |
| 2109 strIsoDate.Format("%4d-%02d-%02d", dt.GetYear(), dt.GetMonth(), dt.GetDay()); | 2249 strIsoDate.Format("%4d-%02d-%02d", dt.GetYear(), dt.GetMonth(), dt.GetDay()); |
| 2110 return TRUE; | 2250 return TRUE; |
| 2111 } | 2251 } |
| 2252 |
| 2253 // static |
| 2112 FX_BOOL CXFA_FM2JSContext::Local2IsoTime(CFXJSE_Value* pThis, | 2254 FX_BOOL CXFA_FM2JSContext::Local2IsoTime(CFXJSE_Value* pThis, |
| 2113 const CFX_ByteStringC& szTime, | 2255 const CFX_ByteStringC& szTime, |
| 2114 const CFX_ByteStringC& szFormat, | 2256 const CFX_ByteStringC& szFormat, |
| 2115 const CFX_ByteStringC& szLocale, | 2257 const CFX_ByteStringC& szLocale, |
| 2116 CFX_ByteString& strIsoTime) { | 2258 CFX_ByteString& strIsoTime) { |
| 2117 CXFA_FM2JSContext* pContext = | 2259 CXFA_FM2JSContext* pContext = |
| 2118 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 2260 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2119 CXFA_Document* pDoc = pContext->GetDocument(); | 2261 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2120 if (!pDoc) { | 2262 if (!pDoc) { |
| 2121 return FALSE; | 2263 return FALSE; |
| 2122 } | 2264 } |
| 2123 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2265 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2124 IFX_Locale* pLocale = NULL; | 2266 IFX_Locale* pLocale = nullptr; |
| 2125 if (szLocale.IsEmpty()) { | 2267 if (szLocale.IsEmpty()) { |
| 2126 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2268 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2127 ASSERT(pThisNode); | 2269 ASSERT(pThisNode); |
| 2128 CXFA_WidgetData widgetData(pThisNode); | 2270 CXFA_WidgetData widgetData(pThisNode); |
| 2129 pLocale = widgetData.GetLocal(); | 2271 pLocale = widgetData.GetLocal(); |
| 2130 } else { | 2272 } else { |
| 2131 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale)); | 2273 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale)); |
| 2132 } | 2274 } |
| 2133 if (!pLocale) { | 2275 if (!pLocale) { |
| 2134 return FALSE; | 2276 return FALSE; |
| 2135 } | 2277 } |
| 2136 CFX_WideString wsFormat; | 2278 CFX_WideString wsFormat; |
| 2137 if (szFormat.IsEmpty()) { | 2279 if (szFormat.IsEmpty()) { |
| 2138 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2280 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
| 2139 } else { | 2281 } else { |
| 2140 wsFormat = CFX_WideString::FromUTF8(szFormat); | 2282 wsFormat = CFX_WideString::FromUTF8(szFormat); |
| 2141 } | 2283 } |
| 2142 wsFormat = FX_WSTRC(L"time{") + wsFormat; | 2284 wsFormat = FX_WSTRC(L"time{") + wsFormat; |
| 2143 wsFormat += FX_WSTRC(L"}"); | 2285 wsFormat += FX_WSTRC(L"}"); |
| 2144 CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime), | 2286 CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime), |
| 2145 wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr); | 2287 wsFormat, pLocale, (CXFA_LocaleMgr*)pMgr); |
| 2146 CFX_Unitime utime = widgetValue.GetTime(); | 2288 CFX_Unitime utime = widgetValue.GetTime(); |
| 2147 strIsoTime.Format("%02d:%02d:%02d.%03d", utime.GetHour(), utime.GetMinute(), | 2289 strIsoTime.Format("%02d:%02d:%02d.%03d", utime.GetHour(), utime.GetMinute(), |
| 2148 utime.GetSecond(), utime.GetMillisecond()); | 2290 utime.GetSecond(), utime.GetMillisecond()); |
| 2149 return TRUE; | 2291 return TRUE; |
| 2150 } | 2292 } |
| 2293 |
| 2294 // static |
| 2151 FX_BOOL CXFA_FM2JSContext::IsoDate2Local(CFXJSE_Value* pThis, | 2295 FX_BOOL CXFA_FM2JSContext::IsoDate2Local(CFXJSE_Value* pThis, |
| 2152 const CFX_ByteStringC& szDate, | 2296 const CFX_ByteStringC& szDate, |
| 2153 const CFX_ByteStringC& szFormat, | 2297 const CFX_ByteStringC& szFormat, |
| 2154 const CFX_ByteStringC& szLocale, | 2298 const CFX_ByteStringC& szLocale, |
| 2155 CFX_ByteString& strLocalDate) { | 2299 CFX_ByteString& strLocalDate) { |
| 2156 CXFA_FM2JSContext* pContext = | 2300 CXFA_FM2JSContext* pContext = |
| 2157 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 2301 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2158 CXFA_Document* pDoc = pContext->GetDocument(); | 2302 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2159 if (!pDoc) { | 2303 if (!pDoc) { |
| 2160 return FALSE; | 2304 return FALSE; |
| 2161 } | 2305 } |
| 2162 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2306 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2163 IFX_Locale* pLocale = NULL; | 2307 IFX_Locale* pLocale = nullptr; |
| 2164 if (szLocale.IsEmpty()) { | 2308 if (szLocale.IsEmpty()) { |
| 2165 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2309 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2166 ASSERT(pThisNode); | 2310 ASSERT(pThisNode); |
| 2167 CXFA_WidgetData widgetData(pThisNode); | 2311 CXFA_WidgetData widgetData(pThisNode); |
| 2168 pLocale = widgetData.GetLocal(); | 2312 pLocale = widgetData.GetLocal(); |
| 2169 } else { | 2313 } else { |
| 2170 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale)); | 2314 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale)); |
| 2171 } | 2315 } |
| 2172 if (!pLocale) { | 2316 if (!pLocale) { |
| 2173 return FALSE; | 2317 return FALSE; |
| 2174 } | 2318 } |
| 2175 CFX_WideString wsFormat; | 2319 CFX_WideString wsFormat; |
| 2176 if (szFormat.IsEmpty()) { | 2320 if (szFormat.IsEmpty()) { |
| 2177 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2321 pLocale->GetDatePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
| 2178 } else { | 2322 } else { |
| 2179 wsFormat = CFX_WideString::FromUTF8(szFormat); | 2323 wsFormat = CFX_WideString::FromUTF8(szFormat); |
| 2180 } | 2324 } |
| 2181 CXFA_LocaleValue widgetValue(XFA_VT_DATE, CFX_WideString::FromUTF8(szDate), | 2325 CXFA_LocaleValue widgetValue(XFA_VT_DATE, CFX_WideString::FromUTF8(szDate), |
| 2182 (CXFA_LocaleMgr*)pMgr); | 2326 (CXFA_LocaleMgr*)pMgr); |
| 2183 CFX_WideString wsRet; | 2327 CFX_WideString wsRet; |
| 2184 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, | 2328 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, |
| 2185 XFA_VALUEPICTURE_Display); | 2329 XFA_VALUEPICTURE_Display); |
| 2186 strLocalDate = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()); | 2330 strLocalDate = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()); |
| 2187 return TRUE; | 2331 return TRUE; |
| 2188 } | 2332 } |
| 2333 |
| 2334 // static |
| 2189 FX_BOOL CXFA_FM2JSContext::IsoTime2Local(CFXJSE_Value* pThis, | 2335 FX_BOOL CXFA_FM2JSContext::IsoTime2Local(CFXJSE_Value* pThis, |
| 2190 const CFX_ByteStringC& szTime, | 2336 const CFX_ByteStringC& szTime, |
| 2191 const CFX_ByteStringC& szFormat, | 2337 const CFX_ByteStringC& szFormat, |
| 2192 const CFX_ByteStringC& szLocale, | 2338 const CFX_ByteStringC& szLocale, |
| 2193 CFX_ByteString& strLocalTime) { | 2339 CFX_ByteString& strLocalTime) { |
| 2194 CXFA_FM2JSContext* pContext = | 2340 CXFA_FM2JSContext* pContext = |
| 2195 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 2341 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2196 CXFA_Document* pDoc = pContext->GetDocument(); | 2342 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2197 if (!pDoc) { | 2343 if (!pDoc) { |
| 2198 return FALSE; | 2344 return FALSE; |
| 2199 } | 2345 } |
| 2200 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2346 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2201 IFX_Locale* pLocale = NULL; | 2347 IFX_Locale* pLocale = nullptr; |
| 2202 if (szLocale.IsEmpty()) { | 2348 if (szLocale.IsEmpty()) { |
| 2203 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2349 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2204 ASSERT(pThisNode); | 2350 ASSERT(pThisNode); |
| 2205 CXFA_WidgetData widgetData(pThisNode); | 2351 CXFA_WidgetData widgetData(pThisNode); |
| 2206 pLocale = widgetData.GetLocal(); | 2352 pLocale = widgetData.GetLocal(); |
| 2207 } else { | 2353 } else { |
| 2208 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale)); | 2354 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale)); |
| 2209 } | 2355 } |
| 2210 if (!pLocale) { | 2356 if (!pLocale) { |
| 2211 return FALSE; | 2357 return FALSE; |
| 2212 } | 2358 } |
| 2213 CFX_WideString wsFormat; | 2359 CFX_WideString wsFormat; |
| 2214 if (szFormat.IsEmpty()) { | 2360 if (szFormat.IsEmpty()) { |
| 2215 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2361 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
| 2216 } else { | 2362 } else { |
| 2217 wsFormat = CFX_WideString::FromUTF8(szFormat); | 2363 wsFormat = CFX_WideString::FromUTF8(szFormat); |
| 2218 } | 2364 } |
| 2219 wsFormat = FX_WSTRC(L"time{") + wsFormat; | 2365 wsFormat = FX_WSTRC(L"time{") + wsFormat; |
| 2220 wsFormat += FX_WSTRC(L"}"); | 2366 wsFormat += FX_WSTRC(L"}"); |
| 2221 CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime), | 2367 CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime), |
| 2222 (CXFA_LocaleMgr*)pMgr); | 2368 (CXFA_LocaleMgr*)pMgr); |
| 2223 CFX_WideString wsRet; | 2369 CFX_WideString wsRet; |
| 2224 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, | 2370 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, |
| 2225 XFA_VALUEPICTURE_Display); | 2371 XFA_VALUEPICTURE_Display); |
| 2226 strLocalTime = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()); | 2372 strLocalTime = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()); |
| 2227 return TRUE; | 2373 return TRUE; |
| 2228 } | 2374 } |
| 2375 |
| 2376 // static |
| 2229 FX_BOOL CXFA_FM2JSContext::GetGMTTime(CFXJSE_Value* pThis, | 2377 FX_BOOL CXFA_FM2JSContext::GetGMTTime(CFXJSE_Value* pThis, |
| 2230 const CFX_ByteStringC& szTime, | 2378 const CFX_ByteStringC& szTime, |
| 2231 const CFX_ByteStringC& szFormat, | 2379 const CFX_ByteStringC& szFormat, |
| 2232 const CFX_ByteStringC& szLocale, | 2380 const CFX_ByteStringC& szLocale, |
| 2233 CFX_ByteString& strGMTTime) { | 2381 CFX_ByteString& strGMTTime) { |
| 2234 CXFA_FM2JSContext* pContext = | 2382 CXFA_FM2JSContext* pContext = |
| 2235 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 2383 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2236 CXFA_Document* pDoc = pContext->GetDocument(); | 2384 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2237 if (!pDoc) { | 2385 if (!pDoc) { |
| 2238 return FALSE; | 2386 return FALSE; |
| 2239 } | 2387 } |
| 2240 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2388 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2241 IFX_Locale* pLocale = NULL; | 2389 IFX_Locale* pLocale = nullptr; |
| 2242 if (szLocale.IsEmpty()) { | 2390 if (szLocale.IsEmpty()) { |
| 2243 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2391 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2244 ASSERT(pThisNode); | 2392 ASSERT(pThisNode); |
| 2245 CXFA_WidgetData widgetData(pThisNode); | 2393 CXFA_WidgetData widgetData(pThisNode); |
| 2246 pLocale = widgetData.GetLocal(); | 2394 pLocale = widgetData.GetLocal(); |
| 2247 } else { | 2395 } else { |
| 2248 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale)); | 2396 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocale)); |
| 2249 } | 2397 } |
| 2250 if (!pLocale) { | 2398 if (!pLocale) { |
| 2251 return FALSE; | 2399 return FALSE; |
| 2252 } | 2400 } |
| 2253 CFX_WideString wsFormat; | 2401 CFX_WideString wsFormat; |
| 2254 if (szFormat.IsEmpty()) { | 2402 if (szFormat.IsEmpty()) { |
| 2255 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); | 2403 pLocale->GetTimePattern(FX_LOCALEDATETIMESUBCATEGORY_Default, wsFormat); |
| 2256 } else { | 2404 } else { |
| 2257 wsFormat = CFX_WideString::FromUTF8(szFormat); | 2405 wsFormat = CFX_WideString::FromUTF8(szFormat); |
| 2258 } | 2406 } |
| 2259 wsFormat = FX_WSTRC(L"time{") + wsFormat; | 2407 wsFormat = FX_WSTRC(L"time{") + wsFormat; |
| 2260 wsFormat += FX_WSTRC(L"}"); | 2408 wsFormat += FX_WSTRC(L"}"); |
| 2261 CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime), | 2409 CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime), |
| 2262 (CXFA_LocaleMgr*)pMgr); | 2410 (CXFA_LocaleMgr*)pMgr); |
| 2263 CFX_WideString wsRet; | 2411 CFX_WideString wsRet; |
| 2264 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, | 2412 widgetValue.FormatPatterns(wsRet, wsFormat, pLocale, |
| 2265 XFA_VALUEPICTURE_Display); | 2413 XFA_VALUEPICTURE_Display); |
| 2266 strGMTTime = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()); | 2414 strGMTTime = FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()); |
| 2267 return TRUE; | 2415 return TRUE; |
| 2268 } | 2416 } |
| 2417 |
| 2418 // static |
| 2269 int32_t CXFA_FM2JSContext::DateString2Num(const CFX_ByteStringC& szDateString) { | 2419 int32_t CXFA_FM2JSContext::DateString2Num(const CFX_ByteStringC& szDateString) { |
| 2270 FX_BOOL bFlags = FALSE; | 2420 FX_BOOL bFlags = FALSE; |
| 2271 int32_t iLength = szDateString.GetLength(); | 2421 int32_t iLength = szDateString.GetLength(); |
| 2272 FX_BOOL iRet = FALSE; | 2422 FX_BOOL iRet = FALSE; |
| 2273 int32_t iStyle = -1; | 2423 int32_t iStyle = -1; |
| 2274 int32_t iYear = 0; | 2424 int32_t iYear = 0; |
| 2275 int32_t iMonth = 0; | 2425 int32_t iMonth = 0; |
| 2276 int32_t iDay = 0; | 2426 int32_t iDay = 0; |
| 2277 int32_t iHour = 0; | 2427 int32_t iHour = 0; |
| 2278 int32_t iMinute = 0; | 2428 int32_t iMinute = 0; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2332 while (iDay - i > 0) { | 2482 while (iDay - i > 0) { |
| 2333 dDays += 1; | 2483 dDays += 1; |
| 2334 ++i; | 2484 ++i; |
| 2335 } | 2485 } |
| 2336 } else { | 2486 } else { |
| 2337 dDays = 0; | 2487 dDays = 0; |
| 2338 } | 2488 } |
| 2339 return (int32_t)dDays; | 2489 return (int32_t)dDays; |
| 2340 } | 2490 } |
| 2341 | 2491 |
| 2492 // static |
| 2342 void CXFA_FM2JSContext::GetLocalDateFormat(CFXJSE_Value* pThis, | 2493 void CXFA_FM2JSContext::GetLocalDateFormat(CFXJSE_Value* pThis, |
| 2343 int32_t iStyle, | 2494 int32_t iStyle, |
| 2344 const CFX_ByteStringC& szLocalStr, | 2495 const CFX_ByteStringC& szLocalStr, |
| 2345 CFX_ByteString& strFormat, | 2496 CFX_ByteString& strFormat, |
| 2346 FX_BOOL bStandard) { | 2497 FX_BOOL bStandard) { |
| 2347 FX_LOCALEDATETIMESUBCATEGORY strStyle; | 2498 FX_LOCALEDATETIMESUBCATEGORY strStyle; |
| 2348 switch (iStyle) { | 2499 switch (iStyle) { |
| 2349 case 0: | 2500 case 0: |
| 2350 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; | 2501 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; |
| 2351 break; | 2502 break; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2365 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; | 2516 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; |
| 2366 break; | 2517 break; |
| 2367 } | 2518 } |
| 2368 CXFA_FM2JSContext* pContext = | 2519 CXFA_FM2JSContext* pContext = |
| 2369 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 2520 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2370 CXFA_Document* pDoc = pContext->GetDocument(); | 2521 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2371 if (!pDoc) { | 2522 if (!pDoc) { |
| 2372 return; | 2523 return; |
| 2373 } | 2524 } |
| 2374 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2525 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2375 IFX_Locale* pLocale = NULL; | 2526 IFX_Locale* pLocale = nullptr; |
| 2376 if (szLocalStr.IsEmpty()) { | 2527 if (szLocalStr.IsEmpty()) { |
| 2377 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2528 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2378 ASSERT(pThisNode); | 2529 ASSERT(pThisNode); |
| 2379 CXFA_WidgetData widgetData(pThisNode); | 2530 CXFA_WidgetData widgetData(pThisNode); |
| 2380 pLocale = widgetData.GetLocal(); | 2531 pLocale = widgetData.GetLocal(); |
| 2381 } else { | 2532 } else { |
| 2382 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocalStr)); | 2533 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocalStr)); |
| 2383 } | 2534 } |
| 2384 if (!pLocale) { | 2535 if (!pLocale) { |
| 2385 return; | 2536 return; |
| 2386 } | 2537 } |
| 2387 CFX_WideString strRet; | 2538 CFX_WideString strRet; |
| 2388 pLocale->GetDatePattern(strStyle, strRet); | 2539 pLocale->GetDatePattern(strStyle, strRet); |
| 2389 if (!bStandard) { | 2540 if (!bStandard) { |
| 2390 CFX_WideString wsSymbols; | 2541 CFX_WideString wsSymbols; |
| 2391 pLocale->GetDateTimeSymbols(wsSymbols); | 2542 pLocale->GetDateTimeSymbols(wsSymbols); |
| 2392 AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date); | 2543 AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date); |
| 2393 } | 2544 } |
| 2394 strFormat = FX_UTF8Encode(strRet.c_str(), strRet.GetLength()); | 2545 strFormat = FX_UTF8Encode(strRet.c_str(), strRet.GetLength()); |
| 2395 } | 2546 } |
| 2547 |
| 2548 // static |
| 2396 void CXFA_FM2JSContext::GetLocalTimeFormat(CFXJSE_Value* pThis, | 2549 void CXFA_FM2JSContext::GetLocalTimeFormat(CFXJSE_Value* pThis, |
| 2397 int32_t iStyle, | 2550 int32_t iStyle, |
| 2398 const CFX_ByteStringC& szLocalStr, | 2551 const CFX_ByteStringC& szLocalStr, |
| 2399 CFX_ByteString& strFormat, | 2552 CFX_ByteString& strFormat, |
| 2400 FX_BOOL bStandard) { | 2553 FX_BOOL bStandard) { |
| 2401 FX_LOCALEDATETIMESUBCATEGORY strStyle; | 2554 FX_LOCALEDATETIMESUBCATEGORY strStyle; |
| 2402 switch (iStyle) { | 2555 switch (iStyle) { |
| 2403 case 0: | 2556 case 0: |
| 2404 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; | 2557 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; |
| 2405 break; | 2558 break; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2419 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; | 2572 strStyle = FX_LOCALEDATETIMESUBCATEGORY_Medium; |
| 2420 break; | 2573 break; |
| 2421 } | 2574 } |
| 2422 CXFA_FM2JSContext* pContext = | 2575 CXFA_FM2JSContext* pContext = |
| 2423 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 2576 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2424 CXFA_Document* pDoc = pContext->GetDocument(); | 2577 CXFA_Document* pDoc = pContext->GetDocument(); |
| 2425 if (!pDoc) { | 2578 if (!pDoc) { |
| 2426 return; | 2579 return; |
| 2427 } | 2580 } |
| 2428 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 2581 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 2429 IFX_Locale* pLocale = NULL; | 2582 IFX_Locale* pLocale = nullptr; |
| 2430 if (szLocalStr.IsEmpty()) { | 2583 if (szLocalStr.IsEmpty()) { |
| 2431 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 2584 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 2432 ASSERT(pThisNode); | 2585 ASSERT(pThisNode); |
| 2433 CXFA_WidgetData widgetData(pThisNode); | 2586 CXFA_WidgetData widgetData(pThisNode); |
| 2434 pLocale = widgetData.GetLocal(); | 2587 pLocale = widgetData.GetLocal(); |
| 2435 } else { | 2588 } else { |
| 2436 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocalStr)); | 2589 pLocale = pMgr->GetLocaleByName(CFX_WideString::FromUTF8(szLocalStr)); |
| 2437 } | 2590 } |
| 2438 if (!pLocale) { | 2591 if (!pLocale) { |
| 2439 return; | 2592 return; |
| 2440 } | 2593 } |
| 2441 CFX_WideString strRet; | 2594 CFX_WideString strRet; |
| 2442 pLocale->GetTimePattern(strStyle, strRet); | 2595 pLocale->GetTimePattern(strStyle, strRet); |
| 2443 if (!bStandard) { | 2596 if (!bStandard) { |
| 2444 CFX_WideString wsSymbols; | 2597 CFX_WideString wsSymbols; |
| 2445 pLocale->GetDateTimeSymbols(wsSymbols); | 2598 pLocale->GetDateTimeSymbols(wsSymbols); |
| 2446 AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time); | 2599 AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time); |
| 2447 } | 2600 } |
| 2448 strFormat = FX_UTF8Encode(strRet.c_str(), strRet.GetLength()); | 2601 strFormat = FX_UTF8Encode(strRet.c_str(), strRet.GetLength()); |
| 2449 } | 2602 } |
| 2603 |
| 2604 // static |
| 2450 void CXFA_FM2JSContext::GetStandardDateFormat(CFXJSE_Value* pThis, | 2605 void CXFA_FM2JSContext::GetStandardDateFormat(CFXJSE_Value* pThis, |
| 2451 int32_t iStyle, | 2606 int32_t iStyle, |
| 2452 const CFX_ByteStringC& szLocalStr, | 2607 const CFX_ByteStringC& szLocalStr, |
| 2453 CFX_ByteString& strFormat) { | 2608 CFX_ByteString& strFormat) { |
| 2454 GetLocalDateFormat(pThis, iStyle, szLocalStr, strFormat, TRUE); | 2609 GetLocalDateFormat(pThis, iStyle, szLocalStr, strFormat, TRUE); |
| 2455 } | 2610 } |
| 2611 |
| 2612 // static |
| 2456 void CXFA_FM2JSContext::GetStandardTimeFormat(CFXJSE_Value* pThis, | 2613 void CXFA_FM2JSContext::GetStandardTimeFormat(CFXJSE_Value* pThis, |
| 2457 int32_t iStyle, | 2614 int32_t iStyle, |
| 2458 const CFX_ByteStringC& szLocalStr, | 2615 const CFX_ByteStringC& szLocalStr, |
| 2459 CFX_ByteString& strFormat) { | 2616 CFX_ByteString& strFormat) { |
| 2460 GetLocalTimeFormat(pThis, iStyle, szLocalStr, strFormat, TRUE); | 2617 GetLocalTimeFormat(pThis, iStyle, szLocalStr, strFormat, TRUE); |
| 2461 } | 2618 } |
| 2619 |
| 2620 // static |
| 2462 void CXFA_FM2JSContext::Num2AllTime(CFXJSE_Value* pThis, | 2621 void CXFA_FM2JSContext::Num2AllTime(CFXJSE_Value* pThis, |
| 2463 int32_t iTime, | 2622 int32_t iTime, |
| 2464 const CFX_ByteStringC& szFormat, | 2623 const CFX_ByteStringC& szFormat, |
| 2465 const CFX_ByteStringC& szLocale, | 2624 const CFX_ByteStringC& szLocale, |
| 2466 FX_BOOL bGM, | 2625 FX_BOOL bGM, |
| 2467 CFX_ByteString& strTime) { | 2626 CFX_ByteString& strTime) { |
| 2468 int32_t iHour = 0; | 2627 int32_t iHour = 0; |
| 2469 int32_t iMin = 0; | 2628 int32_t iMin = 0; |
| 2470 int32_t iSec = 0; | 2629 int32_t iSec = 0; |
| 2471 int32_t iZoneHour = 0; | 2630 int32_t iZoneHour = 0; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2488 GetGMTTime(pThis, strIsoTime.AsStringC(), szFormat, szLocale, strTime); | 2647 GetGMTTime(pThis, strIsoTime.AsStringC(), szFormat, szLocale, strTime); |
| 2489 } else { | 2648 } else { |
| 2490 iRet = IsoTime2Local(pThis, strIsoTime.AsStringC(), szFormat, szLocale, | 2649 iRet = IsoTime2Local(pThis, strIsoTime.AsStringC(), szFormat, szLocale, |
| 2491 strTime); | 2650 strTime); |
| 2492 } | 2651 } |
| 2493 if (!iRet) { | 2652 if (!iRet) { |
| 2494 strTime = ""; | 2653 strTime = ""; |
| 2495 } | 2654 } |
| 2496 } | 2655 } |
| 2497 | 2656 |
| 2657 // static |
| 2498 void CXFA_FM2JSContext::GetLocalTimeZone(int32_t& iHour, | 2658 void CXFA_FM2JSContext::GetLocalTimeZone(int32_t& iHour, |
| 2499 int32_t& iMin, | 2659 int32_t& iMin, |
| 2500 int32_t& iSec) { | 2660 int32_t& iSec) { |
| 2501 time_t now; | 2661 time_t now; |
| 2502 time(&now); | 2662 time(&now); |
| 2503 struct tm* pGmt = gmtime(&now); | 2663 struct tm* pGmt = gmtime(&now); |
| 2504 int32_t iGMHour = pGmt->tm_hour; | 2664 int32_t iGMHour = pGmt->tm_hour; |
| 2505 int32_t iGMMin = pGmt->tm_min; | 2665 int32_t iGMMin = pGmt->tm_min; |
| 2506 int32_t iGMSec = pGmt->tm_sec; | 2666 int32_t iGMSec = pGmt->tm_sec; |
| 2507 struct tm* pLocal = localtime(&now); | 2667 struct tm* pLocal = localtime(&now); |
| 2508 int32_t iLocalHour = pLocal->tm_hour; | 2668 int32_t iLocalHour = pLocal->tm_hour; |
| 2509 int32_t iLocalMin = pLocal->tm_min; | 2669 int32_t iLocalMin = pLocal->tm_min; |
| 2510 int32_t iLocalSec = pLocal->tm_sec; | 2670 int32_t iLocalSec = pLocal->tm_sec; |
| 2511 iHour = iLocalHour - iGMHour; | 2671 iHour = iLocalHour - iGMHour; |
| 2512 iMin = iLocalMin - iGMMin; | 2672 iMin = iLocalMin - iGMMin; |
| 2513 iSec = iLocalSec - iGMSec; | 2673 iSec = iLocalSec - iGMSec; |
| 2514 } | 2674 } |
| 2675 |
| 2676 // static |
| 2515 void CXFA_FM2JSContext::Apr(CFXJSE_Value* pThis, | 2677 void CXFA_FM2JSContext::Apr(CFXJSE_Value* pThis, |
| 2516 const CFX_ByteStringC& szFuncName, | 2678 const CFX_ByteStringC& szFuncName, |
| 2517 CFXJSE_Arguments& args) { | 2679 CFXJSE_Arguments& args) { |
| 2518 CXFA_FM2JSContext* pContext = | 2680 CXFA_FM2JSContext* pContext = |
| 2519 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 2681 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2520 if (args.GetLength() == 3) { | 2682 if (args.GetLength() == 3) { |
| 2521 FX_BOOL bFlags = FALSE; | 2683 FX_BOOL bFlags = FALSE; |
| 2522 FX_DOUBLE nPrincipal = 0; | 2684 FX_DOUBLE nPrincipal = 0; |
| 2523 FX_DOUBLE nPayment = 0; | 2685 FX_DOUBLE nPayment = 0; |
| 2524 FX_DOUBLE nPeriods = 0; | 2686 FX_DOUBLE nPeriods = 0; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2538 if (bFlags) { | 2700 if (bFlags) { |
| 2539 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 2701 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 2540 } else { | 2702 } else { |
| 2541 FX_DOUBLE r = | 2703 FX_DOUBLE r = |
| 2542 2 * (nPeriods * nPayment - nPrincipal) / (nPeriods * nPrincipal); | 2704 2 * (nPeriods * nPayment - nPrincipal) / (nPeriods * nPrincipal); |
| 2543 FX_DOUBLE nTemp = 1; | 2705 FX_DOUBLE nTemp = 1; |
| 2544 for (int32_t i = 0; i < nPeriods; ++i) { | 2706 for (int32_t i = 0; i < nPeriods; ++i) { |
| 2545 nTemp *= (1 + r); | 2707 nTemp *= (1 + r); |
| 2546 } | 2708 } |
| 2547 FX_DOUBLE nRet = r * nTemp / (nTemp - 1) - nPayment / nPrincipal; | 2709 FX_DOUBLE nRet = r * nTemp / (nTemp - 1) - nPayment / nPrincipal; |
| 2548 while ((nRet > FINANCIAL_PRECISION || nRet < -FINANCIAL_PRECISION) && | 2710 while (fabs(nRet) > kFinancialPrecision && !bFlags) { |
| 2549 (!bFlags)) { | |
| 2550 FX_DOUBLE nDerivative = 0; | 2711 FX_DOUBLE nDerivative = 0; |
| 2551 nDerivative = | 2712 nDerivative = |
| 2552 ((nTemp + r * nPeriods * (nTemp / (1 + r))) * (nTemp - 1) - | 2713 ((nTemp + r * nPeriods * (nTemp / (1 + r))) * (nTemp - 1) - |
| 2553 (r * nTemp * nPeriods * (nTemp / (1 + r)))) / | 2714 (r * nTemp * nPeriods * (nTemp / (1 + r)))) / |
| 2554 ((nTemp - 1) * (nTemp - 1)); | 2715 ((nTemp - 1) * (nTemp - 1)); |
| 2555 if (nDerivative == 0) { | 2716 if (nDerivative == 0) { |
| 2556 bFlags = TRUE; | 2717 bFlags = TRUE; |
| 2557 continue; | 2718 continue; |
| 2558 } | 2719 } |
| 2559 r = r - nRet / nDerivative; | 2720 r = r - nRet / nDerivative; |
| 2560 nTemp = 1; | 2721 nTemp = 1; |
| 2561 for (int32_t i = 0; i < nPeriods; ++i) { | 2722 for (int32_t i = 0; i < nPeriods; ++i) { |
| 2562 nTemp *= (1 + r); | 2723 nTemp *= (1 + r); |
| 2563 } | 2724 } |
| 2564 nRet = r * nTemp / (nTemp - 1) - nPayment / nPrincipal; | 2725 nRet = r * nTemp / (nTemp - 1) - nPayment / nPrincipal; |
| 2565 } | 2726 } |
| 2566 if (bFlags) { | 2727 if (bFlags) { |
| 2567 FXJSE_Value_SetNull(args.GetReturnValue()); | 2728 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2568 } else { | 2729 } else { |
| 2569 r = r * 12; | 2730 r = r * 12; |
| 2570 FXJSE_Value_SetDouble(args.GetReturnValue(), r); | 2731 FXJSE_Value_SetDouble(args.GetReturnValue(), r); |
| 2571 } | 2732 } |
| 2572 } | 2733 } |
| 2573 } | 2734 } |
| 2574 } else { | 2735 } else { |
| 2575 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2736 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2576 L"Apr"); | 2737 L"Apr"); |
| 2577 } | 2738 } |
| 2578 } | 2739 } |
| 2740 |
| 2741 // static |
| 2579 void CXFA_FM2JSContext::CTerm(CFXJSE_Value* pThis, | 2742 void CXFA_FM2JSContext::CTerm(CFXJSE_Value* pThis, |
| 2580 const CFX_ByteStringC& szFuncName, | 2743 const CFX_ByteStringC& szFuncName, |
| 2581 CFXJSE_Arguments& args) { | 2744 CFXJSE_Arguments& args) { |
| 2582 CXFA_FM2JSContext* pContext = | 2745 CXFA_FM2JSContext* pContext = |
| 2583 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 2746 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2584 if (args.GetLength() == 3) { | 2747 if (args.GetLength() == 3) { |
| 2585 FX_BOOL bFlags = FALSE; | 2748 FX_BOOL bFlags = FALSE; |
| 2586 FX_FLOAT nRate = 0; | 2749 FX_FLOAT nRate = 0; |
| 2587 FX_FLOAT nFutureValue = 0; | 2750 FX_FLOAT nFutureValue = 0; |
| 2588 FX_FLOAT nInitAmount = 0; | 2751 FX_FLOAT nInitAmount = 0; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2605 FXJSE_Value_SetFloat(args.GetReturnValue(), | 2768 FXJSE_Value_SetFloat(args.GetReturnValue(), |
| 2606 FXSYS_log((FX_FLOAT)(nFutureValue / nInitAmount)) / | 2769 FXSYS_log((FX_FLOAT)(nFutureValue / nInitAmount)) / |
| 2607 FXSYS_log((FX_FLOAT)(1 + nRate))); | 2770 FXSYS_log((FX_FLOAT)(1 + nRate))); |
| 2608 } | 2771 } |
| 2609 } | 2772 } |
| 2610 } else { | 2773 } else { |
| 2611 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2774 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2612 L"CTerm"); | 2775 L"CTerm"); |
| 2613 } | 2776 } |
| 2614 } | 2777 } |
| 2778 |
| 2779 // static |
| 2615 void CXFA_FM2JSContext::FV(CFXJSE_Value* pThis, | 2780 void CXFA_FM2JSContext::FV(CFXJSE_Value* pThis, |
| 2616 const CFX_ByteStringC& szFuncName, | 2781 const CFX_ByteStringC& szFuncName, |
| 2617 CFXJSE_Arguments& args) { | 2782 CFXJSE_Arguments& args) { |
| 2618 CXFA_FM2JSContext* pContext = | 2783 CXFA_FM2JSContext* pContext = |
| 2619 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 2784 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2620 if (args.GetLength() == 3) { | 2785 if (args.GetLength() == 3) { |
| 2621 FX_BOOL bFlags = FALSE; | 2786 FX_BOOL bFlags = FALSE; |
| 2622 FX_DOUBLE nAmount = 0; | 2787 FX_DOUBLE nAmount = 0; |
| 2623 FX_DOUBLE nRate = 0; | 2788 FX_DOUBLE nRate = 0; |
| 2624 FX_DOUBLE nPeriod = 0; | 2789 FX_DOUBLE nPeriod = 0; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2649 dResult = nAmount * (nTemp - 1) / nRate; | 2814 dResult = nAmount * (nTemp - 1) / nRate; |
| 2650 } | 2815 } |
| 2651 FXJSE_Value_SetDouble(args.GetReturnValue(), dResult); | 2816 FXJSE_Value_SetDouble(args.GetReturnValue(), dResult); |
| 2652 } | 2817 } |
| 2653 } | 2818 } |
| 2654 } else { | 2819 } else { |
| 2655 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2820 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2656 L"FV"); | 2821 L"FV"); |
| 2657 } | 2822 } |
| 2658 } | 2823 } |
| 2824 |
| 2825 // static |
| 2659 void CXFA_FM2JSContext::IPmt(CFXJSE_Value* pThis, | 2826 void CXFA_FM2JSContext::IPmt(CFXJSE_Value* pThis, |
| 2660 const CFX_ByteStringC& szFuncName, | 2827 const CFX_ByteStringC& szFuncName, |
| 2661 CFXJSE_Arguments& args) { | 2828 CFXJSE_Arguments& args) { |
| 2662 CXFA_FM2JSContext* pContext = | 2829 CXFA_FM2JSContext* pContext = |
| 2663 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 2830 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2664 if (args.GetLength() == 5) { | 2831 if (args.GetLength() == 5) { |
| 2665 FX_BOOL bFlags = FALSE; | 2832 FX_BOOL bFlags = FALSE; |
| 2666 FX_FLOAT nPrincpalAmount = 0; | 2833 FX_FLOAT nPrincpalAmount = 0; |
| 2667 FX_FLOAT nRate = 0; | 2834 FX_FLOAT nRate = 0; |
| 2668 FX_FLOAT nPayment = 0; | 2835 FX_FLOAT nPayment = 0; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2719 fResult = nSum; | 2886 fResult = nSum; |
| 2720 } | 2887 } |
| 2721 FXJSE_Value_SetFloat(args.GetReturnValue(), fResult); | 2888 FXJSE_Value_SetFloat(args.GetReturnValue(), fResult); |
| 2722 } | 2889 } |
| 2723 } | 2890 } |
| 2724 } else { | 2891 } else { |
| 2725 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2892 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2726 L"IPmt"); | 2893 L"IPmt"); |
| 2727 } | 2894 } |
| 2728 } | 2895 } |
| 2896 |
| 2897 // static |
| 2729 void CXFA_FM2JSContext::NPV(CFXJSE_Value* pThis, | 2898 void CXFA_FM2JSContext::NPV(CFXJSE_Value* pThis, |
| 2730 const CFX_ByteStringC& szFuncName, | 2899 const CFX_ByteStringC& szFuncName, |
| 2731 CFXJSE_Arguments& args) { | 2900 CFXJSE_Arguments& args) { |
| 2732 CXFA_FM2JSContext* pContext = | 2901 CXFA_FM2JSContext* pContext = |
| 2733 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 2902 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2734 int32_t argc = args.GetLength(); | 2903 int32_t argc = args.GetLength(); |
| 2735 if (argc > 2) { | 2904 if (argc > 2) { |
| 2736 FX_BOOL bFlags = FALSE; | 2905 FX_BOOL bFlags = FALSE; |
| 2737 std::vector<std::unique_ptr<CFXJSE_Value>> argValues; | 2906 std::vector<std::unique_ptr<CFXJSE_Value>> argValues; |
| 2738 for (int32_t i = 0; i < argc; i++) { | 2907 for (int32_t i = 0; i < argc; i++) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2766 pData = 0; | 2935 pData = 0; |
| 2767 } | 2936 } |
| 2768 } else { | 2937 } else { |
| 2769 FXJSE_Value_SetNull(args.GetReturnValue()); | 2938 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 2770 } | 2939 } |
| 2771 } else { | 2940 } else { |
| 2772 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2941 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2773 L"NPV"); | 2942 L"NPV"); |
| 2774 } | 2943 } |
| 2775 } | 2944 } |
| 2945 |
| 2946 // static |
| 2776 void CXFA_FM2JSContext::Pmt(CFXJSE_Value* pThis, | 2947 void CXFA_FM2JSContext::Pmt(CFXJSE_Value* pThis, |
| 2777 const CFX_ByteStringC& szFuncName, | 2948 const CFX_ByteStringC& szFuncName, |
| 2778 CFXJSE_Arguments& args) { | 2949 CFXJSE_Arguments& args) { |
| 2779 CXFA_FM2JSContext* pContext = | 2950 CXFA_FM2JSContext* pContext = |
| 2780 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 2951 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2781 if (args.GetLength() == 3) { | 2952 if (args.GetLength() == 3) { |
| 2782 FX_BOOL bFlags = FALSE; | 2953 FX_BOOL bFlags = FALSE; |
| 2783 FX_FLOAT nPrincipal = 0; | 2954 FX_FLOAT nPrincipal = 0; |
| 2784 FX_FLOAT nRate = 0; | 2955 FX_FLOAT nRate = 0; |
| 2785 FX_FLOAT nPeriods = 0; | 2956 FX_FLOAT nPeriods = 0; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2807 } | 2978 } |
| 2808 FXJSE_Value_SetFloat(args.GetReturnValue(), | 2979 FXJSE_Value_SetFloat(args.GetReturnValue(), |
| 2809 (nPrincipal * nRate * nSum) / (nSum - 1)); | 2980 (nPrincipal * nRate * nSum) / (nSum - 1)); |
| 2810 } | 2981 } |
| 2811 } | 2982 } |
| 2812 } else { | 2983 } else { |
| 2813 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2984 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2814 L"Pmt"); | 2985 L"Pmt"); |
| 2815 } | 2986 } |
| 2816 } | 2987 } |
| 2988 |
| 2989 // static |
| 2817 void CXFA_FM2JSContext::PPmt(CFXJSE_Value* pThis, | 2990 void CXFA_FM2JSContext::PPmt(CFXJSE_Value* pThis, |
| 2818 const CFX_ByteStringC& szFuncName, | 2991 const CFX_ByteStringC& szFuncName, |
| 2819 CFXJSE_Arguments& args) { | 2992 CFXJSE_Arguments& args) { |
| 2820 CXFA_FM2JSContext* pContext = | 2993 CXFA_FM2JSContext* pContext = |
| 2821 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 2994 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2822 if (args.GetLength() == 5) { | 2995 if (args.GetLength() == 5) { |
| 2823 FX_BOOL bFlags = FALSE; | 2996 FX_BOOL bFlags = FALSE; |
| 2824 FX_FLOAT nPrincpalAmount = 0; | 2997 FX_FLOAT nPrincpalAmount = 0; |
| 2825 FX_FLOAT nRate = 0; | 2998 FX_FLOAT nRate = 0; |
| 2826 FX_FLOAT nPayment = 0; | 2999 FX_FLOAT nPayment = 0; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2878 } else { | 3051 } else { |
| 2879 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 3052 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 2880 } | 3053 } |
| 2881 } | 3054 } |
| 2882 } | 3055 } |
| 2883 } else { | 3056 } else { |
| 2884 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3057 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2885 L"PPmt"); | 3058 L"PPmt"); |
| 2886 } | 3059 } |
| 2887 } | 3060 } |
| 3061 |
| 3062 // static |
| 2888 void CXFA_FM2JSContext::PV(CFXJSE_Value* pThis, | 3063 void CXFA_FM2JSContext::PV(CFXJSE_Value* pThis, |
| 2889 const CFX_ByteStringC& szFuncName, | 3064 const CFX_ByteStringC& szFuncName, |
| 2890 CFXJSE_Arguments& args) { | 3065 CFXJSE_Arguments& args) { |
| 2891 CXFA_FM2JSContext* pContext = | 3066 CXFA_FM2JSContext* pContext = |
| 2892 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3067 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2893 if (args.GetLength() == 3) { | 3068 if (args.GetLength() == 3) { |
| 2894 FX_BOOL bFlags = FALSE; | 3069 FX_BOOL bFlags = FALSE; |
| 2895 FX_DOUBLE nAmount = 0; | 3070 FX_DOUBLE nAmount = 0; |
| 2896 FX_DOUBLE nRate = 0; | 3071 FX_DOUBLE nRate = 0; |
| 2897 FX_DOUBLE nPeriod = 0; | 3072 FX_DOUBLE nPeriod = 0; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2918 nTemp = 1 / nTemp; | 3093 nTemp = 1 / nTemp; |
| 2919 FXJSE_Value_SetDouble(args.GetReturnValue(), | 3094 FXJSE_Value_SetDouble(args.GetReturnValue(), |
| 2920 nAmount * ((1 - nTemp) / nRate)); | 3095 nAmount * ((1 - nTemp) / nRate)); |
| 2921 } | 3096 } |
| 2922 } | 3097 } |
| 2923 } else { | 3098 } else { |
| 2924 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3099 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2925 L"PV"); | 3100 L"PV"); |
| 2926 } | 3101 } |
| 2927 } | 3102 } |
| 3103 |
| 3104 // static |
| 2928 void CXFA_FM2JSContext::Rate(CFXJSE_Value* pThis, | 3105 void CXFA_FM2JSContext::Rate(CFXJSE_Value* pThis, |
| 2929 const CFX_ByteStringC& szFuncName, | 3106 const CFX_ByteStringC& szFuncName, |
| 2930 CFXJSE_Arguments& args) { | 3107 CFXJSE_Arguments& args) { |
| 2931 CXFA_FM2JSContext* pContext = | 3108 CXFA_FM2JSContext* pContext = |
| 2932 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3109 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2933 if (args.GetLength() == 3) { | 3110 if (args.GetLength() == 3) { |
| 2934 FX_BOOL bFlags = FALSE; | 3111 FX_BOOL bFlags = FALSE; |
| 2935 FX_FLOAT nFuture = 0; | 3112 FX_FLOAT nFuture = 0; |
| 2936 FX_FLOAT nPresent = 0; | 3113 FX_FLOAT nPresent = 0; |
| 2937 FX_FLOAT nTotalNumber = 0; | 3114 FX_FLOAT nTotalNumber = 0; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2955 (FXSYS_pow((FX_FLOAT)(nFuture / nPresent), | 3132 (FXSYS_pow((FX_FLOAT)(nFuture / nPresent), |
| 2956 (FX_FLOAT)(1 / nTotalNumber)) - | 3133 (FX_FLOAT)(1 / nTotalNumber)) - |
| 2957 1)); | 3134 1)); |
| 2958 } | 3135 } |
| 2959 } | 3136 } |
| 2960 } else { | 3137 } else { |
| 2961 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3138 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2962 L"Rate"); | 3139 L"Rate"); |
| 2963 } | 3140 } |
| 2964 } | 3141 } |
| 3142 |
| 3143 // static |
| 2965 void CXFA_FM2JSContext::Term(CFXJSE_Value* pThis, | 3144 void CXFA_FM2JSContext::Term(CFXJSE_Value* pThis, |
| 2966 const CFX_ByteStringC& szFuncName, | 3145 const CFX_ByteStringC& szFuncName, |
| 2967 CFXJSE_Arguments& args) { | 3146 CFXJSE_Arguments& args) { |
| 2968 CXFA_FM2JSContext* pContext = | 3147 CXFA_FM2JSContext* pContext = |
| 2969 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3148 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 2970 if (args.GetLength() == 3) { | 3149 if (args.GetLength() == 3) { |
| 2971 FX_BOOL bFlags = FALSE; | 3150 FX_BOOL bFlags = FALSE; |
| 2972 FX_FLOAT nMount = 0; | 3151 FX_FLOAT nMount = 0; |
| 2973 FX_FLOAT nRate = 0; | 3152 FX_FLOAT nRate = 0; |
| 2974 FX_FLOAT nFuture = 0; | 3153 FX_FLOAT nFuture = 0; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2992 args.GetReturnValue(), | 3171 args.GetReturnValue(), |
| 2993 (FXSYS_log((FX_FLOAT)(nFuture / nMount * nRate) + 1) / | 3172 (FXSYS_log((FX_FLOAT)(nFuture / nMount * nRate) + 1) / |
| 2994 FXSYS_log((FX_FLOAT)(1 + nRate)))); | 3173 FXSYS_log((FX_FLOAT)(1 + nRate)))); |
| 2995 } | 3174 } |
| 2996 } | 3175 } |
| 2997 } else { | 3176 } else { |
| 2998 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3177 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 2999 L"Term"); | 3178 L"Term"); |
| 3000 } | 3179 } |
| 3001 } | 3180 } |
| 3181 |
| 3182 // static |
| 3002 void CXFA_FM2JSContext::Choose(CFXJSE_Value* pThis, | 3183 void CXFA_FM2JSContext::Choose(CFXJSE_Value* pThis, |
| 3003 const CFX_ByteStringC& szFuncName, | 3184 const CFX_ByteStringC& szFuncName, |
| 3004 CFXJSE_Arguments& args) { | 3185 CFXJSE_Arguments& args) { |
| 3005 CXFA_FM2JSContext* pContext = | 3186 CXFA_FM2JSContext* pContext = |
| 3006 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3187 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3007 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 3188 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 3008 int32_t argc = args.GetLength(); | 3189 int32_t argc = args.GetLength(); |
| 3009 if (argc > 1) { | 3190 if (argc > 1) { |
| 3010 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 3191 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 3011 FX_BOOL argOneIsNull = FALSE; | 3192 FX_BOOL argOneIsNull = FALSE; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3078 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 3259 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
| 3079 } | 3260 } |
| 3080 } | 3261 } |
| 3081 } else { | 3262 } else { |
| 3082 CXFA_FM2JSContext* pContext = | 3263 CXFA_FM2JSContext* pContext = |
| 3083 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3264 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3084 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3265 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3085 L"Choose"); | 3266 L"Choose"); |
| 3086 } | 3267 } |
| 3087 } | 3268 } |
| 3269 |
| 3270 // static |
| 3088 void CXFA_FM2JSContext::Exists(CFXJSE_Value* pThis, | 3271 void CXFA_FM2JSContext::Exists(CFXJSE_Value* pThis, |
| 3089 const CFX_ByteStringC& szFuncName, | 3272 const CFX_ByteStringC& szFuncName, |
| 3090 CFXJSE_Arguments& args) { | 3273 CFXJSE_Arguments& args) { |
| 3091 if (args.GetLength() == 1) { | 3274 if (args.GetLength() == 1) { |
| 3092 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 3275 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 3093 FXJSE_Value_SetInteger(args.GetReturnValue(), | 3276 FXJSE_Value_SetInteger(args.GetReturnValue(), |
| 3094 FXJSE_Value_IsObject(argOne.get())); | 3277 FXJSE_Value_IsObject(argOne.get())); |
| 3095 } else { | 3278 } else { |
| 3096 CXFA_FM2JSContext* pContext = | 3279 CXFA_FM2JSContext* pContext = |
| 3097 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3280 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3098 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3281 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3099 L"Exists"); | 3282 L"Exists"); |
| 3100 } | 3283 } |
| 3101 } | 3284 } |
| 3285 |
| 3286 // static |
| 3102 void CXFA_FM2JSContext::HasValue(CFXJSE_Value* pThis, | 3287 void CXFA_FM2JSContext::HasValue(CFXJSE_Value* pThis, |
| 3103 const CFX_ByteStringC& szFuncName, | 3288 const CFX_ByteStringC& szFuncName, |
| 3104 CFXJSE_Arguments& args) { | 3289 CFXJSE_Arguments& args) { |
| 3105 if (args.GetLength() == 1) { | 3290 if (args.GetLength() == 1) { |
| 3106 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 3291 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 3107 if (FXJSE_Value_IsUTF8String(argOne.get())) { | 3292 if (FXJSE_Value_IsUTF8String(argOne.get())) { |
| 3108 CFX_ByteString valueStr; | 3293 CFX_ByteString valueStr; |
| 3109 FXJSE_Value_ToUTF8String(argOne.get(), valueStr); | 3294 FXJSE_Value_ToUTF8String(argOne.get(), valueStr); |
| 3110 valueStr.TrimLeft(); | 3295 valueStr.TrimLeft(); |
| 3111 FXJSE_Value_SetInteger(args.GetReturnValue(), (!valueStr.IsEmpty())); | 3296 FXJSE_Value_SetInteger(args.GetReturnValue(), (!valueStr.IsEmpty())); |
| 3112 } else if (FXJSE_Value_IsNumber(argOne.get()) || | 3297 } else if (FXJSE_Value_IsNumber(argOne.get()) || |
| 3113 FXJSE_Value_IsBoolean(argOne.get())) { | 3298 FXJSE_Value_IsBoolean(argOne.get())) { |
| 3114 FXJSE_Value_SetInteger(args.GetReturnValue(), TRUE); | 3299 FXJSE_Value_SetInteger(args.GetReturnValue(), TRUE); |
| 3115 } else { | 3300 } else { |
| 3116 FXJSE_Value_SetInteger(args.GetReturnValue(), FALSE); | 3301 FXJSE_Value_SetInteger(args.GetReturnValue(), FALSE); |
| 3117 } | 3302 } |
| 3118 } else { | 3303 } else { |
| 3119 CXFA_FM2JSContext* pContext = | 3304 CXFA_FM2JSContext* pContext = |
| 3120 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3305 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3121 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3306 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3122 L"HasValue"); | 3307 L"HasValue"); |
| 3123 } | 3308 } |
| 3124 } | 3309 } |
| 3310 |
| 3311 // static |
| 3125 void CXFA_FM2JSContext::Oneof(CFXJSE_Value* pThis, | 3312 void CXFA_FM2JSContext::Oneof(CFXJSE_Value* pThis, |
| 3126 const CFX_ByteStringC& szFuncName, | 3313 const CFX_ByteStringC& szFuncName, |
| 3127 CFXJSE_Arguments& args) { | 3314 CFXJSE_Arguments& args) { |
| 3128 int32_t argc = args.GetLength(); | 3315 if (args.GetLength() > 1) { |
| 3129 if (argc > 1) { | |
| 3130 FX_BOOL bFlags = FALSE; | 3316 FX_BOOL bFlags = FALSE; |
| 3131 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 3317 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 3132 CFXJSE_Value** parametersValue = nullptr; | 3318 CFXJSE_Value** parametersValue = nullptr; |
| 3133 int32_t iCount = 0; | 3319 int32_t iCount = 0; |
| 3134 unfoldArgs(pThis, args, parametersValue, iCount, 1); | 3320 unfoldArgs(pThis, args, parametersValue, iCount, 1); |
| 3135 for (int32_t i = 0; i < iCount; i++) { | 3321 for (int32_t i = 0; i < iCount; i++) { |
| 3136 if (simpleValueCompare(pThis, argOne.get(), parametersValue[i])) { | 3322 if (simpleValueCompare(pThis, argOne.get(), parametersValue[i])) { |
| 3137 bFlags = TRUE; | 3323 bFlags = TRUE; |
| 3138 break; | 3324 break; |
| 3139 } | 3325 } |
| 3140 } | 3326 } |
| 3141 FXJSE_Value_SetInteger(args.GetReturnValue(), bFlags); | 3327 FXJSE_Value_SetInteger(args.GetReturnValue(), bFlags); |
| 3142 for (int32_t i = 0; i < iCount; i++) { | 3328 for (int32_t i = 0; i < iCount; i++) { |
| 3143 delete parametersValue[i]; | 3329 delete parametersValue[i]; |
| 3144 } | 3330 } |
| 3145 FX_Free(parametersValue); | 3331 FX_Free(parametersValue); |
| 3146 } else { | 3332 } else { |
| 3147 CXFA_FM2JSContext* pContext = | 3333 CXFA_FM2JSContext* pContext = |
| 3148 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3334 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3149 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3335 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3150 L"Oneof"); | 3336 L"Oneof"); |
| 3151 } | 3337 } |
| 3152 } | 3338 } |
| 3339 |
| 3340 // static |
| 3153 void CXFA_FM2JSContext::Within(CFXJSE_Value* pThis, | 3341 void CXFA_FM2JSContext::Within(CFXJSE_Value* pThis, |
| 3154 const CFX_ByteStringC& szFuncName, | 3342 const CFX_ByteStringC& szFuncName, |
| 3155 CFXJSE_Arguments& args) { | 3343 CFXJSE_Arguments& args) { |
| 3156 int32_t argc = args.GetLength(); | 3344 if (args.GetLength() == 3) { |
| 3157 if (argc == 3) { | |
| 3158 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 3345 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 3159 if (FXJSE_Value_IsNull(argOne.get())) { | 3346 if (FXJSE_Value_IsNull(argOne.get())) { |
| 3160 FXJSE_Value_SetUndefined(args.GetReturnValue()); | 3347 FXJSE_Value_SetUndefined(args.GetReturnValue()); |
| 3161 } else { | 3348 } else { |
| 3162 std::unique_ptr<CFXJSE_Value> argLow = GetSimpleValue(pThis, args, 1); | 3349 std::unique_ptr<CFXJSE_Value> argLow = GetSimpleValue(pThis, args, 1); |
| 3163 std::unique_ptr<CFXJSE_Value> argHeight = GetSimpleValue(pThis, args, 2); | 3350 std::unique_ptr<CFXJSE_Value> argHeight = GetSimpleValue(pThis, args, 2); |
| 3164 if (FXJSE_Value_IsNumber(argOne.get())) { | 3351 if (FXJSE_Value_IsNumber(argOne.get())) { |
| 3165 FX_FLOAT oneNumber = ValueToFloat(pThis, argOne.get()); | 3352 FX_FLOAT oneNumber = ValueToFloat(pThis, argOne.get()); |
| 3166 FX_FLOAT lowNumber = ValueToFloat(pThis, argLow.get()); | 3353 FX_FLOAT lowNumber = ValueToFloat(pThis, argLow.get()); |
| 3167 FX_FLOAT heightNumber = ValueToFloat(pThis, argHeight.get()); | 3354 FX_FLOAT heightNumber = ValueToFloat(pThis, argHeight.get()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3181 (oneString.Compare(heightString.AsStringC()) <= 0))); | 3368 (oneString.Compare(heightString.AsStringC()) <= 0))); |
| 3182 } | 3369 } |
| 3183 } | 3370 } |
| 3184 } else { | 3371 } else { |
| 3185 CXFA_FM2JSContext* pContext = | 3372 CXFA_FM2JSContext* pContext = |
| 3186 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3373 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3187 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3374 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3188 L"Within"); | 3375 L"Within"); |
| 3189 } | 3376 } |
| 3190 } | 3377 } |
| 3378 |
| 3379 // static |
| 3191 void CXFA_FM2JSContext::If(CFXJSE_Value* pThis, | 3380 void CXFA_FM2JSContext::If(CFXJSE_Value* pThis, |
| 3192 const CFX_ByteStringC& szFuncName, | 3381 const CFX_ByteStringC& szFuncName, |
| 3193 CFXJSE_Arguments& args) { | 3382 CFXJSE_Arguments& args) { |
| 3194 if (args.GetLength() == 3) { | 3383 if (args.GetLength() == 3) { |
| 3195 std::unique_ptr<CFXJSE_Value> argCondition = GetSimpleValue(pThis, args, 0); | 3384 std::unique_ptr<CFXJSE_Value> argCondition = GetSimpleValue(pThis, args, 0); |
| 3196 std::unique_ptr<CFXJSE_Value> argFirstValue = | 3385 std::unique_ptr<CFXJSE_Value> argFirstValue = |
| 3197 GetSimpleValue(pThis, args, 1); | 3386 GetSimpleValue(pThis, args, 1); |
| 3198 std::unique_ptr<CFXJSE_Value> argSecondValue = | 3387 std::unique_ptr<CFXJSE_Value> argSecondValue = |
| 3199 GetSimpleValue(pThis, args, 2); | 3388 GetSimpleValue(pThis, args, 2); |
| 3200 FX_BOOL bCondition = FXJSE_Value_ToBoolean(argCondition.get()); | 3389 FX_BOOL bCondition = FXJSE_Value_ToBoolean(argCondition.get()); |
| 3201 FXJSE_Value_Set(args.GetReturnValue(), | 3390 FXJSE_Value_Set(args.GetReturnValue(), |
| 3202 bCondition ? argFirstValue.get() : argSecondValue.get()); | 3391 bCondition ? argFirstValue.get() : argSecondValue.get()); |
| 3203 } else { | 3392 } else { |
| 3204 CXFA_FM2JSContext* pContext = | 3393 CXFA_FM2JSContext* pContext = |
| 3205 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3394 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3206 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3395 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3207 L"If"); | 3396 L"If"); |
| 3208 } | 3397 } |
| 3209 } | 3398 } |
| 3399 |
| 3400 // static |
| 3210 void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis, | 3401 void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis, |
| 3211 const CFX_ByteStringC& szFuncName, | 3402 const CFX_ByteStringC& szFuncName, |
| 3212 CFXJSE_Arguments& args) { | 3403 CFXJSE_Arguments& args) { |
| 3213 CXFA_FM2JSContext* pContext = | 3404 CXFA_FM2JSContext* pContext = |
| 3214 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3405 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3215 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 3406 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 3216 if (args.GetLength() == 1) { | 3407 if (args.GetLength() == 1) { |
| 3217 std::unique_ptr<CFXJSE_Value> scriptValue = GetSimpleValue(pThis, args, 0); | 3408 std::unique_ptr<CFXJSE_Value> scriptValue = GetSimpleValue(pThis, args, 0); |
| 3218 CFX_ByteString utf8ScriptString; | 3409 CFX_ByteString utf8ScriptString; |
| 3219 ValueToUTF8String(scriptValue.get(), utf8ScriptString); | 3410 ValueToUTF8String(scriptValue.get(), utf8ScriptString); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3235 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(), | 3426 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(), |
| 3236 returnValue.get()); | 3427 returnValue.get()); |
| 3237 FXJSE_Value_Set(args.GetReturnValue(), returnValue.get()); | 3428 FXJSE_Value_Set(args.GetReturnValue(), returnValue.get()); |
| 3238 FXJSE_Context_Release(pContext); | 3429 FXJSE_Context_Release(pContext); |
| 3239 } | 3430 } |
| 3240 } else { | 3431 } else { |
| 3241 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3432 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3242 L"Eval"); | 3433 L"Eval"); |
| 3243 } | 3434 } |
| 3244 } | 3435 } |
| 3436 |
| 3437 // static |
| 3245 void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis, | 3438 void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis, |
| 3246 const CFX_ByteStringC& szFuncName, | 3439 const CFX_ByteStringC& szFuncName, |
| 3247 CFXJSE_Arguments& args) { | 3440 CFXJSE_Arguments& args) { |
| 3248 CXFA_FM2JSContext* pContext = | 3441 CXFA_FM2JSContext* pContext = |
| 3249 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3442 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3250 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 3443 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 3251 if (args.GetLength() == 1) { | 3444 if (args.GetLength() == 1) { |
| 3252 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 3445 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 3253 if (FXJSE_Value_IsNull(argOne.get())) { | 3446 if (FXJSE_Value_IsNull(argOne.get())) { |
| 3254 CFXJSE_Value* rgValues[3]; | 3447 CFXJSE_Value* rgValues[3]; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3307 FXJSE_Value_IsNumber(argOne.get())) { | 3500 FXJSE_Value_IsNumber(argOne.get())) { |
| 3308 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); | 3501 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); |
| 3309 } else { | 3502 } else { |
| 3310 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 3503 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 3311 } | 3504 } |
| 3312 } else { | 3505 } else { |
| 3313 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3506 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3314 L"Ref"); | 3507 L"Ref"); |
| 3315 } | 3508 } |
| 3316 } | 3509 } |
| 3510 |
| 3511 // static |
| 3317 void CXFA_FM2JSContext::UnitType(CFXJSE_Value* pThis, | 3512 void CXFA_FM2JSContext::UnitType(CFXJSE_Value* pThis, |
| 3318 const CFX_ByteStringC& szFuncName, | 3513 const CFX_ByteStringC& szFuncName, |
| 3319 CFXJSE_Arguments& args) { | 3514 CFXJSE_Arguments& args) { |
| 3320 if (args.GetLength() == 1) { | 3515 if (args.GetLength() == 1) { |
| 3321 std::unique_ptr<CFXJSE_Value> unitspanValue = | 3516 std::unique_ptr<CFXJSE_Value> unitspanValue = |
| 3322 GetSimpleValue(pThis, args, 0); | 3517 GetSimpleValue(pThis, args, 0); |
| 3323 if (FXJSE_Value_IsNull(unitspanValue.get())) { | 3518 if (FXJSE_Value_IsNull(unitspanValue.get())) { |
| 3324 FXJSE_Value_SetNull(args.GetReturnValue()); | 3519 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3325 return; | 3520 return; |
| 3326 } | 3521 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3423 break; | 3618 break; |
| 3424 } | 3619 } |
| 3425 } | 3620 } |
| 3426 } else { | 3621 } else { |
| 3427 CXFA_FM2JSContext* pContext = | 3622 CXFA_FM2JSContext* pContext = |
| 3428 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3623 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3429 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3624 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3430 L"UnitType"); | 3625 L"UnitType"); |
| 3431 } | 3626 } |
| 3432 } | 3627 } |
| 3628 |
| 3629 // static |
| 3433 void CXFA_FM2JSContext::UnitValue(CFXJSE_Value* pThis, | 3630 void CXFA_FM2JSContext::UnitValue(CFXJSE_Value* pThis, |
| 3434 const CFX_ByteStringC& szFuncName, | 3631 const CFX_ByteStringC& szFuncName, |
| 3435 CFXJSE_Arguments& args) { | 3632 CFXJSE_Arguments& args) { |
| 3436 int32_t argc = args.GetLength(); | 3633 int32_t argc = args.GetLength(); |
| 3437 if ((argc == 1) || (argc == 2)) { | 3634 if ((argc == 1) || (argc == 2)) { |
| 3438 std::unique_ptr<CFXJSE_Value> unitspanValue = | 3635 std::unique_ptr<CFXJSE_Value> unitspanValue = |
| 3439 GetSimpleValue(pThis, args, 0); | 3636 GetSimpleValue(pThis, args, 0); |
| 3440 CFX_ByteString unitspanString; | 3637 CFX_ByteString unitspanString; |
| 3441 FX_DOUBLE dFirstNumber = 0; | 3638 FX_DOUBLE dFirstNumber = 0; |
| 3442 CFX_ByteString strFirstUnit; | 3639 CFX_ByteString strFirstUnit; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 3453 *(pData + u) == 0x0A || *(pData + u) == 0x0D) { | 3650 *(pData + u) == 0x0A || *(pData + u) == 0x0D) { |
| 3454 ++u; | 3651 ++u; |
| 3455 } | 3652 } |
| 3456 while (u < unitspanString.GetLength()) { | 3653 while (u < unitspanString.GetLength()) { |
| 3457 if ((*(pData + u) > '9' || *(pData + u) < '0') && | 3654 if ((*(pData + u) > '9' || *(pData + u) < '0') && |
| 3458 *(pData + u) != '.' && *(pData + u) != '-') { | 3655 *(pData + u) != '.' && *(pData + u) != '-') { |
| 3459 break; | 3656 break; |
| 3460 } | 3657 } |
| 3461 ++u; | 3658 ++u; |
| 3462 } | 3659 } |
| 3463 FX_CHAR* pTemp = NULL; | 3660 FX_CHAR* pTemp = nullptr; |
| 3464 dFirstNumber = strtod(pData, &pTemp); | 3661 dFirstNumber = strtod(pData, &pTemp); |
| 3465 while (*(pData + u) == ' ' || *(pData + u) == 0x09 || | 3662 while (*(pData + u) == ' ' || *(pData + u) == 0x09 || |
| 3466 *(pData + u) == 0x0B || *(pData + u) == 0x0C || | 3663 *(pData + u) == 0x0B || *(pData + u) == 0x0C || |
| 3467 *(pData + u) == 0x0A || *(pData + u) == 0x0D) { | 3664 *(pData + u) == 0x0A || *(pData + u) == 0x0D) { |
| 3468 ++u; | 3665 ++u; |
| 3469 } | 3666 } |
| 3470 int32_t uLen = unitspanString.GetLength(); | 3667 int32_t uLen = unitspanString.GetLength(); |
| 3471 while (u < uLen) { | 3668 while (u < uLen) { |
| 3472 if (*(pData + u) == ' ') { | 3669 if (*(pData + u) == ' ') { |
| 3473 break; | 3670 break; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3579 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 3776 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
| 3580 } | 3777 } |
| 3581 } | 3778 } |
| 3582 } else { | 3779 } else { |
| 3583 CXFA_FM2JSContext* pContext = | 3780 CXFA_FM2JSContext* pContext = |
| 3584 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3781 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3585 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3782 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3586 L"UnitValue"); | 3783 L"UnitValue"); |
| 3587 } | 3784 } |
| 3588 } | 3785 } |
| 3786 |
| 3787 // static |
| 3589 void CXFA_FM2JSContext::At(CFXJSE_Value* pThis, | 3788 void CXFA_FM2JSContext::At(CFXJSE_Value* pThis, |
| 3590 const CFX_ByteStringC& szFuncName, | 3789 const CFX_ByteStringC& szFuncName, |
| 3591 CFXJSE_Arguments& args) { | 3790 CFXJSE_Arguments& args) { |
| 3592 CXFA_FM2JSContext* pContext = | |
| 3593 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
| 3594 if (args.GetLength() == 2) { | 3791 if (args.GetLength() == 2) { |
| 3595 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 3792 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 3596 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | 3793 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
| 3597 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get())) { | 3794 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get())) { |
| 3598 FXJSE_Value_SetNull(args.GetReturnValue()); | 3795 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3599 } else { | 3796 } else { |
| 3600 CFX_ByteString stringTwo; | 3797 CFX_ByteString stringTwo; |
| 3601 ValueToUTF8String(argTwo.get(), stringTwo); | 3798 ValueToUTF8String(argTwo.get(), stringTwo); |
| 3602 if (stringTwo.IsEmpty()) { | 3799 if (stringTwo.IsEmpty()) { |
| 3603 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); | 3800 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); |
| 3604 } else { | 3801 } else { |
| 3605 CFX_ByteString stringOne; | 3802 CFX_ByteString stringOne; |
| 3606 ValueToUTF8String(argOne.get(), stringOne); | 3803 ValueToUTF8String(argOne.get(), stringOne); |
| 3607 FX_STRSIZE iPosition = stringOne.Find(stringTwo.AsStringC()); | 3804 FX_STRSIZE iPosition = stringOne.Find(stringTwo.AsStringC()); |
| 3608 FXJSE_Value_SetInteger(args.GetReturnValue(), iPosition + 1); | 3805 FXJSE_Value_SetInteger(args.GetReturnValue(), iPosition + 1); |
| 3609 } | 3806 } |
| 3610 } | 3807 } |
| 3611 } else { | 3808 } else { |
| 3809 CXFA_FM2JSContext* pContext = |
| 3810 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3612 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3811 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3613 L"At"); | 3812 L"At"); |
| 3614 } | 3813 } |
| 3615 } | 3814 } |
| 3815 |
| 3816 // static |
| 3616 void CXFA_FM2JSContext::Concat(CFXJSE_Value* pThis, | 3817 void CXFA_FM2JSContext::Concat(CFXJSE_Value* pThis, |
| 3617 const CFX_ByteStringC& szFuncName, | 3818 const CFX_ByteStringC& szFuncName, |
| 3618 CFXJSE_Arguments& args) { | 3819 CFXJSE_Arguments& args) { |
| 3619 CXFA_FM2JSContext* pContext = | |
| 3620 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
| 3621 int32_t argc = args.GetLength(); | 3820 int32_t argc = args.GetLength(); |
| 3622 if (argc >= 1) { | 3821 if (argc >= 1) { |
| 3623 CFX_ByteString resultString; | 3822 CFX_ByteString resultString; |
| 3624 FX_BOOL bAllNull = TRUE; | 3823 FX_BOOL bAllNull = TRUE; |
| 3625 | 3824 |
| 3626 for (int32_t i = 0; i < argc; i++) { | 3825 for (int32_t i = 0; i < argc; i++) { |
| 3627 std::unique_ptr<CFXJSE_Value> value = GetSimpleValue(pThis, args, i); | 3826 std::unique_ptr<CFXJSE_Value> value = GetSimpleValue(pThis, args, i); |
| 3628 if (!ValueIsNull(pThis, value.get())) { | 3827 if (!ValueIsNull(pThis, value.get())) { |
| 3629 CFX_ByteString valueStr; | 3828 CFX_ByteString valueStr; |
| 3630 ValueToUTF8String(value.get(), valueStr); | 3829 ValueToUTF8String(value.get(), valueStr); |
| 3631 resultString += valueStr; | 3830 resultString += valueStr; |
| 3632 bAllNull = FALSE; | 3831 bAllNull = FALSE; |
| 3633 } | 3832 } |
| 3634 } | 3833 } |
| 3635 | 3834 |
| 3636 if (bAllNull) { | 3835 if (bAllNull) { |
| 3637 FXJSE_Value_SetNull(args.GetReturnValue()); | 3836 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3638 } else { | 3837 } else { |
| 3639 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 3838 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 3640 resultString.AsStringC()); | 3839 resultString.AsStringC()); |
| 3641 } | 3840 } |
| 3642 } else { | 3841 } else { |
| 3842 CXFA_FM2JSContext* pContext = |
| 3843 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3643 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3844 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3644 L"Concat"); | 3845 L"Concat"); |
| 3645 } | 3846 } |
| 3646 } | 3847 } |
| 3848 |
| 3849 // static |
| 3647 void CXFA_FM2JSContext::Decode(CFXJSE_Value* pThis, | 3850 void CXFA_FM2JSContext::Decode(CFXJSE_Value* pThis, |
| 3648 const CFX_ByteStringC& szFuncName, | 3851 const CFX_ByteStringC& szFuncName, |
| 3649 CFXJSE_Arguments& args) { | 3852 CFXJSE_Arguments& args) { |
| 3650 CXFA_FM2JSContext* pContext = | |
| 3651 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
| 3652 int32_t argc = args.GetLength(); | 3853 int32_t argc = args.GetLength(); |
| 3653 if (argc == 1) { | 3854 if (argc == 1) { |
| 3654 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 3855 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 3655 if (ValueIsNull(pThis, argOne.get())) { | 3856 if (ValueIsNull(pThis, argOne.get())) { |
| 3656 FXJSE_Value_SetNull(args.GetReturnValue()); | 3857 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3657 } else { | 3858 } else { |
| 3658 CFX_ByteString toDecodeString; | 3859 CFX_ByteString toDecodeString; |
| 3659 ValueToUTF8String(argOne.get(), toDecodeString); | 3860 ValueToUTF8String(argOne.get(), toDecodeString); |
| 3660 CFX_ByteTextBuf resultBuf; | 3861 CFX_ByteTextBuf resultBuf; |
| 3661 DecodeURL(toDecodeString.AsStringC(), resultBuf); | 3862 DecodeURL(toDecodeString.AsStringC(), resultBuf); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3675 if (identifyString.EqualNoCase("html")) { | 3876 if (identifyString.EqualNoCase("html")) { |
| 3676 DecodeHTML(toDecodeString.AsStringC(), resultBuf); | 3877 DecodeHTML(toDecodeString.AsStringC(), resultBuf); |
| 3677 } else if (identifyString.EqualNoCase("xml")) { | 3878 } else if (identifyString.EqualNoCase("xml")) { |
| 3678 DecodeXML(toDecodeString.AsStringC(), resultBuf); | 3879 DecodeXML(toDecodeString.AsStringC(), resultBuf); |
| 3679 } else { | 3880 } else { |
| 3680 DecodeURL(toDecodeString.AsStringC(), resultBuf); | 3881 DecodeURL(toDecodeString.AsStringC(), resultBuf); |
| 3681 } | 3882 } |
| 3682 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); | 3883 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); |
| 3683 } | 3884 } |
| 3684 } else { | 3885 } else { |
| 3886 CXFA_FM2JSContext* pContext = |
| 3887 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3685 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3888 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3686 L"Decode"); | 3889 L"Decode"); |
| 3687 } | 3890 } |
| 3688 } | 3891 } |
| 3892 |
| 3893 // static |
| 3689 void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString, | 3894 void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString, |
| 3690 CFX_ByteTextBuf& szResultString) { | 3895 CFX_ByteTextBuf& szResultString) { |
| 3691 CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString); | 3896 CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString); |
| 3692 const FX_WCHAR* pData = wsURLString.c_str(); | 3897 const FX_WCHAR* pData = wsURLString.c_str(); |
| 3693 int32_t iLen = wsURLString.GetLength(); | 3898 int32_t iLen = wsURLString.GetLength(); |
| 3694 int32_t i = 0; | 3899 int32_t i = 0; |
| 3695 FX_WCHAR ch = 0; | 3900 FX_WCHAR ch = 0; |
| 3696 FX_WCHAR chTemp = 0; | 3901 FX_WCHAR chTemp = 0; |
| 3697 CFX_WideTextBuf wsResultBuf; | 3902 CFX_WideTextBuf wsResultBuf; |
| 3698 while (i < iLen) { | 3903 while (i < iLen) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3734 wsResultBuf.AppendChar(ch); | 3939 wsResultBuf.AppendChar(ch); |
| 3735 } | 3940 } |
| 3736 ++i; | 3941 ++i; |
| 3737 } | 3942 } |
| 3738 wsResultBuf.AppendChar(0); | 3943 wsResultBuf.AppendChar(0); |
| 3739 szResultString.Clear(); | 3944 szResultString.Clear(); |
| 3740 szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), | 3945 szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), |
| 3741 wsResultBuf.GetLength()) | 3946 wsResultBuf.GetLength()) |
| 3742 .AsStringC(); | 3947 .AsStringC(); |
| 3743 } | 3948 } |
| 3949 |
| 3950 // static |
| 3744 void CXFA_FM2JSContext::DecodeHTML(const CFX_ByteStringC& szHTMLString, | 3951 void CXFA_FM2JSContext::DecodeHTML(const CFX_ByteStringC& szHTMLString, |
| 3745 CFX_ByteTextBuf& szResultString) { | 3952 CFX_ByteTextBuf& szResultString) { |
| 3746 CFX_WideString wsHTMLString = CFX_WideString::FromUTF8(szHTMLString); | 3953 CFX_WideString wsHTMLString = CFX_WideString::FromUTF8(szHTMLString); |
| 3747 FX_WCHAR strString[9]; | 3954 FX_WCHAR strString[9]; |
| 3748 int32_t iStrIndex = 0; | 3955 int32_t iStrIndex = 0; |
| 3749 int32_t iLen = wsHTMLString.GetLength(); | 3956 int32_t iLen = wsHTMLString.GetLength(); |
| 3750 int32_t i = 0; | 3957 int32_t i = 0; |
| 3751 int32_t iCode = 0; | 3958 int32_t iCode = 0; |
| 3752 FX_WCHAR ch = 0; | 3959 FX_WCHAR ch = 0; |
| 3753 const FX_WCHAR* pData = wsHTMLString.c_str(); | 3960 const FX_WCHAR* pData = wsHTMLString.c_str(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3808 iStrIndex = 0; | 4015 iStrIndex = 0; |
| 3809 strString[iStrIndex] = 0; | 4016 strString[iStrIndex] = 0; |
| 3810 ++i; | 4017 ++i; |
| 3811 } | 4018 } |
| 3812 wsResultBuf.AppendChar(0); | 4019 wsResultBuf.AppendChar(0); |
| 3813 szResultString.Clear(); | 4020 szResultString.Clear(); |
| 3814 szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), | 4021 szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), |
| 3815 wsResultBuf.GetLength()) | 4022 wsResultBuf.GetLength()) |
| 3816 .AsStringC(); | 4023 .AsStringC(); |
| 3817 } | 4024 } |
| 4025 |
| 4026 // static |
| 3818 void CXFA_FM2JSContext::DecodeXML(const CFX_ByteStringC& szXMLString, | 4027 void CXFA_FM2JSContext::DecodeXML(const CFX_ByteStringC& szXMLString, |
| 3819 CFX_ByteTextBuf& szResultString) { | 4028 CFX_ByteTextBuf& szResultString) { |
| 3820 CFX_WideString wsXMLString = CFX_WideString::FromUTF8(szXMLString); | 4029 CFX_WideString wsXMLString = CFX_WideString::FromUTF8(szXMLString); |
| 3821 FX_WCHAR strString[9]; | 4030 FX_WCHAR strString[9]; |
| 3822 int32_t iStrIndex = 0; | 4031 int32_t iStrIndex = 0; |
| 3823 int32_t iLen = wsXMLString.GetLength(); | 4032 int32_t iLen = wsXMLString.GetLength(); |
| 3824 int32_t i = 0; | 4033 int32_t i = 0; |
| 3825 int32_t iCode = 0; | 4034 int32_t iCode = 0; |
| 3826 FX_WCHAR ch = 0; | 4035 FX_WCHAR ch = 0; |
| 3827 const FX_WCHAR* pData = wsXMLString.c_str(); | 4036 const FX_WCHAR* pData = wsXMLString.c_str(); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3905 iStrIndex = 0; | 4114 iStrIndex = 0; |
| 3906 strString[iStrIndex] = 0; | 4115 strString[iStrIndex] = 0; |
| 3907 ++i; | 4116 ++i; |
| 3908 iCode = 0; | 4117 iCode = 0; |
| 3909 } | 4118 } |
| 3910 wsXMLBuf.AppendChar(0); | 4119 wsXMLBuf.AppendChar(0); |
| 3911 szResultString.Clear(); | 4120 szResultString.Clear(); |
| 3912 szResultString << FX_UTF8Encode(wsXMLBuf.GetBuffer(), wsXMLBuf.GetLength()) | 4121 szResultString << FX_UTF8Encode(wsXMLBuf.GetBuffer(), wsXMLBuf.GetLength()) |
| 3913 .AsStringC(); | 4122 .AsStringC(); |
| 3914 } | 4123 } |
| 4124 |
| 4125 // static |
| 3915 void CXFA_FM2JSContext::Encode(CFXJSE_Value* pThis, | 4126 void CXFA_FM2JSContext::Encode(CFXJSE_Value* pThis, |
| 3916 const CFX_ByteStringC& szFuncName, | 4127 const CFX_ByteStringC& szFuncName, |
| 3917 CFXJSE_Arguments& args) { | 4128 CFXJSE_Arguments& args) { |
| 3918 CXFA_FM2JSContext* pContext = | |
| 3919 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
| 3920 int32_t argc = args.GetLength(); | 4129 int32_t argc = args.GetLength(); |
| 3921 if (argc == 1) { | 4130 if (argc == 1) { |
| 3922 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4131 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 3923 if (ValueIsNull(pThis, argOne.get())) { | 4132 if (ValueIsNull(pThis, argOne.get())) { |
| 3924 FXJSE_Value_SetNull(args.GetReturnValue()); | 4133 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 3925 } else { | 4134 } else { |
| 3926 CFX_ByteString toEncodeString; | 4135 CFX_ByteString toEncodeString; |
| 3927 ValueToUTF8String(argOne.get(), toEncodeString); | 4136 ValueToUTF8String(argOne.get(), toEncodeString); |
| 3928 CFX_ByteTextBuf resultBuf; | 4137 CFX_ByteTextBuf resultBuf; |
| 3929 EncodeURL(toEncodeString.AsStringC(), resultBuf); | 4138 EncodeURL(toEncodeString.AsStringC(), resultBuf); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3943 if (identifyString.EqualNoCase("html")) { | 4152 if (identifyString.EqualNoCase("html")) { |
| 3944 EncodeHTML(toEncodeString.AsStringC(), resultBuf); | 4153 EncodeHTML(toEncodeString.AsStringC(), resultBuf); |
| 3945 } else if (identifyString.EqualNoCase("xml")) { | 4154 } else if (identifyString.EqualNoCase("xml")) { |
| 3946 EncodeXML(toEncodeString.AsStringC(), resultBuf); | 4155 EncodeXML(toEncodeString.AsStringC(), resultBuf); |
| 3947 } else { | 4156 } else { |
| 3948 EncodeURL(toEncodeString.AsStringC(), resultBuf); | 4157 EncodeURL(toEncodeString.AsStringC(), resultBuf); |
| 3949 } | 4158 } |
| 3950 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); | 4159 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); |
| 3951 } | 4160 } |
| 3952 } else { | 4161 } else { |
| 4162 CXFA_FM2JSContext* pContext = |
| 4163 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 3953 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4164 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 3954 L"Encode"); | 4165 L"Encode"); |
| 3955 } | 4166 } |
| 3956 } | 4167 } |
| 4168 |
| 4169 // static |
| 3957 void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString, | 4170 void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString, |
| 3958 CFX_ByteTextBuf& szResultBuf) { | 4171 CFX_ByteTextBuf& szResultBuf) { |
| 3959 CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString); | 4172 CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString); |
| 3960 CFX_WideTextBuf wsResultBuf; | 4173 CFX_WideTextBuf wsResultBuf; |
| 3961 FX_WCHAR ch = 0; | 4174 FX_WCHAR ch = 0; |
| 3962 int32_t iLength = wsURLString.GetLength(); | 4175 int32_t iLength = wsURLString.GetLength(); |
| 3963 FX_WCHAR strEncode[4]; | 4176 FX_WCHAR strEncode[4]; |
| 3964 strEncode[0] = '%'; | 4177 strEncode[0] = '%'; |
| 3965 strEncode[3] = 0; | 4178 strEncode[3] = 0; |
| 3966 FX_WCHAR strUnsafe[] = {' ', '<', '>', '"', '#', '%', '{', '}', | 4179 FX_WCHAR strUnsafe[] = {' ', '<', '>', '"', '#', '%', '{', '}', |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4054 iIndex -= 2; | 4267 iIndex -= 2; |
| 4055 wsResultBuf << FX_WSTRC(strEncode); | 4268 wsResultBuf << FX_WSTRC(strEncode); |
| 4056 } | 4269 } |
| 4057 } | 4270 } |
| 4058 } | 4271 } |
| 4059 wsResultBuf.AppendChar(0); | 4272 wsResultBuf.AppendChar(0); |
| 4060 szResultBuf.Clear(); | 4273 szResultBuf.Clear(); |
| 4061 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()) | 4274 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()) |
| 4062 .AsStringC(); | 4275 .AsStringC(); |
| 4063 } | 4276 } |
| 4277 |
| 4278 // static |
| 4064 void CXFA_FM2JSContext::EncodeHTML(const CFX_ByteStringC& szHTMLString, | 4279 void CXFA_FM2JSContext::EncodeHTML(const CFX_ByteStringC& szHTMLString, |
| 4065 CFX_ByteTextBuf& szResultBuf) { | 4280 CFX_ByteTextBuf& szResultBuf) { |
| 4066 CFX_ByteString str = szHTMLString.c_str(); | 4281 CFX_ByteString str = szHTMLString.c_str(); |
| 4067 CFX_WideString wsHTMLString = CFX_WideString::FromUTF8(str.AsStringC()); | 4282 CFX_WideString wsHTMLString = CFX_WideString::FromUTF8(str.AsStringC()); |
| 4068 const FX_WCHAR* strCode = L"0123456789abcdef"; | 4283 const FX_WCHAR* strCode = L"0123456789abcdef"; |
| 4069 FX_WCHAR strEncode[9]; | 4284 FX_WCHAR strEncode[9]; |
| 4070 strEncode[0] = '&'; | 4285 strEncode[0] = '&'; |
| 4071 strEncode[1] = '#'; | 4286 strEncode[1] = '#'; |
| 4072 strEncode[2] = 'x'; | 4287 strEncode[2] = 'x'; |
| 4073 strEncode[5] = ';'; | 4288 strEncode[5] = ';'; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4108 wsResultBuf << FX_WSTRC(strEncode); | 4323 wsResultBuf << FX_WSTRC(strEncode); |
| 4109 } | 4324 } |
| 4110 } | 4325 } |
| 4111 ++i; | 4326 ++i; |
| 4112 } | 4327 } |
| 4113 wsResultBuf.AppendChar(0); | 4328 wsResultBuf.AppendChar(0); |
| 4114 szResultBuf.Clear(); | 4329 szResultBuf.Clear(); |
| 4115 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()) | 4330 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()) |
| 4116 .AsStringC(); | 4331 .AsStringC(); |
| 4117 } | 4332 } |
| 4333 |
| 4334 // static |
| 4118 void CXFA_FM2JSContext::EncodeXML(const CFX_ByteStringC& szXMLString, | 4335 void CXFA_FM2JSContext::EncodeXML(const CFX_ByteStringC& szXMLString, |
| 4119 CFX_ByteTextBuf& szResultBuf) { | 4336 CFX_ByteTextBuf& szResultBuf) { |
| 4120 CFX_WideString wsXMLString = CFX_WideString::FromUTF8(szXMLString); | 4337 CFX_WideString wsXMLString = CFX_WideString::FromUTF8(szXMLString); |
| 4121 CFX_WideTextBuf wsResultBuf; | 4338 CFX_WideTextBuf wsResultBuf; |
| 4122 enum { | 4339 enum { |
| 4123 QUOT, | 4340 QUOT, |
| 4124 AMP, | 4341 AMP, |
| 4125 APOS, | 4342 APOS, |
| 4126 LT, | 4343 LT, |
| 4127 GT, | 4344 GT, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4189 wsResultBuf << FX_WSTRC(strEncode); | 4406 wsResultBuf << FX_WSTRC(strEncode); |
| 4190 } | 4407 } |
| 4191 } break; | 4408 } break; |
| 4192 } | 4409 } |
| 4193 } | 4410 } |
| 4194 wsResultBuf.AppendChar(0); | 4411 wsResultBuf.AppendChar(0); |
| 4195 szResultBuf.Clear(); | 4412 szResultBuf.Clear(); |
| 4196 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()) | 4413 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()) |
| 4197 .AsStringC(); | 4414 .AsStringC(); |
| 4198 } | 4415 } |
| 4416 |
| 4417 // static |
| 4199 FX_BOOL CXFA_FM2JSContext::HTMLSTR2Code(const CFX_WideStringC& pData, | 4418 FX_BOOL CXFA_FM2JSContext::HTMLSTR2Code(const CFX_WideStringC& pData, |
| 4200 uint32_t& iCode) { | 4419 uint32_t& iCode) { |
| 4201 uint32_t uHash = FX_HashCode_GetW(pData, false); | 4420 uint32_t uHash = FX_HashCode_GetW(pData, false); |
| 4202 int32_t iStart = 0; | 4421 int32_t iStart = 0; |
| 4203 int32_t iEnd = FX_ArraySize(reservesForDecode) - 1; | 4422 int32_t iEnd = FX_ArraySize(reservesForDecode) - 1; |
| 4204 do { | 4423 do { |
| 4205 int32_t iMid = (iStart + iEnd) / 2; | 4424 int32_t iMid = (iStart + iEnd) / 2; |
| 4206 XFA_FMHtmlHashedReserveCode htmlhashedreservecode = reservesForDecode[iMid]; | 4425 XFA_FMHtmlHashedReserveCode htmlhashedreservecode = reservesForDecode[iMid]; |
| 4207 if (uHash == htmlhashedreservecode.m_uHash) { | 4426 if (uHash == htmlhashedreservecode.m_uHash) { |
| 4208 iCode = htmlhashedreservecode.m_uCode; | 4427 iCode = htmlhashedreservecode.m_uCode; |
| 4209 return TRUE; | 4428 return TRUE; |
| 4210 } | 4429 } |
| 4211 if (uHash < htmlhashedreservecode.m_uHash) { | 4430 if (uHash < htmlhashedreservecode.m_uHash) { |
| 4212 iEnd = iMid - 1; | 4431 iEnd = iMid - 1; |
| 4213 } else { | 4432 } else { |
| 4214 iStart = iMid + 1; | 4433 iStart = iMid + 1; |
| 4215 } | 4434 } |
| 4216 } while (iStart <= iEnd); | 4435 } while (iStart <= iEnd); |
| 4217 return FALSE; | 4436 return FALSE; |
| 4218 } | 4437 } |
| 4438 |
| 4439 // static |
| 4219 FX_BOOL CXFA_FM2JSContext::HTMLCode2STR(uint32_t iCode, | 4440 FX_BOOL CXFA_FM2JSContext::HTMLCode2STR(uint32_t iCode, |
| 4220 CFX_WideString& wsHTMLReserve) { | 4441 CFX_WideString& wsHTMLReserve) { |
| 4221 XFA_FMHtmlReserveCode htmlreservecode; | 4442 XFA_FMHtmlReserveCode htmlreservecode; |
| 4222 int32_t iStart = 0, | 4443 int32_t iStart = 0, |
| 4223 iEnd = (sizeof(reservesForEncode) / sizeof(reservesForEncode[0])) - 1; | 4444 iEnd = (sizeof(reservesForEncode) / sizeof(reservesForEncode[0])) - 1; |
| 4224 int32_t iMid = (iStart + iEnd) / 2; | 4445 int32_t iMid = (iStart + iEnd) / 2; |
| 4225 do { | 4446 do { |
| 4226 iMid = (iStart + iEnd) / 2; | 4447 iMid = (iStart + iEnd) / 2; |
| 4227 htmlreservecode = reservesForEncode[iMid]; | 4448 htmlreservecode = reservesForEncode[iMid]; |
| 4228 if (iCode == htmlreservecode.m_uCode) { | 4449 if (iCode == htmlreservecode.m_uCode) { |
| 4229 wsHTMLReserve = htmlreservecode.m_htmlReserve; | 4450 wsHTMLReserve = htmlreservecode.m_htmlReserve; |
| 4230 return TRUE; | 4451 return TRUE; |
| 4231 } else if (iCode < htmlreservecode.m_uCode) { | 4452 } else if (iCode < htmlreservecode.m_uCode) { |
| 4232 iEnd = iMid - 1; | 4453 iEnd = iMid - 1; |
| 4233 } else { | 4454 } else { |
| 4234 iStart = iMid + 1; | 4455 iStart = iMid + 1; |
| 4235 } | 4456 } |
| 4236 } while (iStart <= iEnd); | 4457 } while (iStart <= iEnd); |
| 4237 return FALSE; | 4458 return FALSE; |
| 4238 } | 4459 } |
| 4239 static FX_BOOL XFA_PATTERN_STRING_Type(const CFX_ByteStringC& szPattern, | 4460 |
| 4240 uint32_t& patternType) { | 4461 // static |
| 4241 CFX_WideString wsPattern = CFX_WideString::FromUTF8(szPattern); | |
| 4242 if (FX_WSTRC(L"datetime") == wsPattern.Left(8)) { | |
| 4243 patternType = XFA_VT_DATETIME; | |
| 4244 return TRUE; | |
| 4245 } else if (FX_WSTRC(L"date") == wsPattern.Left(4)) { | |
| 4246 patternType = wsPattern.Find(L"time") > 0 ? XFA_VT_DATETIME : XFA_VT_DATE; | |
| 4247 return TRUE; | |
| 4248 } else if (FX_WSTRC(L"time") == wsPattern.Left(4)) { | |
| 4249 patternType = XFA_VT_TIME; | |
| 4250 return TRUE; | |
| 4251 } else if (FX_WSTRC(L"text") == wsPattern.Left(4)) { | |
| 4252 patternType = XFA_VT_TEXT; | |
| 4253 return TRUE; | |
| 4254 } else if (FX_WSTRC(L"num") == wsPattern.Left(3)) { | |
| 4255 if (FX_WSTRC(L"integer") == wsPattern.Mid(4, 7)) { | |
| 4256 patternType = XFA_VT_INTEGER; | |
| 4257 } else if (FX_WSTRC(L"decimal") == wsPattern.Mid(4, 7)) { | |
| 4258 patternType = XFA_VT_DECIMAL; | |
| 4259 } else if (FX_WSTRC(L"currency") == wsPattern.Mid(4, 8)) { | |
| 4260 patternType = XFA_VT_FLOAT; | |
| 4261 } else if (FX_WSTRC(L"percent") == wsPattern.Mid(4, 7)) { | |
| 4262 patternType = XFA_VT_FLOAT; | |
| 4263 } else { | |
| 4264 patternType = XFA_VT_FLOAT; | |
| 4265 } | |
| 4266 return TRUE; | |
| 4267 } | |
| 4268 patternType = XFA_VT_NULL; | |
| 4269 wsPattern.MakeLower(); | |
| 4270 const FX_WCHAR* pData = wsPattern.c_str(); | |
| 4271 int32_t iLength = wsPattern.GetLength(); | |
| 4272 int32_t iIndex = 0; | |
| 4273 FX_BOOL bSingleQuotation = FALSE; | |
| 4274 FX_WCHAR patternChar; | |
| 4275 while (iIndex < iLength) { | |
| 4276 patternChar = *(pData + iIndex); | |
| 4277 if (patternChar == 0x27) { | |
| 4278 bSingleQuotation = !bSingleQuotation; | |
| 4279 } else if (!bSingleQuotation && | |
| 4280 (patternChar == 'y' || patternChar == 'j')) { | |
| 4281 patternType = XFA_VT_DATE; | |
| 4282 iIndex++; | |
| 4283 FX_WCHAR timePatternChar; | |
| 4284 while (iIndex < iLength) { | |
| 4285 timePatternChar = *(pData + iIndex); | |
| 4286 if (timePatternChar == 0x27) { | |
| 4287 bSingleQuotation = !bSingleQuotation; | |
| 4288 } else if (!bSingleQuotation && timePatternChar == 't') { | |
| 4289 patternType = XFA_VT_DATETIME; | |
| 4290 break; | |
| 4291 } | |
| 4292 iIndex++; | |
| 4293 } | |
| 4294 break; | |
| 4295 } else if (!bSingleQuotation && | |
| 4296 (patternChar == 'h' || patternChar == 'k')) { | |
| 4297 patternType = XFA_VT_TIME; | |
| 4298 break; | |
| 4299 } else if (!bSingleQuotation && | |
| 4300 (patternChar == 'a' || patternChar == 'x' || | |
| 4301 patternChar == 'o' || patternChar == '0')) { | |
| 4302 patternType = XFA_VT_TEXT; | |
| 4303 if (patternChar == 'x' || patternChar == 'o' || patternChar == '0') { | |
| 4304 break; | |
| 4305 } | |
| 4306 } else if (!bSingleQuotation && | |
| 4307 (patternChar == 'z' || patternChar == 's' || | |
| 4308 patternChar == 'e' || patternChar == 'v' || | |
| 4309 patternChar == '8' || patternChar == ',' || | |
| 4310 patternChar == '.' || patternChar == '$')) { | |
| 4311 patternType = XFA_VT_FLOAT; | |
| 4312 if (patternChar == 'v' || patternChar == '8' || patternChar == '$') { | |
| 4313 break; | |
| 4314 } | |
| 4315 } | |
| 4316 iIndex++; | |
| 4317 } | |
| 4318 if (patternType == XFA_VT_NULL) { | |
| 4319 patternType = XFA_VT_TEXT | XFA_VT_FLOAT; | |
| 4320 } | |
| 4321 return FALSE; | |
| 4322 } | |
| 4323 void CXFA_FM2JSContext::Format(CFXJSE_Value* pThis, | 4462 void CXFA_FM2JSContext::Format(CFXJSE_Value* pThis, |
| 4324 const CFX_ByteStringC& szFuncName, | 4463 const CFX_ByteStringC& szFuncName, |
| 4325 CFXJSE_Arguments& args) { | 4464 CFXJSE_Arguments& args) { |
| 4326 CXFA_FM2JSContext* pContext = | 4465 CXFA_FM2JSContext* pContext = |
| 4327 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 4466 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 4328 int32_t argc = args.GetLength(); | 4467 if (args.GetLength() >= 2) { |
| 4329 if (argc >= 2) { | |
| 4330 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4468 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 4331 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | 4469 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
| 4332 CFX_ByteString szPattern; | 4470 CFX_ByteString szPattern; |
| 4333 ValueToUTF8String(argOne.get(), szPattern); | 4471 ValueToUTF8String(argOne.get(), szPattern); |
| 4334 CFX_ByteString szValue; | 4472 CFX_ByteString szValue; |
| 4335 ValueToUTF8String(argTwo.get(), szValue); | 4473 ValueToUTF8String(argTwo.get(), szValue); |
| 4336 CXFA_Document* pDoc = pContext->GetDocument(); | 4474 CXFA_Document* pDoc = pContext->GetDocument(); |
| 4337 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 4475 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 4338 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 4476 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 4339 ASSERT(pThisNode); | 4477 ASSERT(pThisNode); |
| 4340 CXFA_WidgetData widgetData(pThisNode); | 4478 CXFA_WidgetData widgetData(pThisNode); |
| 4341 IFX_Locale* pLocale = widgetData.GetLocal(); | 4479 IFX_Locale* pLocale = widgetData.GetLocal(); |
| 4342 uint32_t patternType; | 4480 uint32_t patternType; |
| 4343 FX_BOOL bCompelte = | |
| 4344 XFA_PATTERN_STRING_Type(szPattern.AsStringC(), patternType); | |
| 4345 CFX_WideString wsPattern = CFX_WideString::FromUTF8(szPattern.AsStringC()); | 4481 CFX_WideString wsPattern = CFX_WideString::FromUTF8(szPattern.AsStringC()); |
| 4346 CFX_WideString wsValue = CFX_WideString::FromUTF8(szValue.AsStringC()); | 4482 CFX_WideString wsValue = CFX_WideString::FromUTF8(szValue.AsStringC()); |
| 4347 if (!bCompelte) { | 4483 if (!PatternStringType(szPattern.AsStringC(), patternType)) { |
| 4348 switch (patternType) { | 4484 switch (patternType) { |
| 4349 case XFA_VT_DATETIME: { | 4485 case XFA_VT_DATETIME: { |
| 4350 FX_STRSIZE iTChar = wsPattern.Find(L'T'); | 4486 FX_STRSIZE iTChar = wsPattern.Find(L'T'); |
| 4351 CFX_WideString wsDatePattern(L"date{"); | 4487 CFX_WideString wsDatePattern(L"date{"); |
| 4352 wsDatePattern += wsPattern.Left(iTChar); | 4488 wsDatePattern += wsPattern.Left(iTChar); |
| 4353 wsDatePattern += FX_WSTRC(L"} "); | 4489 wsDatePattern += FX_WSTRC(L"} "); |
| 4354 CFX_WideString wsTimePattern(L"time{"); | 4490 CFX_WideString wsTimePattern(L"time{"); |
| 4355 wsTimePattern += wsPattern.Mid(iTChar + 1); | 4491 wsTimePattern += wsPattern.Mid(iTChar + 1); |
| 4356 wsTimePattern += FX_WSTRC(L"}"); | 4492 wsTimePattern += FX_WSTRC(L"}"); |
| 4357 wsPattern = wsDatePattern + wsTimePattern; | 4493 wsPattern = wsDatePattern + wsTimePattern; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4399 args.GetReturnValue(), | 4535 args.GetReturnValue(), |
| 4400 FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()).AsStringC()); | 4536 FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()).AsStringC()); |
| 4401 } else { | 4537 } else { |
| 4402 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 4538 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
| 4403 } | 4539 } |
| 4404 } else { | 4540 } else { |
| 4405 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4541 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4406 L"Format"); | 4542 L"Format"); |
| 4407 } | 4543 } |
| 4408 } | 4544 } |
| 4545 |
| 4546 // static |
| 4409 void CXFA_FM2JSContext::Left(CFXJSE_Value* pThis, | 4547 void CXFA_FM2JSContext::Left(CFXJSE_Value* pThis, |
| 4410 const CFX_ByteStringC& szFuncName, | 4548 const CFX_ByteStringC& szFuncName, |
| 4411 CFXJSE_Arguments& args) { | 4549 CFXJSE_Arguments& args) { |
| 4412 CXFA_FM2JSContext* pContext = | |
| 4413 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
| 4414 if (args.GetLength() == 2) { | 4550 if (args.GetLength() == 2) { |
| 4415 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4551 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 4416 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | 4552 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
| 4417 FX_BOOL argIsNull = FALSE; | 4553 FX_BOOL argIsNull = FALSE; |
| 4418 if ((ValueIsNull(pThis, argOne.get())) || | 4554 if ((ValueIsNull(pThis, argOne.get())) || |
| 4419 (ValueIsNull(pThis, argTwo.get()))) { | 4555 (ValueIsNull(pThis, argTwo.get()))) { |
| 4420 argIsNull = TRUE; | 4556 argIsNull = TRUE; |
| 4421 } | 4557 } |
| 4422 if (argIsNull) { | 4558 if (argIsNull) { |
| 4423 FXJSE_Value_SetNull(args.GetReturnValue()); | 4559 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4424 } else { | 4560 } else { |
| 4425 CFX_ByteString sourceString; | 4561 CFX_ByteString sourceString; |
| 4426 ValueToUTF8String(argOne.get(), sourceString); | 4562 ValueToUTF8String(argOne.get(), sourceString); |
| 4427 int32_t count = ValueToInteger(pThis, argTwo.get()); | 4563 int32_t count = ValueToInteger(pThis, argTwo.get()); |
| 4428 if (count < 0) { | 4564 if (count < 0) { |
| 4429 count = 0; | 4565 count = 0; |
| 4430 } | 4566 } |
| 4431 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 4567 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 4432 sourceString.Left(count).AsStringC()); | 4568 sourceString.Left(count).AsStringC()); |
| 4433 } | 4569 } |
| 4434 } else { | 4570 } else { |
| 4571 CXFA_FM2JSContext* pContext = |
| 4572 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 4435 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4573 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4436 L"Left"); | 4574 L"Left"); |
| 4437 } | 4575 } |
| 4438 } | 4576 } |
| 4577 |
| 4578 // static |
| 4439 void CXFA_FM2JSContext::Len(CFXJSE_Value* pThis, | 4579 void CXFA_FM2JSContext::Len(CFXJSE_Value* pThis, |
| 4440 const CFX_ByteStringC& szFuncName, | 4580 const CFX_ByteStringC& szFuncName, |
| 4441 CFXJSE_Arguments& args) { | 4581 CFXJSE_Arguments& args) { |
| 4442 CXFA_FM2JSContext* pContext = | |
| 4443 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
| 4444 if (args.GetLength() == 1) { | 4582 if (args.GetLength() == 1) { |
| 4445 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4583 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 4446 if (ValueIsNull(pThis, argOne.get())) { | 4584 if (ValueIsNull(pThis, argOne.get())) { |
| 4447 FXJSE_Value_SetNull(args.GetReturnValue()); | 4585 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4448 } else { | 4586 } else { |
| 4449 CFX_ByteString sourceString; | 4587 CFX_ByteString sourceString; |
| 4450 ValueToUTF8String(argOne.get(), sourceString); | 4588 ValueToUTF8String(argOne.get(), sourceString); |
| 4451 FXJSE_Value_SetInteger(args.GetReturnValue(), sourceString.GetLength()); | 4589 FXJSE_Value_SetInteger(args.GetReturnValue(), sourceString.GetLength()); |
| 4452 } | 4590 } |
| 4453 } else { | 4591 } else { |
| 4592 CXFA_FM2JSContext* pContext = |
| 4593 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 4454 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4594 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4455 L"Len"); | 4595 L"Len"); |
| 4456 } | 4596 } |
| 4457 } | 4597 } |
| 4598 |
| 4599 // static |
| 4458 void CXFA_FM2JSContext::Lower(CFXJSE_Value* pThis, | 4600 void CXFA_FM2JSContext::Lower(CFXJSE_Value* pThis, |
| 4459 const CFX_ByteStringC& szFuncName, | 4601 const CFX_ByteStringC& szFuncName, |
| 4460 CFXJSE_Arguments& args) { | 4602 CFXJSE_Arguments& args) { |
| 4461 int32_t argc = args.GetLength(); | 4603 int32_t argc = args.GetLength(); |
| 4462 if ((argc > 0) && (argc < 3)) { | 4604 if ((argc > 0) && (argc < 3)) { |
| 4463 CFX_ByteString argString; | 4605 CFX_ByteString argString; |
| 4464 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4606 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 4465 if (ValueIsNull(pThis, argOne.get())) { | 4607 if (ValueIsNull(pThis, argOne.get())) { |
| 4466 FXJSE_Value_SetNull(args.GetReturnValue()); | 4608 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4467 } else { | 4609 } else { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 4491 FX_UTF8Encode(lowStringBuf.GetBuffer(), lowStringBuf.GetLength()) | 4633 FX_UTF8Encode(lowStringBuf.GetBuffer(), lowStringBuf.GetLength()) |
| 4492 .AsStringC()); | 4634 .AsStringC()); |
| 4493 } | 4635 } |
| 4494 } else { | 4636 } else { |
| 4495 CXFA_FM2JSContext* pContext = | 4637 CXFA_FM2JSContext* pContext = |
| 4496 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 4638 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 4497 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4639 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4498 L"Lower"); | 4640 L"Lower"); |
| 4499 } | 4641 } |
| 4500 } | 4642 } |
| 4643 |
| 4644 // static |
| 4501 void CXFA_FM2JSContext::Ltrim(CFXJSE_Value* pThis, | 4645 void CXFA_FM2JSContext::Ltrim(CFXJSE_Value* pThis, |
| 4502 const CFX_ByteStringC& szFuncName, | 4646 const CFX_ByteStringC& szFuncName, |
| 4503 CFXJSE_Arguments& args) { | 4647 CFXJSE_Arguments& args) { |
| 4504 CXFA_FM2JSContext* pContext = | |
| 4505 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
| 4506 if (args.GetLength() == 1) { | 4648 if (args.GetLength() == 1) { |
| 4507 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4649 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 4508 if (ValueIsNull(pThis, argOne.get())) { | 4650 if (ValueIsNull(pThis, argOne.get())) { |
| 4509 FXJSE_Value_SetNull(args.GetReturnValue()); | 4651 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4510 } else { | 4652 } else { |
| 4511 CFX_ByteString sourceString; | 4653 CFX_ByteString sourceString; |
| 4512 ValueToUTF8String(argOne.get(), sourceString); | 4654 ValueToUTF8String(argOne.get(), sourceString); |
| 4513 sourceString.TrimLeft(); | 4655 sourceString.TrimLeft(); |
| 4514 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 4656 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 4515 sourceString.AsStringC()); | 4657 sourceString.AsStringC()); |
| 4516 } | 4658 } |
| 4517 } else { | 4659 } else { |
| 4660 CXFA_FM2JSContext* pContext = |
| 4661 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 4518 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4662 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4519 L"Ltrim"); | 4663 L"Ltrim"); |
| 4520 } | 4664 } |
| 4521 } | 4665 } |
| 4666 |
| 4667 // static |
| 4522 void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis, | 4668 void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis, |
| 4523 const CFX_ByteStringC& szFuncName, | 4669 const CFX_ByteStringC& szFuncName, |
| 4524 CFXJSE_Arguments& args) { | 4670 CFXJSE_Arguments& args) { |
| 4525 CXFA_FM2JSContext* pContext = | 4671 CXFA_FM2JSContext* pContext = |
| 4526 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 4672 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 4527 if (args.GetLength() == 2) { | 4673 if (args.GetLength() == 2) { |
| 4528 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4674 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 4529 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | 4675 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
| 4530 if (ValueIsNull(pThis, argTwo.get())) { | 4676 if (ValueIsNull(pThis, argTwo.get())) { |
| 4531 FXJSE_Value_SetNull(args.GetReturnValue()); | 4677 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4532 } else { | 4678 } else { |
| 4533 CFX_ByteString szPattern; | 4679 CFX_ByteString szPattern; |
| 4534 ValueToUTF8String(argOne.get(), szPattern); | 4680 ValueToUTF8String(argOne.get(), szPattern); |
| 4535 CFX_ByteString szValue; | 4681 CFX_ByteString szValue; |
| 4536 ValueToUTF8String(argTwo.get(), szValue); | 4682 ValueToUTF8String(argTwo.get(), szValue); |
| 4537 CXFA_Document* pDoc = pContext->GetDocument(); | 4683 CXFA_Document* pDoc = pContext->GetDocument(); |
| 4538 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 4684 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
| 4539 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 4685 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
| 4540 ASSERT(pThisNode); | 4686 ASSERT(pThisNode); |
| 4541 CXFA_WidgetData widgetData(pThisNode); | 4687 CXFA_WidgetData widgetData(pThisNode); |
| 4542 IFX_Locale* pLocale = widgetData.GetLocal(); | 4688 IFX_Locale* pLocale = widgetData.GetLocal(); |
| 4543 uint32_t patternType; | 4689 uint32_t patternType; |
| 4544 FX_BOOL bCompletePattern = | |
| 4545 XFA_PATTERN_STRING_Type(szPattern.AsStringC(), patternType); | |
| 4546 CFX_WideString wsPattern = | 4690 CFX_WideString wsPattern = |
| 4547 CFX_WideString::FromUTF8(szPattern.AsStringC()); | 4691 CFX_WideString::FromUTF8(szPattern.AsStringC()); |
| 4548 CFX_WideString wsValue = CFX_WideString::FromUTF8(szValue.AsStringC()); | 4692 CFX_WideString wsValue = CFX_WideString::FromUTF8(szValue.AsStringC()); |
| 4549 CFX_ByteString szParsedValue; | 4693 CFX_ByteString szParsedValue; |
| 4550 if (bCompletePattern) { | 4694 if (PatternStringType(szPattern.AsStringC(), patternType)) { |
| 4551 CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, pLocale, | 4695 CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, pLocale, |
| 4552 (CXFA_LocaleMgr*)pMgr); | 4696 (CXFA_LocaleMgr*)pMgr); |
| 4553 if (localeValue.IsValid()) { | 4697 if (localeValue.IsValid()) { |
| 4554 szParsedValue = FX_UTF8Encode(localeValue.GetValue()); | 4698 szParsedValue = FX_UTF8Encode(localeValue.GetValue()); |
| 4555 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 4699 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 4556 szParsedValue.AsStringC()); | 4700 szParsedValue.AsStringC()); |
| 4557 } else { | 4701 } else { |
| 4558 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 4702 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
| 4559 } | 4703 } |
| 4560 } else { | 4704 } else { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4653 } | 4797 } |
| 4654 } break; | 4798 } break; |
| 4655 } | 4799 } |
| 4656 } | 4800 } |
| 4657 } | 4801 } |
| 4658 } else { | 4802 } else { |
| 4659 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4803 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4660 L"Parse"); | 4804 L"Parse"); |
| 4661 } | 4805 } |
| 4662 } | 4806 } |
| 4807 |
| 4808 // static |
| 4663 void CXFA_FM2JSContext::Replace(CFXJSE_Value* pThis, | 4809 void CXFA_FM2JSContext::Replace(CFXJSE_Value* pThis, |
| 4664 const CFX_ByteStringC& szFuncName, | 4810 const CFX_ByteStringC& szFuncName, |
| 4665 CFXJSE_Arguments& args) { | 4811 CFXJSE_Arguments& args) { |
| 4666 int32_t argc = args.GetLength(); | 4812 int32_t argc = args.GetLength(); |
| 4667 if ((argc == 2) || (argc == 3)) { | 4813 if ((argc == 2) || (argc == 3)) { |
| 4668 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4814 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 4669 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | 4815 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
| 4670 CFX_ByteString oneString; | 4816 CFX_ByteString oneString; |
| 4671 CFX_ByteString twoString; | 4817 CFX_ByteString twoString; |
| 4672 CFX_ByteString threeString; | 4818 CFX_ByteString threeString; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4713 } | 4859 } |
| 4714 resultString.AppendChar(0); | 4860 resultString.AppendChar(0); |
| 4715 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); | 4861 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); |
| 4716 } else { | 4862 } else { |
| 4717 CXFA_FM2JSContext* pContext = | 4863 CXFA_FM2JSContext* pContext = |
| 4718 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 4864 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 4719 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4865 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4720 L"Replace"); | 4866 L"Replace"); |
| 4721 } | 4867 } |
| 4722 } | 4868 } |
| 4869 |
| 4870 // static |
| 4723 void CXFA_FM2JSContext::Right(CFXJSE_Value* pThis, | 4871 void CXFA_FM2JSContext::Right(CFXJSE_Value* pThis, |
| 4724 const CFX_ByteStringC& szFuncName, | 4872 const CFX_ByteStringC& szFuncName, |
| 4725 CFXJSE_Arguments& args) { | 4873 CFXJSE_Arguments& args) { |
| 4726 CXFA_FM2JSContext* pContext = | |
| 4727 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
| 4728 if (args.GetLength() == 2) { | 4874 if (args.GetLength() == 2) { |
| 4729 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4875 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 4730 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | 4876 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
| 4731 FX_BOOL argIsNull = FALSE; | 4877 FX_BOOL argIsNull = FALSE; |
| 4732 if ((ValueIsNull(pThis, argOne.get())) || | 4878 if ((ValueIsNull(pThis, argOne.get())) || |
| 4733 (ValueIsNull(pThis, argTwo.get()))) { | 4879 (ValueIsNull(pThis, argTwo.get()))) { |
| 4734 argIsNull = TRUE; | 4880 argIsNull = TRUE; |
| 4735 } | 4881 } |
| 4736 if (argIsNull) { | 4882 if (argIsNull) { |
| 4737 FXJSE_Value_SetNull(args.GetReturnValue()); | 4883 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4738 } else { | 4884 } else { |
| 4739 CFX_ByteString sourceString; | 4885 CFX_ByteString sourceString; |
| 4740 ValueToUTF8String(argOne.get(), sourceString); | 4886 ValueToUTF8String(argOne.get(), sourceString); |
| 4741 int32_t count = ValueToInteger(pThis, argTwo.get()); | 4887 int32_t count = ValueToInteger(pThis, argTwo.get()); |
| 4742 if (count < 0) { | 4888 if (count < 0) { |
| 4743 count = 0; | 4889 count = 0; |
| 4744 } | 4890 } |
| 4745 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 4891 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 4746 sourceString.Right(count).AsStringC()); | 4892 sourceString.Right(count).AsStringC()); |
| 4747 } | 4893 } |
| 4748 } else { | 4894 } else { |
| 4895 CXFA_FM2JSContext* pContext = |
| 4896 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 4749 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4897 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4750 L"Right"); | 4898 L"Right"); |
| 4751 } | 4899 } |
| 4752 } | 4900 } |
| 4901 |
| 4902 // static |
| 4753 void CXFA_FM2JSContext::Rtrim(CFXJSE_Value* pThis, | 4903 void CXFA_FM2JSContext::Rtrim(CFXJSE_Value* pThis, |
| 4754 const CFX_ByteStringC& szFuncName, | 4904 const CFX_ByteStringC& szFuncName, |
| 4755 CFXJSE_Arguments& args) { | 4905 CFXJSE_Arguments& args) { |
| 4756 CXFA_FM2JSContext* pContext = | |
| 4757 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
| 4758 if (args.GetLength() == 1) { | 4906 if (args.GetLength() == 1) { |
| 4759 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4907 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 4760 if (ValueIsNull(pThis, argOne.get())) { | 4908 if (ValueIsNull(pThis, argOne.get())) { |
| 4761 FXJSE_Value_SetNull(args.GetReturnValue()); | 4909 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4762 } else { | 4910 } else { |
| 4763 CFX_ByteString sourceString; | 4911 CFX_ByteString sourceString; |
| 4764 ValueToUTF8String(argOne.get(), sourceString); | 4912 ValueToUTF8String(argOne.get(), sourceString); |
| 4765 sourceString.TrimRight(); | 4913 sourceString.TrimRight(); |
| 4766 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 4914 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 4767 sourceString.AsStringC()); | 4915 sourceString.AsStringC()); |
| 4768 } | 4916 } |
| 4769 } else { | 4917 } else { |
| 4918 CXFA_FM2JSContext* pContext = |
| 4919 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 4770 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4920 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4771 L"Rtrim"); | 4921 L"Rtrim"); |
| 4772 } | 4922 } |
| 4773 } | 4923 } |
| 4924 |
| 4925 // static |
| 4774 void CXFA_FM2JSContext::Space(CFXJSE_Value* pThis, | 4926 void CXFA_FM2JSContext::Space(CFXJSE_Value* pThis, |
| 4775 const CFX_ByteStringC& szFuncName, | 4927 const CFX_ByteStringC& szFuncName, |
| 4776 CFXJSE_Arguments& args) { | 4928 CFXJSE_Arguments& args) { |
| 4777 CXFA_FM2JSContext* pContext = | |
| 4778 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
| 4779 if (args.GetLength() == 1) { | 4929 if (args.GetLength() == 1) { |
| 4780 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4930 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 4781 if (FXJSE_Value_IsNull(argOne.get())) { | 4931 if (FXJSE_Value_IsNull(argOne.get())) { |
| 4782 FXJSE_Value_SetNull(args.GetReturnValue()); | 4932 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4783 } else { | 4933 } else { |
| 4784 int32_t count = 0; | 4934 int32_t count = 0; |
| 4785 count = ValueToInteger(pThis, argOne.get()); | 4935 count = ValueToInteger(pThis, argOne.get()); |
| 4786 count = (count < 0) ? 0 : count; | 4936 count = (count < 0) ? 0 : count; |
| 4787 CFX_ByteTextBuf spaceString; | 4937 CFX_ByteTextBuf spaceString; |
| 4788 int32_t index = 0; | 4938 int32_t index = 0; |
| 4789 while (index < count) { | 4939 while (index < count) { |
| 4790 spaceString.AppendByte(' '); | 4940 spaceString.AppendByte(' '); |
| 4791 index++; | 4941 index++; |
| 4792 } | 4942 } |
| 4793 spaceString.AppendByte(0); | 4943 spaceString.AppendByte(0); |
| 4794 FXJSE_Value_SetUTF8String(args.GetReturnValue(), spaceString.AsStringC()); | 4944 FXJSE_Value_SetUTF8String(args.GetReturnValue(), spaceString.AsStringC()); |
| 4795 } | 4945 } |
| 4796 } else { | 4946 } else { |
| 4947 CXFA_FM2JSContext* pContext = |
| 4948 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 4797 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4949 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4798 L"Space"); | 4950 L"Space"); |
| 4799 } | 4951 } |
| 4800 } | 4952 } |
| 4953 |
| 4954 // static |
| 4801 void CXFA_FM2JSContext::Str(CFXJSE_Value* pThis, | 4955 void CXFA_FM2JSContext::Str(CFXJSE_Value* pThis, |
| 4802 const CFX_ByteStringC& szFuncName, | 4956 const CFX_ByteStringC& szFuncName, |
| 4803 CFXJSE_Arguments& args) { | 4957 CFXJSE_Arguments& args) { |
| 4804 int32_t argc = args.GetLength(); | 4958 int32_t argc = args.GetLength(); |
| 4805 if ((argc > 0) && (argc < 4)) { | 4959 if ((argc > 0) && (argc < 4)) { |
| 4806 FX_BOOL bFlags = FALSE; | 4960 FX_BOOL bFlags = FALSE; |
| 4807 FX_FLOAT fNumber = 0.0f; | 4961 FX_FLOAT fNumber = 0.0f; |
| 4808 int32_t iWidth = 10; | 4962 int32_t iWidth = 10; |
| 4809 int32_t iPrecision = 0; | 4963 int32_t iPrecision = 0; |
| 4810 std::unique_ptr<CFXJSE_Value> numberValue = GetSimpleValue(pThis, args, 0); | 4964 std::unique_ptr<CFXJSE_Value> numberValue = GetSimpleValue(pThis, args, 0); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4909 } else { | 5063 } else { |
| 4910 FXJSE_Value_SetNull(args.GetReturnValue()); | 5064 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4911 } | 5065 } |
| 4912 } else { | 5066 } else { |
| 4913 CXFA_FM2JSContext* pContext = | 5067 CXFA_FM2JSContext* pContext = |
| 4914 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5068 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 4915 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5069 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4916 L"Str"); | 5070 L"Str"); |
| 4917 } | 5071 } |
| 4918 } | 5072 } |
| 5073 |
| 5074 // static |
| 4919 void CXFA_FM2JSContext::Stuff(CFXJSE_Value* pThis, | 5075 void CXFA_FM2JSContext::Stuff(CFXJSE_Value* pThis, |
| 4920 const CFX_ByteStringC& szFuncName, | 5076 const CFX_ByteStringC& szFuncName, |
| 4921 CFXJSE_Arguments& args) { | 5077 CFXJSE_Arguments& args) { |
| 4922 int32_t argc = args.GetLength(); | 5078 int32_t argc = args.GetLength(); |
| 4923 if ((argc == 3) || (argc == 4)) { | 5079 if ((argc == 3) || (argc == 4)) { |
| 4924 CFX_ByteString sourceString; | 5080 CFX_ByteString sourceString; |
| 4925 CFX_ByteString insertString; | 5081 CFX_ByteString insertString; |
| 4926 int32_t iLength = 0; | 5082 int32_t iLength = 0; |
| 4927 int32_t iStart = 0; | 5083 int32_t iStart = 0; |
| 4928 int32_t iDelete = 0; | 5084 int32_t iDelete = 0; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4966 } | 5122 } |
| 4967 resultString.AppendChar(0); | 5123 resultString.AppendChar(0); |
| 4968 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); | 5124 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); |
| 4969 } else { | 5125 } else { |
| 4970 CXFA_FM2JSContext* pContext = | 5126 CXFA_FM2JSContext* pContext = |
| 4971 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5127 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 4972 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5128 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 4973 L"Stuff"); | 5129 L"Stuff"); |
| 4974 } | 5130 } |
| 4975 } | 5131 } |
| 5132 |
| 5133 // static |
| 4976 void CXFA_FM2JSContext::Substr(CFXJSE_Value* pThis, | 5134 void CXFA_FM2JSContext::Substr(CFXJSE_Value* pThis, |
| 4977 const CFX_ByteStringC& szFuncName, | 5135 const CFX_ByteStringC& szFuncName, |
| 4978 CFXJSE_Arguments& args) { | 5136 CFXJSE_Arguments& args) { |
| 4979 int32_t argc = args.GetLength(); | 5137 if (args.GetLength() == 3) { |
| 4980 if (argc == 3) { | |
| 4981 std::unique_ptr<CFXJSE_Value> stringValue = GetSimpleValue(pThis, args, 0); | 5138 std::unique_ptr<CFXJSE_Value> stringValue = GetSimpleValue(pThis, args, 0); |
| 4982 std::unique_ptr<CFXJSE_Value> startValue = GetSimpleValue(pThis, args, 1); | 5139 std::unique_ptr<CFXJSE_Value> startValue = GetSimpleValue(pThis, args, 1); |
| 4983 std::unique_ptr<CFXJSE_Value> endValue = GetSimpleValue(pThis, args, 2); | 5140 std::unique_ptr<CFXJSE_Value> endValue = GetSimpleValue(pThis, args, 2); |
| 4984 if (ValueIsNull(pThis, stringValue.get()) || | 5141 if (ValueIsNull(pThis, stringValue.get()) || |
| 4985 (ValueIsNull(pThis, startValue.get())) || | 5142 (ValueIsNull(pThis, startValue.get())) || |
| 4986 (ValueIsNull(pThis, endValue.get()))) { | 5143 (ValueIsNull(pThis, endValue.get()))) { |
| 4987 FXJSE_Value_SetNull(args.GetReturnValue()); | 5144 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 4988 } else { | 5145 } else { |
| 4989 CFX_ByteString szSourceStr; | 5146 CFX_ByteString szSourceStr; |
| 4990 int32_t iStart = 0; | 5147 int32_t iStart = 0; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 5010 szSourceStr.Mid(iStart, iCount).AsStringC()); | 5167 szSourceStr.Mid(iStart, iCount).AsStringC()); |
| 5011 } | 5168 } |
| 5012 } | 5169 } |
| 5013 } else { | 5170 } else { |
| 5014 CXFA_FM2JSContext* pContext = | 5171 CXFA_FM2JSContext* pContext = |
| 5015 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5172 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5016 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5173 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5017 L"Substr"); | 5174 L"Substr"); |
| 5018 } | 5175 } |
| 5019 } | 5176 } |
| 5177 |
| 5178 // static |
| 5020 void CXFA_FM2JSContext::Uuid(CFXJSE_Value* pThis, | 5179 void CXFA_FM2JSContext::Uuid(CFXJSE_Value* pThis, |
| 5021 const CFX_ByteStringC& szFuncName, | 5180 const CFX_ByteStringC& szFuncName, |
| 5022 CFXJSE_Arguments& args) { | 5181 CFXJSE_Arguments& args) { |
| 5023 int32_t argc = args.GetLength(); | 5182 int32_t argc = args.GetLength(); |
| 5024 if ((argc == 0) || (argc == 1)) { | 5183 if ((argc == 0) || (argc == 1)) { |
| 5025 int32_t iNum = 0; | 5184 int32_t iNum = 0; |
| 5026 if (argc == 1) { | 5185 if (argc == 1) { |
| 5027 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 5186 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 5028 iNum = (int32_t)ValueToFloat(pThis, argOne.get()); | 5187 iNum = (int32_t)ValueToFloat(pThis, argOne.get()); |
| 5029 } | 5188 } |
| 5030 FX_GUID guid; | 5189 FX_GUID guid; |
| 5031 FX_GUID_CreateV4(&guid); | 5190 FX_GUID_CreateV4(&guid); |
| 5032 CFX_ByteString bsUId; | 5191 CFX_ByteString bsUId; |
| 5033 FX_GUID_ToString(&guid, bsUId, iNum); | 5192 FX_GUID_ToString(&guid, bsUId, iNum); |
| 5034 FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsUId.AsStringC()); | 5193 FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsUId.AsStringC()); |
| 5035 } else { | 5194 } else { |
| 5036 CXFA_FM2JSContext* pContext = | 5195 CXFA_FM2JSContext* pContext = |
| 5037 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5196 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5038 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5197 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5039 L"Uuid"); | 5198 L"Uuid"); |
| 5040 } | 5199 } |
| 5041 } | 5200 } |
| 5201 |
| 5202 // static |
| 5042 void CXFA_FM2JSContext::Upper(CFXJSE_Value* pThis, | 5203 void CXFA_FM2JSContext::Upper(CFXJSE_Value* pThis, |
| 5043 const CFX_ByteStringC& szFuncName, | 5204 const CFX_ByteStringC& szFuncName, |
| 5044 CFXJSE_Arguments& args) { | 5205 CFXJSE_Arguments& args) { |
| 5045 int32_t argc = args.GetLength(); | 5206 int32_t argc = args.GetLength(); |
| 5046 if ((argc > 0) && (argc < 3)) { | 5207 if ((argc > 0) && (argc < 3)) { |
| 5047 CFX_ByteString argString; | 5208 CFX_ByteString argString; |
| 5048 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 5209 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 5049 if (ValueIsNull(pThis, argOne.get())) { | 5210 if (ValueIsNull(pThis, argOne.get())) { |
| 5050 FXJSE_Value_SetNull(args.GetReturnValue()); | 5211 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5051 } else { | 5212 } else { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 5075 FX_UTF8Encode(upperStringBuf.GetBuffer(), upperStringBuf.GetLength()) | 5236 FX_UTF8Encode(upperStringBuf.GetBuffer(), upperStringBuf.GetLength()) |
| 5076 .AsStringC()); | 5237 .AsStringC()); |
| 5077 } | 5238 } |
| 5078 } else { | 5239 } else { |
| 5079 CXFA_FM2JSContext* pContext = | 5240 CXFA_FM2JSContext* pContext = |
| 5080 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5241 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5081 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5242 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5082 L"Upper"); | 5243 L"Upper"); |
| 5083 } | 5244 } |
| 5084 } | 5245 } |
| 5246 |
| 5247 // static |
| 5085 void CXFA_FM2JSContext::WordNum(CFXJSE_Value* pThis, | 5248 void CXFA_FM2JSContext::WordNum(CFXJSE_Value* pThis, |
| 5086 const CFX_ByteStringC& szFuncName, | 5249 const CFX_ByteStringC& szFuncName, |
| 5087 CFXJSE_Arguments& args) { | 5250 CFXJSE_Arguments& args) { |
| 5088 int32_t argc = args.GetLength(); | 5251 int32_t argc = args.GetLength(); |
| 5089 if ((argc > 0) && (argc < 4)) { | 5252 if ((argc > 0) && (argc < 4)) { |
| 5090 FX_BOOL bFlags = FALSE; | 5253 FX_BOOL bFlags = FALSE; |
| 5091 FX_FLOAT fNumber = 0.0f; | 5254 FX_FLOAT fNumber = 0.0f; |
| 5092 int32_t iIdentifier = 0; | 5255 int32_t iIdentifier = 0; |
| 5093 CFX_ByteString localeString; | 5256 CFX_ByteString localeString; |
| 5094 std::unique_ptr<CFXJSE_Value> numberValue = GetSimpleValue(pThis, args, 0); | 5257 std::unique_ptr<CFXJSE_Value> numberValue = GetSimpleValue(pThis, args, 0); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5128 } else { | 5291 } else { |
| 5129 FXJSE_Value_SetNull(args.GetReturnValue()); | 5292 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5130 } | 5293 } |
| 5131 } else { | 5294 } else { |
| 5132 CXFA_FM2JSContext* pContext = | 5295 CXFA_FM2JSContext* pContext = |
| 5133 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5296 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5134 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5297 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5135 L"WordNum"); | 5298 L"WordNum"); |
| 5136 } | 5299 } |
| 5137 } | 5300 } |
| 5301 |
| 5302 // static |
| 5138 void CXFA_FM2JSContext::TrillionUS(const CFX_ByteStringC& szData, | 5303 void CXFA_FM2JSContext::TrillionUS(const CFX_ByteStringC& szData, |
| 5139 CFX_ByteTextBuf& strBuf) { | 5304 CFX_ByteTextBuf& strBuf) { |
| 5140 CFX_ByteStringC pUnits[] = {"zero", "one", "two", "three", "four", | 5305 CFX_ByteStringC pUnits[] = {"zero", "one", "two", "three", "four", |
| 5141 "five", "six", "seven", "eight", "nine"}; | 5306 "five", "six", "seven", "eight", "nine"}; |
| 5142 CFX_ByteStringC pCapUnits[] = {"Zero", "One", "Two", "Three", "Four", | 5307 CFX_ByteStringC pCapUnits[] = {"Zero", "One", "Two", "Three", "Four", |
| 5143 "Five", "Six", "Seven", "Eight", "Nine"}; | 5308 "Five", "Six", "Seven", "Eight", "Nine"}; |
| 5144 CFX_ByteStringC pTens[] = {"Ten", "Eleven", "Twelve", "Thirteen", | 5309 CFX_ByteStringC pTens[] = {"Ten", "Eleven", "Twelve", "Thirteen", |
| 5145 "Fourteen", "Fifteen", "Sixteen", "Seventeen", | 5310 "Fourteen", "Fifteen", "Sixteen", "Seventeen", |
| 5146 "Eighteen", "Nineteen"}; | 5311 "Eighteen", "Nineteen"}; |
| 5147 CFX_ByteStringC pLastTens[] = {"Twenty", "Thirty", "Forty", "Fifty", | 5312 CFX_ByteStringC pLastTens[] = {"Twenty", "Thirty", "Forty", "Fifty", |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5225 strBuf << pCapUnits[*(pData + iIndex + 2) - '0']; | 5390 strBuf << pCapUnits[*(pData + iIndex + 2) - '0']; |
| 5226 } | 5391 } |
| 5227 } | 5392 } |
| 5228 if (iIndex < iLength - 3) { | 5393 if (iIndex < iLength - 3) { |
| 5229 strBuf << pComm[iComm]; | 5394 strBuf << pComm[iComm]; |
| 5230 --iComm; | 5395 --iComm; |
| 5231 } | 5396 } |
| 5232 iIndex += 3; | 5397 iIndex += 3; |
| 5233 } | 5398 } |
| 5234 } | 5399 } |
| 5400 |
| 5401 // static |
| 5235 void CXFA_FM2JSContext::WordUS(const CFX_ByteStringC& szData, | 5402 void CXFA_FM2JSContext::WordUS(const CFX_ByteStringC& szData, |
| 5236 int32_t iStyle, | 5403 int32_t iStyle, |
| 5237 CFX_ByteTextBuf& strBuf) { | 5404 CFX_ByteTextBuf& strBuf) { |
| 5238 const FX_CHAR* pData = szData.c_str(); | 5405 const FX_CHAR* pData = szData.c_str(); |
| 5239 int32_t iLength = szData.GetLength(); | 5406 int32_t iLength = szData.GetLength(); |
| 5240 switch (iStyle) { | 5407 switch (iStyle) { |
| 5241 case 0: { | 5408 case 0: { |
| 5242 int32_t iIndex = 0; | 5409 int32_t iIndex = 0; |
| 5243 while (iIndex < iLength) { | 5410 while (iIndex < iLength) { |
| 5244 if (*(pData + iIndex) == '.') { | 5411 if (*(pData + iIndex) == '.') { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5323 strBuf << " Trillion "; | 5490 strBuf << " Trillion "; |
| 5324 } | 5491 } |
| 5325 } | 5492 } |
| 5326 strBuf << " Cents"; | 5493 strBuf << " Cents"; |
| 5327 } | 5494 } |
| 5328 } break; | 5495 } break; |
| 5329 default: | 5496 default: |
| 5330 break; | 5497 break; |
| 5331 } | 5498 } |
| 5332 } | 5499 } |
| 5500 |
| 5501 // static |
| 5333 void CXFA_FM2JSContext::Get(CFXJSE_Value* pThis, | 5502 void CXFA_FM2JSContext::Get(CFXJSE_Value* pThis, |
| 5334 const CFX_ByteStringC& szFuncName, | 5503 const CFX_ByteStringC& szFuncName, |
| 5335 CFXJSE_Arguments& args) { | 5504 CFXJSE_Arguments& args) { |
| 5336 CXFA_FM2JSContext* pContext = | 5505 CXFA_FM2JSContext* pContext = |
| 5337 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5506 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5338 int32_t argc = args.GetLength(); | 5507 if (args.GetLength() == 1) { |
| 5339 if (argc == 1) { | |
| 5340 CXFA_Document* pDoc = pContext->GetDocument(); | 5508 CXFA_Document* pDoc = pContext->GetDocument(); |
| 5341 if (!pDoc) { | 5509 if (!pDoc) { |
| 5342 return; | 5510 return; |
| 5343 } | 5511 } |
| 5344 IXFA_AppProvider* pAppProvider = | 5512 IXFA_AppProvider* pAppProvider = |
| 5345 pDoc->GetParser()->GetNotify()->GetAppProvider(); | 5513 pDoc->GetParser()->GetNotify()->GetAppProvider(); |
| 5346 if (!pAppProvider) { | 5514 if (!pAppProvider) { |
| 5347 return; | 5515 return; |
| 5348 } | 5516 } |
| 5349 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 5517 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 5350 CFX_ByteString urlString; | 5518 CFX_ByteString urlString; |
| 5351 ValueToUTF8String(argOne.get(), urlString); | 5519 ValueToUTF8String(argOne.get(), urlString); |
| 5352 IFX_FileRead* pFile = pAppProvider->DownloadURL( | 5520 IFX_FileRead* pFile = pAppProvider->DownloadURL( |
| 5353 CFX_WideString::FromUTF8(urlString.AsStringC())); | 5521 CFX_WideString::FromUTF8(urlString.AsStringC())); |
| 5354 if (pFile) { | 5522 if (pFile) { |
| 5355 int32_t size = pFile->GetSize(); | 5523 int32_t size = pFile->GetSize(); |
| 5356 uint8_t* pData = FX_Alloc(uint8_t, size); | 5524 uint8_t* pData = FX_Alloc(uint8_t, size); |
| 5357 pFile->ReadBlock(pData, size); | 5525 pFile->ReadBlock(pData, size); |
| 5358 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 5526 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
| 5359 CFX_ByteStringC(pData, size)); | 5527 CFX_ByteStringC(pData, size)); |
| 5360 FX_Free(pData); | 5528 FX_Free(pData); |
| 5361 pFile->Release(); | 5529 pFile->Release(); |
| 5362 } | 5530 } |
| 5363 } else { | 5531 } else { |
| 5364 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5532 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5365 L"Get"); | 5533 L"Get"); |
| 5366 } | 5534 } |
| 5367 } | 5535 } |
| 5536 |
| 5537 // static |
| 5368 void CXFA_FM2JSContext::Post(CFXJSE_Value* pThis, | 5538 void CXFA_FM2JSContext::Post(CFXJSE_Value* pThis, |
| 5369 const CFX_ByteStringC& szFuncName, | 5539 const CFX_ByteStringC& szFuncName, |
| 5370 CFXJSE_Arguments& args) { | 5540 CFXJSE_Arguments& args) { |
| 5371 CXFA_FM2JSContext* pContext = | 5541 CXFA_FM2JSContext* pContext = |
| 5372 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5542 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5373 int32_t argc = args.GetLength(); | 5543 int32_t argc = args.GetLength(); |
| 5374 if ((argc >= 2) && (argc <= 5)) { | 5544 if ((argc >= 2) && (argc <= 5)) { |
| 5375 CXFA_Document* pDoc = pContext->GetDocument(); | 5545 CXFA_Document* pDoc = pContext->GetDocument(); |
| 5376 if (!pDoc) { | 5546 if (!pDoc) { |
| 5377 return; | 5547 return; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5415 FX_UTF8Encode(decodedResponse.c_str(), decodedResponse.GetLength()) | 5585 FX_UTF8Encode(decodedResponse.c_str(), decodedResponse.GetLength()) |
| 5416 .AsStringC()); | 5586 .AsStringC()); |
| 5417 } else { | 5587 } else { |
| 5418 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); | 5588 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); |
| 5419 } | 5589 } |
| 5420 } else { | 5590 } else { |
| 5421 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5591 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5422 L"Post"); | 5592 L"Post"); |
| 5423 } | 5593 } |
| 5424 } | 5594 } |
| 5595 |
| 5596 // static |
| 5425 void CXFA_FM2JSContext::Put(CFXJSE_Value* pThis, | 5597 void CXFA_FM2JSContext::Put(CFXJSE_Value* pThis, |
| 5426 const CFX_ByteStringC& szFuncName, | 5598 const CFX_ByteStringC& szFuncName, |
| 5427 CFXJSE_Arguments& args) { | 5599 CFXJSE_Arguments& args) { |
| 5428 CXFA_FM2JSContext* pContext = | 5600 CXFA_FM2JSContext* pContext = |
| 5429 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5601 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5430 int32_t argc = args.GetLength(); | 5602 int32_t argc = args.GetLength(); |
| 5431 if ((argc == 2) || (argc == 3)) { | 5603 if ((argc == 2) || (argc == 3)) { |
| 5432 CXFA_Document* pDoc = pContext->GetDocument(); | 5604 CXFA_Document* pDoc = pContext->GetDocument(); |
| 5433 if (!pDoc) { | 5605 if (!pDoc) { |
| 5434 return; | 5606 return; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 5456 if (bFlags) { | 5628 if (bFlags) { |
| 5457 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 5629 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
| 5458 } else { | 5630 } else { |
| 5459 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); | 5631 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); |
| 5460 } | 5632 } |
| 5461 } else { | 5633 } else { |
| 5462 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5634 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 5463 L"Put"); | 5635 L"Put"); |
| 5464 } | 5636 } |
| 5465 } | 5637 } |
| 5638 |
| 5639 // static |
| 5466 void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis, | 5640 void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis, |
| 5467 const CFX_ByteStringC& szFuncName, | 5641 const CFX_ByteStringC& szFuncName, |
| 5468 CFXJSE_Arguments& args) { | 5642 CFXJSE_Arguments& args) { |
| 5469 CXFA_FM2JSContext* pContext = | 5643 CXFA_FM2JSContext* pContext = |
| 5470 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5644 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5471 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 5645 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 5472 if (args.GetLength() == 2) { | 5646 if (args.GetLength() == 2) { |
| 5473 std::unique_ptr<CFXJSE_Value> lValue = args.GetValue(0); | 5647 std::unique_ptr<CFXJSE_Value> lValue = args.GetValue(0); |
| 5474 std::unique_ptr<CFXJSE_Value> rValue = GetSimpleValue(pThis, args, 1); | 5648 std::unique_ptr<CFXJSE_Value> rValue = GetSimpleValue(pThis, args, 1); |
| 5475 FX_BOOL bSetStatus = TRUE; | 5649 FX_BOOL bSetStatus = TRUE; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 5502 bSetStatus = SetObjectDefaultValue(lValue.get(), rValue.get()); | 5676 bSetStatus = SetObjectDefaultValue(lValue.get(), rValue.get()); |
| 5503 if (!bSetStatus) { | 5677 if (!bSetStatus) { |
| 5504 pContext->ThrowScriptErrorMessage(XFA_IDS_NOT_DEFAUL_VALUE); | 5678 pContext->ThrowScriptErrorMessage(XFA_IDS_NOT_DEFAUL_VALUE); |
| 5505 } | 5679 } |
| 5506 } | 5680 } |
| 5507 FXJSE_Value_Set(args.GetReturnValue(), rValue.get()); | 5681 FXJSE_Value_Set(args.GetReturnValue(), rValue.get()); |
| 5508 } else { | 5682 } else { |
| 5509 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5683 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5510 } | 5684 } |
| 5511 } | 5685 } |
| 5686 |
| 5687 // static |
| 5512 void CXFA_FM2JSContext::logical_or_operator(CFXJSE_Value* pThis, | 5688 void CXFA_FM2JSContext::logical_or_operator(CFXJSE_Value* pThis, |
| 5513 const CFX_ByteStringC& szFuncName, | 5689 const CFX_ByteStringC& szFuncName, |
| 5514 CFXJSE_Arguments& args) { | 5690 CFXJSE_Arguments& args) { |
| 5515 if (args.GetLength() == 2) { | 5691 if (args.GetLength() == 2) { |
| 5516 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5692 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5517 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5693 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5518 if (FXJSE_Value_IsNull(argFirst.get()) && | 5694 if (FXJSE_Value_IsNull(argFirst.get()) && |
| 5519 FXJSE_Value_IsNull(argSecond.get())) { | 5695 FXJSE_Value_IsNull(argSecond.get())) { |
| 5520 FXJSE_Value_SetNull(args.GetReturnValue()); | 5696 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5521 } else { | 5697 } else { |
| 5522 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); | 5698 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); |
| 5523 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); | 5699 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); |
| 5524 FXJSE_Value_SetInteger(args.GetReturnValue(), (first || second) ? 1 : 0); | 5700 FXJSE_Value_SetInteger(args.GetReturnValue(), (first || second) ? 1 : 0); |
| 5525 } | 5701 } |
| 5526 } else { | 5702 } else { |
| 5527 CXFA_FM2JSContext* pContext = | 5703 CXFA_FM2JSContext* pContext = |
| 5528 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5704 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5529 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5705 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5530 } | 5706 } |
| 5531 } | 5707 } |
| 5708 |
| 5709 // static |
| 5532 void CXFA_FM2JSContext::logical_and_operator(CFXJSE_Value* pThis, | 5710 void CXFA_FM2JSContext::logical_and_operator(CFXJSE_Value* pThis, |
| 5533 const CFX_ByteStringC& szFuncName, | 5711 const CFX_ByteStringC& szFuncName, |
| 5534 CFXJSE_Arguments& args) { | 5712 CFXJSE_Arguments& args) { |
| 5535 if (args.GetLength() == 2) { | 5713 if (args.GetLength() == 2) { |
| 5536 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5714 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5537 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5715 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5538 if (FXJSE_Value_IsNull(argFirst.get()) && | 5716 if (FXJSE_Value_IsNull(argFirst.get()) && |
| 5539 FXJSE_Value_IsNull(argSecond.get())) { | 5717 FXJSE_Value_IsNull(argSecond.get())) { |
| 5540 FXJSE_Value_SetNull(args.GetReturnValue()); | 5718 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5541 } else { | 5719 } else { |
| 5542 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); | 5720 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); |
| 5543 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); | 5721 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); |
| 5544 FXJSE_Value_SetInteger(args.GetReturnValue(), (first && second) ? 1 : 0); | 5722 FXJSE_Value_SetInteger(args.GetReturnValue(), (first && second) ? 1 : 0); |
| 5545 } | 5723 } |
| 5546 } else { | 5724 } else { |
| 5547 CXFA_FM2JSContext* pContext = | 5725 CXFA_FM2JSContext* pContext = |
| 5548 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5726 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5549 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5727 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5550 } | 5728 } |
| 5551 } | 5729 } |
| 5730 |
| 5731 // static |
| 5552 void CXFA_FM2JSContext::equality_operator(CFXJSE_Value* pThis, | 5732 void CXFA_FM2JSContext::equality_operator(CFXJSE_Value* pThis, |
| 5553 const CFX_ByteStringC& szFuncName, | 5733 const CFX_ByteStringC& szFuncName, |
| 5554 CFXJSE_Arguments& args) { | 5734 CFXJSE_Arguments& args) { |
| 5555 if (args.GetLength() == 2) { | 5735 if (args.GetLength() == 2) { |
| 5556 if (fm_ref_equal(pThis, args)) { | 5736 if (fm_ref_equal(pThis, args)) { |
| 5557 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); | 5737 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); |
| 5558 } else { | 5738 } else { |
| 5559 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5739 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5560 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5740 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5561 if (FXJSE_Value_IsNull(argFirst.get()) || | 5741 if (FXJSE_Value_IsNull(argFirst.get()) || |
| (...skipping 17 matching lines...) Expand all Loading... |
| 5579 FXJSE_Value_SetInteger(args.GetReturnValue(), | 5759 FXJSE_Value_SetInteger(args.GetReturnValue(), |
| 5580 (first == second) ? 1 : 0); | 5760 (first == second) ? 1 : 0); |
| 5581 } | 5761 } |
| 5582 } | 5762 } |
| 5583 } else { | 5763 } else { |
| 5584 CXFA_FM2JSContext* pContext = | 5764 CXFA_FM2JSContext* pContext = |
| 5585 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5765 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5586 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5766 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5587 } | 5767 } |
| 5588 } | 5768 } |
| 5769 |
| 5770 // static |
| 5589 void CXFA_FM2JSContext::notequality_operator(CFXJSE_Value* pThis, | 5771 void CXFA_FM2JSContext::notequality_operator(CFXJSE_Value* pThis, |
| 5590 const CFX_ByteStringC& szFuncName, | 5772 const CFX_ByteStringC& szFuncName, |
| 5591 CFXJSE_Arguments& args) { | 5773 CFXJSE_Arguments& args) { |
| 5592 if (args.GetLength() == 2) { | 5774 if (args.GetLength() == 2) { |
| 5593 if (fm_ref_equal(pThis, args)) { | 5775 if (fm_ref_equal(pThis, args)) { |
| 5594 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 5776 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
| 5595 } else { | 5777 } else { |
| 5596 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5778 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5597 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5779 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5598 if (FXJSE_Value_IsNull(argFirst.get()) || | 5780 if (FXJSE_Value_IsNull(argFirst.get()) || |
| (...skipping 16 matching lines...) Expand all Loading... |
| 5615 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5797 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5616 FXJSE_Value_SetInteger(args.GetReturnValue(), first != second); | 5798 FXJSE_Value_SetInteger(args.GetReturnValue(), first != second); |
| 5617 } | 5799 } |
| 5618 } | 5800 } |
| 5619 } else { | 5801 } else { |
| 5620 CXFA_FM2JSContext* pContext = | 5802 CXFA_FM2JSContext* pContext = |
| 5621 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5803 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5622 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5804 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5623 } | 5805 } |
| 5624 } | 5806 } |
| 5807 |
| 5808 // static |
| 5625 FX_BOOL CXFA_FM2JSContext::fm_ref_equal(CFXJSE_Value* pThis, | 5809 FX_BOOL CXFA_FM2JSContext::fm_ref_equal(CFXJSE_Value* pThis, |
| 5626 CFXJSE_Arguments& args) { | 5810 CFXJSE_Arguments& args) { |
| 5627 FX_BOOL bRet = FALSE; | 5811 FX_BOOL bRet = FALSE; |
| 5628 CXFA_FM2JSContext* pContext = | 5812 CXFA_FM2JSContext* pContext = |
| 5629 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5813 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5630 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 5814 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 5631 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0); | 5815 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0); |
| 5632 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1); | 5816 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1); |
| 5633 if (FXJSE_Value_IsArray(argFirst.get()) && | 5817 if (FXJSE_Value_IsArray(argFirst.get()) && |
| 5634 FXJSE_Value_IsArray(argSecond.get())) { | 5818 FXJSE_Value_IsArray(argSecond.get())) { |
| 5635 std::unique_ptr<CFXJSE_Value> firstFlagValue(new CFXJSE_Value(pIsolate)); | 5819 std::unique_ptr<CFXJSE_Value> firstFlagValue(new CFXJSE_Value(pIsolate)); |
| 5636 std::unique_ptr<CFXJSE_Value> secondFlagValue(new CFXJSE_Value(pIsolate)); | 5820 std::unique_ptr<CFXJSE_Value> secondFlagValue(new CFXJSE_Value(pIsolate)); |
| 5637 FXJSE_Value_GetObjectPropByIdx(argFirst.get(), 0, firstFlagValue.get()); | 5821 FXJSE_Value_GetObjectPropByIdx(argFirst.get(), 0, firstFlagValue.get()); |
| 5638 FXJSE_Value_GetObjectPropByIdx(argSecond.get(), 0, secondFlagValue.get()); | 5822 FXJSE_Value_GetObjectPropByIdx(argSecond.get(), 0, secondFlagValue.get()); |
| 5639 if ((FXJSE_Value_ToInteger(firstFlagValue.get()) == 3) && | 5823 if ((FXJSE_Value_ToInteger(firstFlagValue.get()) == 3) && |
| 5640 (FXJSE_Value_ToInteger(secondFlagValue.get()) == 3)) { | 5824 (FXJSE_Value_ToInteger(secondFlagValue.get()) == 3)) { |
| 5641 std::unique_ptr<CFXJSE_Value> firstJSObject(new CFXJSE_Value(pIsolate)); | 5825 std::unique_ptr<CFXJSE_Value> firstJSObject(new CFXJSE_Value(pIsolate)); |
| 5642 std::unique_ptr<CFXJSE_Value> secondJSObject(new CFXJSE_Value(pIsolate)); | 5826 std::unique_ptr<CFXJSE_Value> secondJSObject(new CFXJSE_Value(pIsolate)); |
| 5643 FXJSE_Value_GetObjectPropByIdx(argFirst.get(), 2, firstJSObject.get()); | 5827 FXJSE_Value_GetObjectPropByIdx(argFirst.get(), 2, firstJSObject.get()); |
| 5644 FXJSE_Value_GetObjectPropByIdx(argSecond.get(), 2, secondJSObject.get()); | 5828 FXJSE_Value_GetObjectPropByIdx(argSecond.get(), 2, secondJSObject.get()); |
| 5645 if (!FXJSE_Value_IsNull(firstJSObject.get()) && | 5829 if (!FXJSE_Value_IsNull(firstJSObject.get()) && |
| 5646 !FXJSE_Value_IsNull(secondJSObject.get())) { | 5830 !FXJSE_Value_IsNull(secondJSObject.get())) { |
| 5647 bRet = (FXJSE_Value_ToObject(firstJSObject.get(), NULL) == | 5831 bRet = (FXJSE_Value_ToObject(firstJSObject.get(), nullptr) == |
| 5648 FXJSE_Value_ToObject(secondJSObject.get(), NULL)); | 5832 FXJSE_Value_ToObject(secondJSObject.get(), nullptr)); |
| 5649 } | 5833 } |
| 5650 } | 5834 } |
| 5651 } | 5835 } |
| 5652 return bRet; | 5836 return bRet; |
| 5653 } | 5837 } |
| 5838 |
| 5839 // static |
| 5654 void CXFA_FM2JSContext::less_operator(CFXJSE_Value* pThis, | 5840 void CXFA_FM2JSContext::less_operator(CFXJSE_Value* pThis, |
| 5655 const CFX_ByteStringC& szFuncName, | 5841 const CFX_ByteStringC& szFuncName, |
| 5656 CFXJSE_Arguments& args) { | 5842 CFXJSE_Arguments& args) { |
| 5657 if (args.GetLength() == 2) { | 5843 if (args.GetLength() == 2) { |
| 5658 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5844 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5659 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5845 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5660 if (FXJSE_Value_IsNull(argFirst.get()) || | 5846 if (FXJSE_Value_IsNull(argFirst.get()) || |
| 5661 FXJSE_Value_IsNull(argSecond.get())) { | 5847 FXJSE_Value_IsNull(argSecond.get())) { |
| 5662 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 5848 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
| 5663 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) && | 5849 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) && |
| 5664 FXJSE_Value_IsUTF8String(argSecond.get())) { | 5850 FXJSE_Value_IsUTF8String(argSecond.get())) { |
| 5665 CFX_ByteString firstOutput; | 5851 CFX_ByteString firstOutput; |
| 5666 CFX_ByteString secondOutput; | 5852 CFX_ByteString secondOutput; |
| 5667 FXJSE_Value_ToUTF8String(argFirst.get(), firstOutput); | 5853 FXJSE_Value_ToUTF8String(argFirst.get(), firstOutput); |
| 5668 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); | 5854 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); |
| 5669 FXJSE_Value_SetInteger( | 5855 FXJSE_Value_SetInteger( |
| 5670 args.GetReturnValue(), | 5856 args.GetReturnValue(), |
| 5671 firstOutput.Compare(secondOutput.AsStringC()) == -1); | 5857 firstOutput.Compare(secondOutput.AsStringC()) == -1); |
| 5672 } else { | 5858 } else { |
| 5673 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5859 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5674 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5860 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5675 FXJSE_Value_SetInteger(args.GetReturnValue(), (first < second) ? 1 : 0); | 5861 FXJSE_Value_SetInteger(args.GetReturnValue(), (first < second) ? 1 : 0); |
| 5676 } | 5862 } |
| 5677 } else { | 5863 } else { |
| 5678 CXFA_FM2JSContext* pContext = | 5864 CXFA_FM2JSContext* pContext = |
| 5679 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5865 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5680 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5866 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5681 } | 5867 } |
| 5682 } | 5868 } |
| 5869 |
| 5870 // static |
| 5683 void CXFA_FM2JSContext::lessequal_operator(CFXJSE_Value* pThis, | 5871 void CXFA_FM2JSContext::lessequal_operator(CFXJSE_Value* pThis, |
| 5684 const CFX_ByteStringC& szFuncName, | 5872 const CFX_ByteStringC& szFuncName, |
| 5685 CFXJSE_Arguments& args) { | 5873 CFXJSE_Arguments& args) { |
| 5686 if (args.GetLength() == 2) { | 5874 if (args.GetLength() == 2) { |
| 5687 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5875 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5688 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5876 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5689 if (FXJSE_Value_IsNull(argFirst.get()) || | 5877 if (FXJSE_Value_IsNull(argFirst.get()) || |
| 5690 FXJSE_Value_IsNull(argSecond.get())) { | 5878 FXJSE_Value_IsNull(argSecond.get())) { |
| 5691 FXJSE_Value_SetInteger(args.GetReturnValue(), | 5879 FXJSE_Value_SetInteger(args.GetReturnValue(), |
| 5692 (FXJSE_Value_IsNull(argFirst.get()) && | 5880 (FXJSE_Value_IsNull(argFirst.get()) && |
| (...skipping 13 matching lines...) Expand all Loading... |
| 5706 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5894 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5707 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5895 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5708 FXJSE_Value_SetInteger(args.GetReturnValue(), (first <= second) ? 1 : 0); | 5896 FXJSE_Value_SetInteger(args.GetReturnValue(), (first <= second) ? 1 : 0); |
| 5709 } | 5897 } |
| 5710 } else { | 5898 } else { |
| 5711 CXFA_FM2JSContext* pContext = | 5899 CXFA_FM2JSContext* pContext = |
| 5712 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5900 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5713 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5901 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5714 } | 5902 } |
| 5715 } | 5903 } |
| 5904 |
| 5905 // static |
| 5716 void CXFA_FM2JSContext::greater_operator(CFXJSE_Value* pThis, | 5906 void CXFA_FM2JSContext::greater_operator(CFXJSE_Value* pThis, |
| 5717 const CFX_ByteStringC& szFuncName, | 5907 const CFX_ByteStringC& szFuncName, |
| 5718 CFXJSE_Arguments& args) { | 5908 CFXJSE_Arguments& args) { |
| 5719 if (args.GetLength() == 2) { | 5909 if (args.GetLength() == 2) { |
| 5720 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5910 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5721 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5911 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5722 if (FXJSE_Value_IsNull(argFirst.get()) || | 5912 if (FXJSE_Value_IsNull(argFirst.get()) || |
| 5723 FXJSE_Value_IsNull(argSecond.get())) { | 5913 FXJSE_Value_IsNull(argSecond.get())) { |
| 5724 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 5914 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
| 5725 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) && | 5915 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) && |
| 5726 FXJSE_Value_IsUTF8String(argSecond.get())) { | 5916 FXJSE_Value_IsUTF8String(argSecond.get())) { |
| 5727 CFX_ByteString firstOutput; | 5917 CFX_ByteString firstOutput; |
| 5728 CFX_ByteString secondOutput; | 5918 CFX_ByteString secondOutput; |
| 5729 FXJSE_Value_ToUTF8String(argFirst.get(), firstOutput); | 5919 FXJSE_Value_ToUTF8String(argFirst.get(), firstOutput); |
| 5730 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); | 5920 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); |
| 5731 FXJSE_Value_SetInteger( | 5921 FXJSE_Value_SetInteger( |
| 5732 args.GetReturnValue(), | 5922 args.GetReturnValue(), |
| 5733 firstOutput.Compare(secondOutput.AsStringC()) == 1); | 5923 firstOutput.Compare(secondOutput.AsStringC()) == 1); |
| 5734 } else { | 5924 } else { |
| 5735 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5925 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5736 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5926 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5737 FXJSE_Value_SetInteger(args.GetReturnValue(), (first > second) ? 1 : 0); | 5927 FXJSE_Value_SetInteger(args.GetReturnValue(), (first > second) ? 1 : 0); |
| 5738 } | 5928 } |
| 5739 } else { | 5929 } else { |
| 5740 CXFA_FM2JSContext* pContext = | 5930 CXFA_FM2JSContext* pContext = |
| 5741 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5931 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5742 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5932 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5743 } | 5933 } |
| 5744 } | 5934 } |
| 5935 |
| 5936 // static |
| 5745 void CXFA_FM2JSContext::greaterequal_operator(CFXJSE_Value* pThis, | 5937 void CXFA_FM2JSContext::greaterequal_operator(CFXJSE_Value* pThis, |
| 5746 const CFX_ByteStringC& szFuncName, | 5938 const CFX_ByteStringC& szFuncName, |
| 5747 CFXJSE_Arguments& args) { | 5939 CFXJSE_Arguments& args) { |
| 5748 if (args.GetLength() == 2) { | 5940 if (args.GetLength() == 2) { |
| 5749 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5941 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5750 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5942 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5751 if (FXJSE_Value_IsNull(argFirst.get()) || | 5943 if (FXJSE_Value_IsNull(argFirst.get()) || |
| 5752 FXJSE_Value_IsNull(argSecond.get())) { | 5944 FXJSE_Value_IsNull(argSecond.get())) { |
| 5753 FXJSE_Value_SetInteger(args.GetReturnValue(), | 5945 FXJSE_Value_SetInteger(args.GetReturnValue(), |
| 5754 (FXJSE_Value_IsNull(argFirst.get()) && | 5946 (FXJSE_Value_IsNull(argFirst.get()) && |
| (...skipping 13 matching lines...) Expand all Loading... |
| 5768 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5960 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5769 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5961 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5770 FXJSE_Value_SetInteger(args.GetReturnValue(), (first >= second) ? 1 : 0); | 5962 FXJSE_Value_SetInteger(args.GetReturnValue(), (first >= second) ? 1 : 0); |
| 5771 } | 5963 } |
| 5772 } else { | 5964 } else { |
| 5773 CXFA_FM2JSContext* pContext = | 5965 CXFA_FM2JSContext* pContext = |
| 5774 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5966 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5775 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5967 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5776 } | 5968 } |
| 5777 } | 5969 } |
| 5970 |
| 5971 // static |
| 5778 void CXFA_FM2JSContext::plus_operator(CFXJSE_Value* pThis, | 5972 void CXFA_FM2JSContext::plus_operator(CFXJSE_Value* pThis, |
| 5779 const CFX_ByteStringC& szFuncName, | 5973 const CFX_ByteStringC& szFuncName, |
| 5780 CFXJSE_Arguments& args) { | 5974 CFXJSE_Arguments& args) { |
| 5781 if (args.GetLength() == 2) { | 5975 if (args.GetLength() == 2) { |
| 5782 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0); | 5976 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0); |
| 5783 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1); | 5977 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1); |
| 5784 if (ValueIsNull(pThis, argFirst.get()) && | 5978 if (ValueIsNull(pThis, argFirst.get()) && |
| 5785 ValueIsNull(pThis, argSecond.get())) { | 5979 ValueIsNull(pThis, argSecond.get())) { |
| 5786 FXJSE_Value_SetNull(args.GetReturnValue()); | 5980 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5787 } else { | 5981 } else { |
| 5788 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5982 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5789 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5983 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5790 FXJSE_Value_SetDouble(args.GetReturnValue(), first + second); | 5984 FXJSE_Value_SetDouble(args.GetReturnValue(), first + second); |
| 5791 } | 5985 } |
| 5792 } else { | 5986 } else { |
| 5793 CXFA_FM2JSContext* pContext = | 5987 CXFA_FM2JSContext* pContext = |
| 5794 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5988 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5795 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5989 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5796 } | 5990 } |
| 5797 } | 5991 } |
| 5992 |
| 5993 // static |
| 5798 void CXFA_FM2JSContext::minus_operator(CFXJSE_Value* pThis, | 5994 void CXFA_FM2JSContext::minus_operator(CFXJSE_Value* pThis, |
| 5799 const CFX_ByteStringC& szFuncName, | 5995 const CFX_ByteStringC& szFuncName, |
| 5800 CFXJSE_Arguments& args) { | 5996 CFXJSE_Arguments& args) { |
| 5801 if (args.GetLength() == 2) { | 5997 if (args.GetLength() == 2) { |
| 5802 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5998 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5803 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5999 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5804 if (FXJSE_Value_IsNull(argFirst.get()) && | 6000 if (FXJSE_Value_IsNull(argFirst.get()) && |
| 5805 FXJSE_Value_IsNull(argSecond.get())) { | 6001 FXJSE_Value_IsNull(argSecond.get())) { |
| 5806 FXJSE_Value_SetNull(args.GetReturnValue()); | 6002 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5807 } else { | 6003 } else { |
| 5808 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 6004 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5809 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 6005 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5810 FXJSE_Value_SetDouble(args.GetReturnValue(), first - second); | 6006 FXJSE_Value_SetDouble(args.GetReturnValue(), first - second); |
| 5811 } | 6007 } |
| 5812 } else { | 6008 } else { |
| 5813 CXFA_FM2JSContext* pContext = | 6009 CXFA_FM2JSContext* pContext = |
| 5814 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6010 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5815 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6011 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5816 } | 6012 } |
| 5817 } | 6013 } |
| 6014 |
| 6015 // static |
| 5818 void CXFA_FM2JSContext::multiple_operator(CFXJSE_Value* pThis, | 6016 void CXFA_FM2JSContext::multiple_operator(CFXJSE_Value* pThis, |
| 5819 const CFX_ByteStringC& szFuncName, | 6017 const CFX_ByteStringC& szFuncName, |
| 5820 CFXJSE_Arguments& args) { | 6018 CFXJSE_Arguments& args) { |
| 5821 if (args.GetLength() == 2) { | 6019 if (args.GetLength() == 2) { |
| 5822 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 6020 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5823 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 6021 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5824 if (FXJSE_Value_IsNull(argFirst.get()) && | 6022 if (FXJSE_Value_IsNull(argFirst.get()) && |
| 5825 FXJSE_Value_IsNull(argSecond.get())) { | 6023 FXJSE_Value_IsNull(argSecond.get())) { |
| 5826 FXJSE_Value_SetNull(args.GetReturnValue()); | 6024 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5827 } else { | 6025 } else { |
| 5828 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 6026 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5829 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 6027 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5830 FXJSE_Value_SetDouble(args.GetReturnValue(), first * second); | 6028 FXJSE_Value_SetDouble(args.GetReturnValue(), first * second); |
| 5831 } | 6029 } |
| 5832 } else { | 6030 } else { |
| 5833 CXFA_FM2JSContext* pContext = | 6031 CXFA_FM2JSContext* pContext = |
| 5834 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6032 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5835 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6033 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5836 } | 6034 } |
| 5837 } | 6035 } |
| 6036 |
| 6037 // static |
| 5838 void CXFA_FM2JSContext::divide_operator(CFXJSE_Value* pThis, | 6038 void CXFA_FM2JSContext::divide_operator(CFXJSE_Value* pThis, |
| 5839 const CFX_ByteStringC& szFuncName, | 6039 const CFX_ByteStringC& szFuncName, |
| 5840 CFXJSE_Arguments& args) { | 6040 CFXJSE_Arguments& args) { |
| 5841 CXFA_FM2JSContext* pContext = | 6041 CXFA_FM2JSContext* pContext = |
| 5842 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6042 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5843 if (args.GetLength() == 2) { | 6043 if (args.GetLength() == 2) { |
| 5844 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 6044 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
| 5845 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 6045 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
| 5846 if (FXJSE_Value_IsNull(argFirst.get()) && | 6046 if (FXJSE_Value_IsNull(argFirst.get()) && |
| 5847 FXJSE_Value_IsNull(argSecond.get())) { | 6047 FXJSE_Value_IsNull(argSecond.get())) { |
| 5848 FXJSE_Value_SetNull(args.GetReturnValue()); | 6048 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5849 } else { | 6049 } else { |
| 5850 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 6050 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
| 5851 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 6051 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
| 5852 if (second == 0.0) { | 6052 if (second == 0.0) { |
| 5853 pContext->ThrowScriptErrorMessage(XFA_IDS_DIVIDE_ZERO); | 6053 pContext->ThrowScriptErrorMessage(XFA_IDS_DIVIDE_ZERO); |
| 5854 } else { | 6054 } else { |
| 5855 FXJSE_Value_SetDouble(args.GetReturnValue(), first / second); | 6055 FXJSE_Value_SetDouble(args.GetReturnValue(), first / second); |
| 5856 } | 6056 } |
| 5857 } | 6057 } |
| 5858 } else { | 6058 } else { |
| 5859 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6059 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5860 } | 6060 } |
| 5861 } | 6061 } |
| 6062 |
| 6063 // static |
| 5862 void CXFA_FM2JSContext::positive_operator(CFXJSE_Value* pThis, | 6064 void CXFA_FM2JSContext::positive_operator(CFXJSE_Value* pThis, |
| 5863 const CFX_ByteStringC& szFuncName, | 6065 const CFX_ByteStringC& szFuncName, |
| 5864 CFXJSE_Arguments& args) { | 6066 CFXJSE_Arguments& args) { |
| 5865 int32_t iLength = args.GetLength(); | 6067 if (args.GetLength() == 1) { |
| 5866 if (iLength == 1) { | |
| 5867 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 6068 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 5868 if (FXJSE_Value_IsNull(argOne.get())) { | 6069 if (FXJSE_Value_IsNull(argOne.get())) { |
| 5869 FXJSE_Value_SetNull(args.GetReturnValue()); | 6070 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5870 } else { | 6071 } else { |
| 5871 FXJSE_Value_SetDouble(args.GetReturnValue(), | 6072 FXJSE_Value_SetDouble(args.GetReturnValue(), |
| 5872 0.0 + ValueToDouble(pThis, argOne.get())); | 6073 0.0 + ValueToDouble(pThis, argOne.get())); |
| 5873 } | 6074 } |
| 5874 } else { | 6075 } else { |
| 5875 CXFA_FM2JSContext* pContext = | 6076 CXFA_FM2JSContext* pContext = |
| 5876 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6077 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5877 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6078 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5878 } | 6079 } |
| 5879 } | 6080 } |
| 6081 |
| 6082 // static |
| 5880 void CXFA_FM2JSContext::negative_operator(CFXJSE_Value* pThis, | 6083 void CXFA_FM2JSContext::negative_operator(CFXJSE_Value* pThis, |
| 5881 const CFX_ByteStringC& szFuncName, | 6084 const CFX_ByteStringC& szFuncName, |
| 5882 CFXJSE_Arguments& args) { | 6085 CFXJSE_Arguments& args) { |
| 5883 int32_t iLength = args.GetLength(); | 6086 if (args.GetLength() == 1) { |
| 5884 if (iLength == 1) { | |
| 5885 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 6087 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 5886 if (FXJSE_Value_IsNull(argOne.get())) { | 6088 if (FXJSE_Value_IsNull(argOne.get())) { |
| 5887 FXJSE_Value_SetNull(args.GetReturnValue()); | 6089 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5888 } else { | 6090 } else { |
| 5889 FXJSE_Value_SetDouble(args.GetReturnValue(), | 6091 FXJSE_Value_SetDouble(args.GetReturnValue(), |
| 5890 0.0 - ValueToDouble(pThis, argOne.get())); | 6092 0.0 - ValueToDouble(pThis, argOne.get())); |
| 5891 } | 6093 } |
| 5892 } else { | 6094 } else { |
| 5893 CXFA_FM2JSContext* pContext = | 6095 CXFA_FM2JSContext* pContext = |
| 5894 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6096 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5895 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6097 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5896 } | 6098 } |
| 5897 } | 6099 } |
| 6100 |
| 6101 // static |
| 5898 void CXFA_FM2JSContext::logical_not_operator(CFXJSE_Value* pThis, | 6102 void CXFA_FM2JSContext::logical_not_operator(CFXJSE_Value* pThis, |
| 5899 const CFX_ByteStringC& szFuncName, | 6103 const CFX_ByteStringC& szFuncName, |
| 5900 CFXJSE_Arguments& args) { | 6104 CFXJSE_Arguments& args) { |
| 5901 int32_t iLength = args.GetLength(); | 6105 if (args.GetLength() == 1) { |
| 5902 if (iLength == 1) { | |
| 5903 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 6106 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 5904 if (FXJSE_Value_IsNull(argOne.get())) { | 6107 if (FXJSE_Value_IsNull(argOne.get())) { |
| 5905 FXJSE_Value_SetNull(args.GetReturnValue()); | 6108 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 5906 } else { | 6109 } else { |
| 5907 FX_DOUBLE first = ValueToDouble(pThis, argOne.get()); | 6110 FX_DOUBLE first = ValueToDouble(pThis, argOne.get()); |
| 5908 FXJSE_Value_SetInteger(args.GetReturnValue(), (first == 0.0) ? 1 : 0); | 6111 FXJSE_Value_SetInteger(args.GetReturnValue(), (first == 0.0) ? 1 : 0); |
| 5909 } | 6112 } |
| 5910 } else { | 6113 } else { |
| 5911 CXFA_FM2JSContext* pContext = | 6114 CXFA_FM2JSContext* pContext = |
| 5912 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6115 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5913 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6116 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 5914 } | 6117 } |
| 5915 } | 6118 } |
| 6119 |
| 6120 // static |
| 5916 void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis, | 6121 void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis, |
| 5917 const CFX_ByteStringC& szFuncName, | 6122 const CFX_ByteStringC& szFuncName, |
| 5918 CFXJSE_Arguments& args) { | 6123 CFXJSE_Arguments& args) { |
| 5919 CXFA_FM2JSContext* pContext = | 6124 CXFA_FM2JSContext* pContext = |
| 5920 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6125 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 5921 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6126 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 5922 int32_t argc = args.GetLength(); | 6127 int32_t argc = args.GetLength(); |
| 5923 if ((argc == 4) || (argc == 5)) { | 6128 if ((argc == 4) || (argc == 5)) { |
| 5924 FX_BOOL bIsStar = TRUE; | 6129 FX_BOOL bIsStar = TRUE; |
| 5925 std::unique_ptr<CFXJSE_Value> argAccessor = args.GetValue(0); | 6130 std::unique_ptr<CFXJSE_Value> argAccessor = args.GetValue(0); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6053 CFX_WideString::FromUTF8(szSomExp.AsStringC()); | 6258 CFX_WideString::FromUTF8(szSomExp.AsStringC()); |
| 6054 pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, | 6259 pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, |
| 6055 wsPropertyName.c_str(), | 6260 wsPropertyName.c_str(), |
| 6056 wsSomExpression.c_str()); | 6261 wsSomExpression.c_str()); |
| 6057 } | 6262 } |
| 6058 } | 6263 } |
| 6059 } else { | 6264 } else { |
| 6060 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6265 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6061 } | 6266 } |
| 6062 } | 6267 } |
| 6268 |
| 6269 // static |
| 6063 void CXFA_FM2JSContext::dotdot_accessor(CFXJSE_Value* pThis, | 6270 void CXFA_FM2JSContext::dotdot_accessor(CFXJSE_Value* pThis, |
| 6064 const CFX_ByteStringC& szFuncName, | 6271 const CFX_ByteStringC& szFuncName, |
| 6065 CFXJSE_Arguments& args) { | 6272 CFXJSE_Arguments& args) { |
| 6066 CXFA_FM2JSContext* pContext = | 6273 CXFA_FM2JSContext* pContext = |
| 6067 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6274 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6068 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6275 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6069 int32_t argc = args.GetLength(); | 6276 int32_t argc = args.GetLength(); |
| 6070 if ((argc == 4) || (argc == 5)) { | 6277 if ((argc == 4) || (argc == 5)) { |
| 6071 FX_BOOL bIsStar = TRUE; | 6278 FX_BOOL bIsStar = TRUE; |
| 6072 std::unique_ptr<CFXJSE_Value> argAccessor = args.GetValue(0); | 6279 std::unique_ptr<CFXJSE_Value> argAccessor = args.GetValue(0); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6195 CFX_WideString::FromUTF8(szSomExp.AsStringC()); | 6402 CFX_WideString::FromUTF8(szSomExp.AsStringC()); |
| 6196 pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, | 6403 pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, |
| 6197 wsPropertyName.c_str(), | 6404 wsPropertyName.c_str(), |
| 6198 wsSomExpression.c_str()); | 6405 wsSomExpression.c_str()); |
| 6199 } | 6406 } |
| 6200 } | 6407 } |
| 6201 } else { | 6408 } else { |
| 6202 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6409 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6203 } | 6410 } |
| 6204 } | 6411 } |
| 6412 |
| 6413 // static |
| 6205 void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis, | 6414 void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis, |
| 6206 const CFX_ByteStringC& szFuncName, | 6415 const CFX_ByteStringC& szFuncName, |
| 6207 CFXJSE_Arguments& args) { | 6416 CFXJSE_Arguments& args) { |
| 6208 CXFA_FM2JSContext* pContext = | 6417 CXFA_FM2JSContext* pContext = |
| 6209 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6418 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6210 int32_t argc = args.GetLength(); | 6419 if (args.GetLength() == 1) { |
| 6211 if (argc == 1) { | |
| 6212 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 6420 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
| 6213 CFX_ByteString argString; | 6421 CFX_ByteString argString; |
| 6214 ValueToUTF8String(argOne.get(), argString); | 6422 ValueToUTF8String(argOne.get(), argString); |
| 6215 if (argString.IsEmpty()) { | 6423 if (argString.IsEmpty()) { |
| 6216 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 6424 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 6217 } else { | 6425 } else { |
| 6218 CFX_WideString scriptString = | 6426 CFX_WideString scriptString = |
| 6219 CFX_WideString::FromUTF8(argString.AsStringC()); | 6427 CFX_WideString::FromUTF8(argString.AsStringC()); |
| 6220 CFX_WideTextBuf wsJavaScriptBuf; | 6428 CFX_WideTextBuf wsJavaScriptBuf; |
| 6221 CFX_WideString wsError; | 6429 CFX_WideString wsError; |
| 6222 XFA_FM2JS_Translate(scriptString.AsStringC(), wsJavaScriptBuf, wsError); | 6430 XFA_FM2JS_Translate(scriptString.AsStringC(), wsJavaScriptBuf, wsError); |
| 6223 if (wsError.IsEmpty()) { | 6431 if (wsError.IsEmpty()) { |
| 6224 CFX_WideString javaScript = wsJavaScriptBuf.MakeString(); | 6432 CFX_WideString javaScript = wsJavaScriptBuf.MakeString(); |
| 6225 FXJSE_Value_SetUTF8String( | 6433 FXJSE_Value_SetUTF8String( |
| 6226 args.GetReturnValue(), | 6434 args.GetReturnValue(), |
| 6227 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()) | 6435 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()) |
| 6228 .AsStringC()); | 6436 .AsStringC()); |
| 6229 } else { | 6437 } else { |
| 6230 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6438 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6231 } | 6439 } |
| 6232 } | 6440 } |
| 6233 } else { | 6441 } else { |
| 6234 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 6442 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
| 6235 L"Eval"); | 6443 L"Eval"); |
| 6236 } | 6444 } |
| 6237 } | 6445 } |
| 6446 |
| 6447 // static |
| 6238 void CXFA_FM2JSContext::is_fm_object(CFXJSE_Value* pThis, | 6448 void CXFA_FM2JSContext::is_fm_object(CFXJSE_Value* pThis, |
| 6239 const CFX_ByteStringC& szFuncName, | 6449 const CFX_ByteStringC& szFuncName, |
| 6240 CFXJSE_Arguments& args) { | 6450 CFXJSE_Arguments& args) { |
| 6241 int32_t iLength = args.GetLength(); | 6451 if (args.GetLength() == 1) { |
| 6242 if (iLength == 1) { | |
| 6243 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 6452 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 6244 FXJSE_Value_SetBoolean(args.GetReturnValue(), | 6453 FXJSE_Value_SetBoolean(args.GetReturnValue(), |
| 6245 FXJSE_Value_IsObject(argOne.get())); | 6454 FXJSE_Value_IsObject(argOne.get())); |
| 6246 } else { | 6455 } else { |
| 6247 FXJSE_Value_SetBoolean(args.GetReturnValue(), FALSE); | 6456 FXJSE_Value_SetBoolean(args.GetReturnValue(), FALSE); |
| 6248 } | 6457 } |
| 6249 } | 6458 } |
| 6459 |
| 6460 // static |
| 6250 void CXFA_FM2JSContext::is_fm_array(CFXJSE_Value* pThis, | 6461 void CXFA_FM2JSContext::is_fm_array(CFXJSE_Value* pThis, |
| 6251 const CFX_ByteStringC& szFuncName, | 6462 const CFX_ByteStringC& szFuncName, |
| 6252 CFXJSE_Arguments& args) { | 6463 CFXJSE_Arguments& args) { |
| 6253 int32_t iLength = args.GetLength(); | 6464 if (args.GetLength() == 1) { |
| 6254 if (iLength == 1) { | |
| 6255 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 6465 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 6256 FX_BOOL bIsArray = FXJSE_Value_IsArray(argOne.get()); | 6466 FX_BOOL bIsArray = FXJSE_Value_IsArray(argOne.get()); |
| 6257 FXJSE_Value_SetBoolean(args.GetReturnValue(), bIsArray); | 6467 FXJSE_Value_SetBoolean(args.GetReturnValue(), bIsArray); |
| 6258 } else { | 6468 } else { |
| 6259 FXJSE_Value_SetBoolean(args.GetReturnValue(), FALSE); | 6469 FXJSE_Value_SetBoolean(args.GetReturnValue(), FALSE); |
| 6260 } | 6470 } |
| 6261 } | 6471 } |
| 6472 |
| 6473 // static |
| 6262 void CXFA_FM2JSContext::get_fm_value(CFXJSE_Value* pThis, | 6474 void CXFA_FM2JSContext::get_fm_value(CFXJSE_Value* pThis, |
| 6263 const CFX_ByteStringC& szFuncName, | 6475 const CFX_ByteStringC& szFuncName, |
| 6264 CFXJSE_Arguments& args) { | 6476 CFXJSE_Arguments& args) { |
| 6265 CXFA_FM2JSContext* pContext = | 6477 CXFA_FM2JSContext* pContext = |
| 6266 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6478 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6267 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6479 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6268 int32_t iLength = args.GetLength(); | 6480 if (args.GetLength() == 1) { |
| 6269 if (iLength == 1) { | |
| 6270 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 6481 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 6271 if (FXJSE_Value_IsArray(argOne.get())) { | 6482 if (FXJSE_Value_IsArray(argOne.get())) { |
| 6272 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 6483 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 6273 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 6484 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 6274 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 1, propertyValue.get()); | 6485 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 1, propertyValue.get()); |
| 6275 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, jsObjectValue.get()); | 6486 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, jsObjectValue.get()); |
| 6276 if (FXJSE_Value_IsNull(propertyValue.get())) { | 6487 if (FXJSE_Value_IsNull(propertyValue.get())) { |
| 6277 GetObjectDefaultValue(jsObjectValue.get(), args.GetReturnValue()); | 6488 GetObjectDefaultValue(jsObjectValue.get(), args.GetReturnValue()); |
| 6278 } else { | 6489 } else { |
| 6279 CFX_ByteString propertyStr; | 6490 CFX_ByteString propertyStr; |
| 6280 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); | 6491 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); |
| 6281 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), | 6492 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), |
| 6282 args.GetReturnValue()); | 6493 args.GetReturnValue()); |
| 6283 } | 6494 } |
| 6284 } else if (FXJSE_Value_IsObject(argOne.get())) { | 6495 } else if (FXJSE_Value_IsObject(argOne.get())) { |
| 6285 GetObjectDefaultValue(argOne.get(), args.GetReturnValue()); | 6496 GetObjectDefaultValue(argOne.get(), args.GetReturnValue()); |
| 6286 } else { | 6497 } else { |
| 6287 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); | 6498 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); |
| 6288 } | 6499 } |
| 6289 } else { | 6500 } else { |
| 6290 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6501 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6291 } | 6502 } |
| 6292 } | 6503 } |
| 6504 |
| 6505 // static |
| 6293 void CXFA_FM2JSContext::get_fm_jsobj(CFXJSE_Value* pThis, | 6506 void CXFA_FM2JSContext::get_fm_jsobj(CFXJSE_Value* pThis, |
| 6294 const CFX_ByteStringC& szFuncName, | 6507 const CFX_ByteStringC& szFuncName, |
| 6295 CFXJSE_Arguments& args) { | 6508 CFXJSE_Arguments& args) { |
| 6296 CXFA_FM2JSContext* pContext = | 6509 if (args.GetLength() == 1) { |
| 6297 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); | |
| 6298 int32_t argc = args.GetLength(); | |
| 6299 if (argc == 1) { | |
| 6300 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 6510 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 6301 if (FXJSE_Value_IsArray(argOne.get())) { | 6511 if (FXJSE_Value_IsArray(argOne.get())) { |
| 6302 #ifndef NDEBUG | 6512 #ifndef NDEBUG |
| 6513 CXFA_FM2JSContext* pContext = |
| 6514 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); |
| 6303 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6515 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6304 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 6516 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 6305 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get()); | 6517 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get()); |
| 6306 ASSERT(FXJSE_Value_ToInteger(lengthValue.get()) >= 3); | 6518 ASSERT(FXJSE_Value_ToInteger(lengthValue.get()) >= 3); |
| 6307 #endif | 6519 #endif |
| 6308 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, args.GetReturnValue()); | 6520 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, args.GetReturnValue()); |
| 6309 } else { | 6521 } else { |
| 6310 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); | 6522 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); |
| 6311 } | 6523 } |
| 6312 } else { | 6524 } else { |
| 6525 CXFA_FM2JSContext* pContext = |
| 6526 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); |
| 6313 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6527 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6314 } | 6528 } |
| 6315 } | 6529 } |
| 6530 |
| 6531 // static |
| 6316 void CXFA_FM2JSContext::fm_var_filter(CFXJSE_Value* pThis, | 6532 void CXFA_FM2JSContext::fm_var_filter(CFXJSE_Value* pThis, |
| 6317 const CFX_ByteStringC& szFuncName, | 6533 const CFX_ByteStringC& szFuncName, |
| 6318 CFXJSE_Arguments& args) { | 6534 CFXJSE_Arguments& args) { |
| 6319 CXFA_FM2JSContext* pContext = | 6535 CXFA_FM2JSContext* pContext = |
| 6320 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6536 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6321 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6537 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6322 int32_t argc = args.GetLength(); | 6538 if (args.GetLength() == 1) { |
| 6323 if (argc == 1) { | |
| 6324 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 6539 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 6325 if (FXJSE_Value_IsArray(argOne.get())) { | 6540 if (FXJSE_Value_IsArray(argOne.get())) { |
| 6326 #ifndef NDEBUG | 6541 #ifndef NDEBUG |
| 6327 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 6542 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 6328 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get()); | 6543 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get()); |
| 6329 ASSERT(FXJSE_Value_ToInteger(lengthValue.get()) >= 3); | 6544 ASSERT(FXJSE_Value_ToInteger(lengthValue.get()) >= 3); |
| 6330 #endif | 6545 #endif |
| 6331 std::unique_ptr<CFXJSE_Value> flagsValue(new CFXJSE_Value(pIsolate)); | 6546 std::unique_ptr<CFXJSE_Value> flagsValue(new CFXJSE_Value(pIsolate)); |
| 6332 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 0, flagsValue.get()); | 6547 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 0, flagsValue.get()); |
| 6333 int32_t iFlags = FXJSE_Value_ToInteger(flagsValue.get()); | 6548 int32_t iFlags = FXJSE_Value_ToInteger(flagsValue.get()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 6357 } | 6572 } |
| 6358 } else { | 6573 } else { |
| 6359 std::unique_ptr<CFXJSE_Value> simpleValue = | 6574 std::unique_ptr<CFXJSE_Value> simpleValue = |
| 6360 GetSimpleValue(pThis, args, 0); | 6575 GetSimpleValue(pThis, args, 0); |
| 6361 FXJSE_Value_Set(args.GetReturnValue(), simpleValue.get()); | 6576 FXJSE_Value_Set(args.GetReturnValue(), simpleValue.get()); |
| 6362 } | 6577 } |
| 6363 } else { | 6578 } else { |
| 6364 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6579 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
| 6365 } | 6580 } |
| 6366 } | 6581 } |
| 6582 |
| 6583 // static |
| 6367 void CXFA_FM2JSContext::concat_fm_object(CFXJSE_Value* pThis, | 6584 void CXFA_FM2JSContext::concat_fm_object(CFXJSE_Value* pThis, |
| 6368 const CFX_ByteStringC& szFuncName, | 6585 const CFX_ByteStringC& szFuncName, |
| 6369 CFXJSE_Arguments& args) { | 6586 CFXJSE_Arguments& args) { |
| 6370 CXFA_FM2JSContext* pContext = | 6587 CXFA_FM2JSContext* pContext = |
| 6371 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6588 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6372 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6589 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6373 uint32_t iLength = 0; | 6590 uint32_t iLength = 0; |
| 6374 int32_t argCount = args.GetLength(); | 6591 int32_t argc = args.GetLength(); |
| 6375 std::vector<std::unique_ptr<CFXJSE_Value>> argValues; | 6592 std::vector<std::unique_ptr<CFXJSE_Value>> argValues; |
| 6376 for (int32_t i = 0; i < argCount; i++) { | 6593 for (int32_t i = 0; i < argc; i++) { |
| 6377 argValues.push_back(args.GetValue(i)); | 6594 argValues.push_back(args.GetValue(i)); |
| 6378 if (FXJSE_Value_IsArray(argValues[i].get())) { | 6595 if (FXJSE_Value_IsArray(argValues[i].get())) { |
| 6379 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 6596 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 6380 FXJSE_Value_GetObjectProp(argValues[i].get(), "length", | 6597 FXJSE_Value_GetObjectProp(argValues[i].get(), "length", |
| 6381 lengthValue.get()); | 6598 lengthValue.get()); |
| 6382 int32_t length = FXJSE_Value_ToInteger(lengthValue.get()); | 6599 int32_t length = FXJSE_Value_ToInteger(lengthValue.get()); |
| 6383 iLength = iLength + ((length > 2) ? (length - 2) : 0); | 6600 iLength = iLength + ((length > 2) ? (length - 2) : 0); |
| 6384 } | 6601 } |
| 6385 iLength += 1; | 6602 iLength += 1; |
| 6386 } | 6603 } |
| 6387 CFXJSE_Value** returnValues = FX_Alloc(CFXJSE_Value*, iLength); | 6604 CFXJSE_Value** returnValues = FX_Alloc(CFXJSE_Value*, iLength); |
| 6388 for (int32_t i = 0; i < (int32_t)iLength; i++) | 6605 for (int32_t i = 0; i < (int32_t)iLength; i++) |
| 6389 returnValues[i] = new CFXJSE_Value(pIsolate); | 6606 returnValues[i] = new CFXJSE_Value(pIsolate); |
| 6390 | 6607 |
| 6391 int32_t index = 0; | 6608 int32_t index = 0; |
| 6392 for (int32_t i = 0; i < argCount; i++) { | 6609 for (int32_t i = 0; i < argc; i++) { |
| 6393 if (FXJSE_Value_IsArray(argValues[i].get())) { | 6610 if (FXJSE_Value_IsArray(argValues[i].get())) { |
| 6394 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 6611 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 6395 FXJSE_Value_GetObjectProp(argValues[i].get(), "length", | 6612 FXJSE_Value_GetObjectProp(argValues[i].get(), "length", |
| 6396 lengthValue.get()); | 6613 lengthValue.get()); |
| 6397 int32_t length = FXJSE_Value_ToInteger(lengthValue.get()); | 6614 int32_t length = FXJSE_Value_ToInteger(lengthValue.get()); |
| 6398 for (int32_t j = 2; j < length; j++) { | 6615 for (int32_t j = 2; j < length; j++) { |
| 6399 FXJSE_Value_GetObjectPropByIdx(argValues[i].get(), j, | 6616 FXJSE_Value_GetObjectPropByIdx(argValues[i].get(), j, |
| 6400 returnValues[index]); | 6617 returnValues[index]); |
| 6401 index++; | 6618 index++; |
| 6402 } | 6619 } |
| 6403 } | 6620 } |
| 6404 FXJSE_Value_Set(returnValues[index], argValues[i].get()); | 6621 FXJSE_Value_Set(returnValues[index], argValues[i].get()); |
| 6405 index++; | 6622 index++; |
| 6406 } | 6623 } |
| 6407 FXJSE_Value_SetArray(args.GetReturnValue(), iLength, returnValues); | 6624 FXJSE_Value_SetArray(args.GetReturnValue(), iLength, returnValues); |
| 6408 for (int32_t i = 0; i < (int32_t)iLength; i++) | 6625 for (int32_t i = 0; i < (int32_t)iLength; i++) |
| 6409 delete returnValues[i]; | 6626 delete returnValues[i]; |
| 6410 | 6627 |
| 6411 FX_Free(returnValues); | 6628 FX_Free(returnValues); |
| 6412 } | 6629 } |
| 6630 |
| 6631 // static |
| 6413 std::unique_ptr<CFXJSE_Value> CXFA_FM2JSContext::GetSimpleValue( | 6632 std::unique_ptr<CFXJSE_Value> CXFA_FM2JSContext::GetSimpleValue( |
| 6414 CFXJSE_Value* pThis, | 6633 CFXJSE_Value* pThis, |
| 6415 CFXJSE_Arguments& args, | 6634 CFXJSE_Arguments& args, |
| 6416 uint32_t index) { | 6635 uint32_t index) { |
| 6417 CXFA_FM2JSContext* pContext = | 6636 CXFA_FM2JSContext* pContext = |
| 6418 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6637 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6419 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6638 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6420 ASSERT(index < (uint32_t)args.GetLength()); | 6639 ASSERT(index < (uint32_t)args.GetLength()); |
| 6421 std::unique_ptr<CFXJSE_Value> argIndex = args.GetValue(index); | 6640 std::unique_ptr<CFXJSE_Value> argIndex = args.GetValue(index); |
| 6422 if (FXJSE_Value_IsArray(argIndex.get())) { | 6641 if (FXJSE_Value_IsArray(argIndex.get())) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 6443 return simpleValue; | 6662 return simpleValue; |
| 6444 } else if (FXJSE_Value_IsObject(argIndex.get())) { | 6663 } else if (FXJSE_Value_IsObject(argIndex.get())) { |
| 6445 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); | 6664 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); |
| 6446 GetObjectDefaultValue(argIndex.get(), defaultValue.get()); | 6665 GetObjectDefaultValue(argIndex.get(), defaultValue.get()); |
| 6447 return defaultValue; | 6666 return defaultValue; |
| 6448 } else { | 6667 } else { |
| 6449 return argIndex; | 6668 return argIndex; |
| 6450 } | 6669 } |
| 6451 } | 6670 } |
| 6452 | 6671 |
| 6672 // static |
| 6453 FX_BOOL CXFA_FM2JSContext::ValueIsNull(CFXJSE_Value* pThis, CFXJSE_Value* arg) { | 6673 FX_BOOL CXFA_FM2JSContext::ValueIsNull(CFXJSE_Value* pThis, CFXJSE_Value* arg) { |
| 6454 CXFA_FM2JSContext* pContext = | 6674 CXFA_FM2JSContext* pContext = |
| 6455 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6675 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6456 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6676 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6457 FX_BOOL isNull = FALSE; | 6677 FX_BOOL isNull = FALSE; |
| 6458 if (FXJSE_Value_IsNull(arg)) { | 6678 if (FXJSE_Value_IsNull(arg)) { |
| 6459 isNull = TRUE; | 6679 isNull = TRUE; |
| 6460 } else if (FXJSE_Value_IsArray(arg)) { | 6680 } else if (FXJSE_Value_IsArray(arg)) { |
| 6461 int32_t iLength = hvalue_get_array_length(pThis, arg); | 6681 int32_t iLength = hvalue_get_array_length(pThis, arg); |
| 6462 if (iLength > 2) { | 6682 if (iLength > 2) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 6487 } else if (FXJSE_Value_IsObject(arg)) { | 6707 } else if (FXJSE_Value_IsObject(arg)) { |
| 6488 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); | 6708 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); |
| 6489 GetObjectDefaultValue(arg, defaultValue.get()); | 6709 GetObjectDefaultValue(arg, defaultValue.get()); |
| 6490 if (FXJSE_Value_IsNull(defaultValue.get())) { | 6710 if (FXJSE_Value_IsNull(defaultValue.get())) { |
| 6491 isNull = TRUE; | 6711 isNull = TRUE; |
| 6492 } | 6712 } |
| 6493 } | 6713 } |
| 6494 return isNull; | 6714 return isNull; |
| 6495 } | 6715 } |
| 6496 | 6716 |
| 6717 // static |
| 6497 int32_t CXFA_FM2JSContext::hvalue_get_array_length(CFXJSE_Value* pThis, | 6718 int32_t CXFA_FM2JSContext::hvalue_get_array_length(CFXJSE_Value* pThis, |
| 6498 CFXJSE_Value* arg) { | 6719 CFXJSE_Value* arg) { |
| 6499 CXFA_FM2JSContext* pContext = | 6720 CXFA_FM2JSContext* pContext = |
| 6500 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6721 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6501 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6722 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6502 int32_t iLength = 0; | 6723 int32_t iLength = 0; |
| 6503 if (FXJSE_Value_IsArray(arg)) { | 6724 if (FXJSE_Value_IsArray(arg)) { |
| 6504 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 6725 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 6505 FXJSE_Value_GetObjectProp(arg, "length", lengthValue.get()); | 6726 FXJSE_Value_GetObjectProp(arg, "length", lengthValue.get()); |
| 6506 iLength = FXJSE_Value_ToInteger(lengthValue.get()); | 6727 iLength = FXJSE_Value_ToInteger(lengthValue.get()); |
| 6507 } | 6728 } |
| 6508 return iLength; | 6729 return iLength; |
| 6509 } | 6730 } |
| 6731 |
| 6732 // static |
| 6510 FX_BOOL CXFA_FM2JSContext::simpleValueCompare(CFXJSE_Value* pThis, | 6733 FX_BOOL CXFA_FM2JSContext::simpleValueCompare(CFXJSE_Value* pThis, |
| 6511 CFXJSE_Value* firstValue, | 6734 CFXJSE_Value* firstValue, |
| 6512 CFXJSE_Value* secondValue) { | 6735 CFXJSE_Value* secondValue) { |
| 6513 FX_BOOL bReturn = FALSE; | 6736 FX_BOOL bReturn = FALSE; |
| 6514 if (FXJSE_Value_IsUTF8String(firstValue)) { | 6737 if (FXJSE_Value_IsUTF8String(firstValue)) { |
| 6515 CFX_ByteString firstString, secondString; | 6738 CFX_ByteString firstString, secondString; |
| 6516 ValueToUTF8String(firstValue, firstString); | 6739 ValueToUTF8String(firstValue, firstString); |
| 6517 ValueToUTF8String(secondValue, secondString); | 6740 ValueToUTF8String(secondValue, secondString); |
| 6518 bReturn = firstString == secondString; | 6741 bReturn = firstString == secondString; |
| 6519 } else if (FXJSE_Value_IsNumber(firstValue)) { | 6742 } else if (FXJSE_Value_IsNumber(firstValue)) { |
| 6520 FX_FLOAT first = ValueToFloat(pThis, firstValue); | 6743 FX_FLOAT first = ValueToFloat(pThis, firstValue); |
| 6521 FX_FLOAT second = ValueToFloat(pThis, secondValue); | 6744 FX_FLOAT second = ValueToFloat(pThis, secondValue); |
| 6522 bReturn = (first == second); | 6745 bReturn = (first == second); |
| 6523 } else if (FXJSE_Value_IsBoolean(firstValue)) { | 6746 } else if (FXJSE_Value_IsBoolean(firstValue)) { |
| 6524 bReturn = (FXJSE_Value_ToBoolean(firstValue) == | 6747 bReturn = (FXJSE_Value_ToBoolean(firstValue) == |
| 6525 FXJSE_Value_ToBoolean(secondValue)); | 6748 FXJSE_Value_ToBoolean(secondValue)); |
| 6526 } else if (FXJSE_Value_IsNull(firstValue) && | 6749 } else if (FXJSE_Value_IsNull(firstValue) && |
| 6527 FXJSE_Value_IsNull(secondValue)) { | 6750 FXJSE_Value_IsNull(secondValue)) { |
| 6528 bReturn = TRUE; | 6751 bReturn = TRUE; |
| 6529 } | 6752 } |
| 6530 return bReturn; | 6753 return bReturn; |
| 6531 } | 6754 } |
| 6755 |
| 6756 // static |
| 6532 void CXFA_FM2JSContext::unfoldArgs(CFXJSE_Value* pThis, | 6757 void CXFA_FM2JSContext::unfoldArgs(CFXJSE_Value* pThis, |
| 6533 CFXJSE_Arguments& args, | 6758 CFXJSE_Arguments& args, |
| 6534 CFXJSE_Value**& resultValues, | 6759 CFXJSE_Value**& resultValues, |
| 6535 int32_t& iCount, | 6760 int32_t& iCount, |
| 6536 int32_t iStart) { | 6761 int32_t iStart) { |
| 6537 CXFA_FM2JSContext* pContext = | 6762 CXFA_FM2JSContext* pContext = |
| 6538 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6763 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6539 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6764 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6540 iCount = 0; | 6765 iCount = 0; |
| 6541 int32_t argc = args.GetLength(); | 6766 int32_t argc = args.GetLength(); |
| 6542 | |
| 6543 std::vector<std::unique_ptr<CFXJSE_Value>> argsValue; | 6767 std::vector<std::unique_ptr<CFXJSE_Value>> argsValue; |
| 6544 for (int32_t i = 0; i < argc - iStart; i++) { | 6768 for (int32_t i = 0; i < argc - iStart; i++) { |
| 6545 argsValue.push_back(args.GetValue(i + iStart)); | 6769 argsValue.push_back(args.GetValue(i + iStart)); |
| 6546 if (FXJSE_Value_IsArray(argsValue[i].get())) { | 6770 if (FXJSE_Value_IsArray(argsValue[i].get())) { |
| 6547 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 6771 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 6548 FXJSE_Value_GetObjectProp(argsValue[i].get(), "length", | 6772 FXJSE_Value_GetObjectProp(argsValue[i].get(), "length", |
| 6549 lengthValue.get()); | 6773 lengthValue.get()); |
| 6550 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); | 6774 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); |
| 6551 iCount += ((iLength > 2) ? (iLength - 2) : 0); | 6775 iCount += ((iLength > 2) ? (iLength - 2) : 0); |
| 6552 } else { | 6776 } else { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6592 } else if (FXJSE_Value_IsObject(argsValue[i].get())) { | 6816 } else if (FXJSE_Value_IsObject(argsValue[i].get())) { |
| 6593 GetObjectDefaultValue(argsValue[i].get(), resultValues[index]); | 6817 GetObjectDefaultValue(argsValue[i].get(), resultValues[index]); |
| 6594 index++; | 6818 index++; |
| 6595 } else { | 6819 } else { |
| 6596 FXJSE_Value_Set(resultValues[index], argsValue[i].get()); | 6820 FXJSE_Value_Set(resultValues[index], argsValue[i].get()); |
| 6597 index++; | 6821 index++; |
| 6598 } | 6822 } |
| 6599 } | 6823 } |
| 6600 } | 6824 } |
| 6601 | 6825 |
| 6826 // static |
| 6602 void CXFA_FM2JSContext::GetObjectDefaultValue(CFXJSE_Value* pObjectValue, | 6827 void CXFA_FM2JSContext::GetObjectDefaultValue(CFXJSE_Value* pObjectValue, |
| 6603 CFXJSE_Value* pDefaultValue) { | 6828 CFXJSE_Value* pDefaultValue) { |
| 6604 CXFA_Node* pNode = | 6829 CXFA_Node* pNode = |
| 6605 ToNode((CXFA_Object*)FXJSE_Value_ToObject(pObjectValue, nullptr)); | 6830 ToNode((CXFA_Object*)FXJSE_Value_ToObject(pObjectValue, nullptr)); |
| 6606 if (pNode) { | 6831 if (pNode) { |
| 6607 pNode->Script_Som_DefaultValue(pDefaultValue, FALSE, (XFA_ATTRIBUTE)-1); | 6832 pNode->Script_Som_DefaultValue(pDefaultValue, FALSE, (XFA_ATTRIBUTE)-1); |
| 6608 } else { | 6833 } else { |
| 6609 FXJSE_Value_SetNull(pDefaultValue); | 6834 FXJSE_Value_SetNull(pDefaultValue); |
| 6610 } | 6835 } |
| 6611 } | 6836 } |
| 6837 |
| 6838 // static |
| 6612 FX_BOOL CXFA_FM2JSContext::SetObjectDefaultValue(CFXJSE_Value* pObjectValue, | 6839 FX_BOOL CXFA_FM2JSContext::SetObjectDefaultValue(CFXJSE_Value* pObjectValue, |
| 6613 CFXJSE_Value* hNewValue) { | 6840 CFXJSE_Value* hNewValue) { |
| 6614 CXFA_Node* pNode = | 6841 CXFA_Node* pNode = |
| 6615 ToNode((CXFA_Object*)FXJSE_Value_ToObject(pObjectValue, nullptr)); | 6842 ToNode((CXFA_Object*)FXJSE_Value_ToObject(pObjectValue, nullptr)); |
| 6616 if (pNode) { | 6843 if (pNode) { |
| 6617 pNode->Script_Som_DefaultValue(hNewValue, TRUE, (XFA_ATTRIBUTE)-1); | 6844 pNode->Script_Som_DefaultValue(hNewValue, TRUE, (XFA_ATTRIBUTE)-1); |
| 6618 return TRUE; | 6845 return TRUE; |
| 6619 } | 6846 } |
| 6620 return FALSE; | 6847 return FALSE; |
| 6621 } | 6848 } |
| 6849 |
| 6850 // static |
| 6622 void CXFA_FM2JSContext::GenerateSomExpression(const CFX_ByteStringC& szName, | 6851 void CXFA_FM2JSContext::GenerateSomExpression(const CFX_ByteStringC& szName, |
| 6623 int32_t iIndexFlags, | 6852 int32_t iIndexFlags, |
| 6624 int32_t iIndexValue, | 6853 int32_t iIndexValue, |
| 6625 FX_BOOL bIsStar, | 6854 FX_BOOL bIsStar, |
| 6626 CFX_ByteString& szSomExp) { | 6855 CFX_ByteString& szSomExp) { |
| 6627 if (bIsStar) { | 6856 if (bIsStar) { |
| 6628 szSomExp = szName + "[*]"; | 6857 szSomExp = szName + "[*]"; |
| 6629 return; | 6858 return; |
| 6630 } | 6859 } |
| 6631 if (iIndexFlags == 0) { | 6860 if (iIndexFlags == 0) { |
| 6632 szSomExp = szName; | 6861 szSomExp = szName; |
| 6633 return; | 6862 return; |
| 6634 } | 6863 } |
| 6635 if (iIndexFlags == 1 || iIndexValue == 0) { | 6864 if (iIndexFlags == 1 || iIndexValue == 0) { |
| 6636 szSomExp = szName + "[" + | 6865 szSomExp = szName + "[" + |
| 6637 CFX_ByteString::FormatInteger(iIndexValue, FXFORMAT_SIGNED) + | 6866 CFX_ByteString::FormatInteger(iIndexValue, FXFORMAT_SIGNED) + |
| 6638 "]"; | 6867 "]"; |
| 6639 } else if (iIndexFlags == 2) { | 6868 } else if (iIndexFlags == 2) { |
| 6640 szSomExp = (iIndexValue < 0) ? (szName + "[-") : (szName + "[+"); | 6869 szSomExp = (iIndexValue < 0) ? (szName + "[-") : (szName + "[+"); |
| 6641 iIndexValue = (iIndexValue < 0) ? (0 - iIndexValue) : iIndexValue; | 6870 iIndexValue = (iIndexValue < 0) ? (0 - iIndexValue) : iIndexValue; |
| 6642 szSomExp += CFX_ByteString::FormatInteger(iIndexValue); | 6871 szSomExp += CFX_ByteString::FormatInteger(iIndexValue); |
| 6643 szSomExp += "]"; | 6872 szSomExp += "]"; |
| 6644 } else { | 6873 } else { |
| 6645 szSomExp = (iIndexValue < 0) ? (szName + "[") : (szName + "[-"); | 6874 szSomExp = (iIndexValue < 0) ? (szName + "[") : (szName + "[-"); |
| 6646 iIndexValue = (iIndexValue < 0) ? (0 - iIndexValue) : iIndexValue; | 6875 iIndexValue = (iIndexValue < 0) ? (0 - iIndexValue) : iIndexValue; |
| 6647 szSomExp += CFX_ByteString::FormatInteger(iIndexValue); | 6876 szSomExp += CFX_ByteString::FormatInteger(iIndexValue); |
| 6648 szSomExp += "]"; | 6877 szSomExp += "]"; |
| 6649 } | 6878 } |
| 6650 } | 6879 } |
| 6880 |
| 6881 // static |
| 6651 FX_BOOL CXFA_FM2JSContext::GetObjectByName( | 6882 FX_BOOL CXFA_FM2JSContext::GetObjectByName( |
| 6652 CFXJSE_Value* pThis, | 6883 CFXJSE_Value* pThis, |
| 6653 CFXJSE_Value* accessorValue, | 6884 CFXJSE_Value* accessorValue, |
| 6654 const CFX_ByteStringC& szAccessorName) { | 6885 const CFX_ByteStringC& szAccessorName) { |
| 6655 FX_BOOL bFlags = FALSE; | 6886 FX_BOOL bFlags = FALSE; |
| 6656 CXFA_FM2JSContext* pContext = | 6887 CXFA_FM2JSContext* pContext = |
| 6657 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6888 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6658 CXFA_Document* pDoc = pContext->GetDocument(); | 6889 CXFA_Document* pDoc = pContext->GetDocument(); |
| 6659 if (!pDoc) { | 6890 if (!pDoc) { |
| 6660 return bFlags; | 6891 return bFlags; |
| 6661 } | 6892 } |
| 6662 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); | 6893 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); |
| 6663 XFA_RESOLVENODE_RS resoveNodeRS; | 6894 XFA_RESOLVENODE_RS resoveNodeRS; |
| 6664 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | | 6895 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | |
| 6665 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; | 6896 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; |
| 6666 int32_t iRet = pScriptContext->ResolveObjects( | 6897 int32_t iRet = pScriptContext->ResolveObjects( |
| 6667 pScriptContext->GetThisObject(), | 6898 pScriptContext->GetThisObject(), |
| 6668 CFX_WideString::FromUTF8(szAccessorName).AsStringC(), resoveNodeRS, | 6899 CFX_WideString::FromUTF8(szAccessorName).AsStringC(), resoveNodeRS, |
| 6669 dwFlags); | 6900 dwFlags); |
| 6670 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { | 6901 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { |
| 6671 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( | 6902 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( |
| 6672 resoveNodeRS.nodes.GetAt(0))); | 6903 resoveNodeRS.nodes.GetAt(0))); |
| 6673 bFlags = TRUE; | 6904 bFlags = TRUE; |
| 6674 } | 6905 } |
| 6675 return bFlags; | 6906 return bFlags; |
| 6676 } | 6907 } |
| 6908 |
| 6909 // static |
| 6677 int32_t CXFA_FM2JSContext::ResolveObjects(CFXJSE_Value* pThis, | 6910 int32_t CXFA_FM2JSContext::ResolveObjects(CFXJSE_Value* pThis, |
| 6678 CFXJSE_Value* pRefValue, | 6911 CFXJSE_Value* pRefValue, |
| 6679 const CFX_ByteStringC& bsSomExp, | 6912 const CFX_ByteStringC& bsSomExp, |
| 6680 XFA_RESOLVENODE_RS& resoveNodeRS, | 6913 XFA_RESOLVENODE_RS& resoveNodeRS, |
| 6681 FX_BOOL bdotAccessor, | 6914 FX_BOOL bdotAccessor, |
| 6682 FX_BOOL bHasNoResolveName) { | 6915 FX_BOOL bHasNoResolveName) { |
| 6683 CFX_WideString wsSomExpression = CFX_WideString::FromUTF8(bsSomExp); | 6916 CFX_WideString wsSomExpression = CFX_WideString::FromUTF8(bsSomExp); |
| 6684 int32_t iRet = -1; | 6917 int32_t iRet = -1; |
| 6685 CXFA_FM2JSContext* pContext = | 6918 CXFA_FM2JSContext* pContext = |
| 6686 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6919 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6687 CXFA_Document* pDoc = pContext->GetDocument(); | 6920 CXFA_Document* pDoc = pContext->GetDocument(); |
| 6688 if (!pDoc) { | 6921 if (!pDoc) { |
| 6689 return iRet; | 6922 return iRet; |
| 6690 } | 6923 } |
| 6691 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); | 6924 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); |
| 6692 CXFA_Object* pNode = NULL; | 6925 CXFA_Object* pNode = nullptr; |
| 6693 uint32_t dFlags = 0UL; | 6926 uint32_t dFlags = 0UL; |
| 6694 if (bdotAccessor) { | 6927 if (bdotAccessor) { |
| 6695 if (FXJSE_Value_IsNull(pRefValue)) { | 6928 if (FXJSE_Value_IsNull(pRefValue)) { |
| 6696 pNode = pScriptContext->GetThisObject(); | 6929 pNode = pScriptContext->GetThisObject(); |
| 6697 dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; | 6930 dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; |
| 6698 } else { | 6931 } else { |
| 6699 pNode = (CXFA_Object*)FXJSE_Value_ToObject(pRefValue, nullptr); | 6932 pNode = (CXFA_Object*)FXJSE_Value_ToObject(pRefValue, nullptr); |
| 6700 ASSERT(pNode); | 6933 ASSERT(pNode); |
| 6701 if (bHasNoResolveName) { | 6934 if (bHasNoResolveName) { |
| 6702 CFX_WideString wsName; | 6935 CFX_WideString wsName; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 6718 } | 6951 } |
| 6719 } | 6952 } |
| 6720 } else { | 6953 } else { |
| 6721 pNode = (CXFA_Object*)FXJSE_Value_ToObject(pRefValue, nullptr); | 6954 pNode = (CXFA_Object*)FXJSE_Value_ToObject(pRefValue, nullptr); |
| 6722 dFlags = XFA_RESOLVENODE_AnyChild; | 6955 dFlags = XFA_RESOLVENODE_AnyChild; |
| 6723 } | 6956 } |
| 6724 iRet = pScriptContext->ResolveObjects(pNode, wsSomExpression.AsStringC(), | 6957 iRet = pScriptContext->ResolveObjects(pNode, wsSomExpression.AsStringC(), |
| 6725 resoveNodeRS, dFlags); | 6958 resoveNodeRS, dFlags); |
| 6726 return iRet; | 6959 return iRet; |
| 6727 } | 6960 } |
| 6961 |
| 6962 // static |
| 6728 void CXFA_FM2JSContext::ParseResolveResult( | 6963 void CXFA_FM2JSContext::ParseResolveResult( |
| 6729 CFXJSE_Value* pThis, | 6964 CFXJSE_Value* pThis, |
| 6730 const XFA_RESOLVENODE_RS& resoveNodeRS, | 6965 const XFA_RESOLVENODE_RS& resoveNodeRS, |
| 6731 CFXJSE_Value* pParentValue, | 6966 CFXJSE_Value* pParentValue, |
| 6732 CFXJSE_Value**& resultValues, | 6967 CFXJSE_Value**& resultValues, |
| 6733 int32_t& iSize, | 6968 int32_t& iSize, |
| 6734 FX_BOOL& bAttribute) { | 6969 FX_BOOL& bAttribute) { |
| 6735 CXFA_FM2JSContext* pContext = | 6970 CXFA_FM2JSContext* pContext = |
| 6736 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6971 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6737 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6972 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6738 iSize = 0; | 6973 iSize = 0; |
| 6739 resultValues = NULL; | 6974 resultValues = nullptr; |
| 6740 if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { | 6975 if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { |
| 6741 bAttribute = FALSE; | 6976 bAttribute = FALSE; |
| 6742 iSize = resoveNodeRS.nodes.GetSize(); | 6977 iSize = resoveNodeRS.nodes.GetSize(); |
| 6743 resultValues = FX_Alloc(CFXJSE_Value*, iSize); | 6978 resultValues = FX_Alloc(CFXJSE_Value*, iSize); |
| 6744 for (int32_t i = 0; i < iSize; i++) { | 6979 for (int32_t i = 0; i < iSize; i++) { |
| 6745 resultValues[i] = new CFXJSE_Value(pIsolate); | 6980 resultValues[i] = new CFXJSE_Value(pIsolate); |
| 6746 FXJSE_Value_Set( | 6981 FXJSE_Value_Set( |
| 6747 resultValues[i], | 6982 resultValues[i], |
| 6748 pContext->GetDocument()->GetScriptContext()->GetJSValueFromMap( | 6983 pContext->GetDocument()->GetScriptContext()->GetJSValueFromMap( |
| 6749 resoveNodeRS.nodes.GetAt(i))); | 6984 resoveNodeRS.nodes.GetAt(i))); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 6762 } else { | 6997 } else { |
| 6763 iSize = iRet; | 6998 iSize = iRet; |
| 6764 resultValues = FX_Alloc(CFXJSE_Value*, iSize); | 6999 resultValues = FX_Alloc(CFXJSE_Value*, iSize); |
| 6765 for (int32_t i = 0; i < iSize; i++) { | 7000 for (int32_t i = 0; i < iSize; i++) { |
| 6766 resultValues[i] = new CFXJSE_Value(pIsolate); | 7001 resultValues[i] = new CFXJSE_Value(pIsolate); |
| 6767 FXJSE_Value_Set(resultValues[i], objectProperties[i]); | 7002 FXJSE_Value_Set(resultValues[i], objectProperties[i]); |
| 6768 } | 7003 } |
| 6769 } | 7004 } |
| 6770 } | 7005 } |
| 6771 } | 7006 } |
| 7007 |
| 7008 // static |
| 6772 int32_t CXFA_FM2JSContext::ValueToInteger(CFXJSE_Value* pThis, | 7009 int32_t CXFA_FM2JSContext::ValueToInteger(CFXJSE_Value* pThis, |
| 6773 CFXJSE_Value* pValue) { | 7010 CFXJSE_Value* pValue) { |
| 6774 CXFA_FM2JSContext* pContext = | 7011 CXFA_FM2JSContext* pContext = |
| 6775 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 7012 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6776 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 7013 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6777 int32_t iValue = 0; | 7014 int32_t iValue = 0; |
| 6778 if (FXJSE_Value_IsArray(pValue)) { | 7015 if (FXJSE_Value_IsArray(pValue)) { |
| 6779 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 7016 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 6780 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 7017 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 6781 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 7018 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 6798 return iValue; | 7035 return iValue; |
| 6799 } else if (FXJSE_Value_IsUTF8String(pValue)) { | 7036 } else if (FXJSE_Value_IsUTF8String(pValue)) { |
| 6800 CFX_ByteString szValue; | 7037 CFX_ByteString szValue; |
| 6801 FXJSE_Value_ToUTF8String(pValue, szValue); | 7038 FXJSE_Value_ToUTF8String(pValue, szValue); |
| 6802 iValue = FXSYS_atoi(szValue.c_str()); | 7039 iValue = FXSYS_atoi(szValue.c_str()); |
| 6803 } else { | 7040 } else { |
| 6804 iValue = FXJSE_Value_ToInteger(pValue); | 7041 iValue = FXJSE_Value_ToInteger(pValue); |
| 6805 } | 7042 } |
| 6806 return iValue; | 7043 return iValue; |
| 6807 } | 7044 } |
| 6808 FX_DOUBLE CXFA_FM2JSContext::StringToDouble( | 7045 |
| 6809 const CFX_ByteStringC& szStringVal) { | 7046 // static |
| 6810 return XFA_ByteStringToDouble(szStringVal); | |
| 6811 } | |
| 6812 FX_FLOAT CXFA_FM2JSContext::ValueToFloat(CFXJSE_Value* pThis, | 7047 FX_FLOAT CXFA_FM2JSContext::ValueToFloat(CFXJSE_Value* pThis, |
| 6813 CFXJSE_Value* arg) { | 7048 CFXJSE_Value* arg) { |
| 6814 CXFA_FM2JSContext* pContext = | 7049 CXFA_FM2JSContext* pContext = |
| 6815 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 7050 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6816 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 7051 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6817 FX_FLOAT fRet = 0.0f; | 7052 FX_FLOAT fRet = 0.0f; |
| 6818 if (FXJSE_Value_IsArray(arg)) { | 7053 if (FXJSE_Value_IsArray(arg)) { |
| 6819 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 7054 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 6820 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 7055 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 6821 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 7056 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
| 6822 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue.get()); | 7057 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue.get()); |
| 6823 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsObjectValue.get()); | 7058 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsObjectValue.get()); |
| 6824 if (FXJSE_Value_IsNull(propertyValue.get())) { | 7059 if (FXJSE_Value_IsNull(propertyValue.get())) { |
| 6825 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 7060 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
| 6826 } else { | 7061 } else { |
| 6827 CFX_ByteString propertyStr; | 7062 CFX_ByteString propertyStr; |
| 6828 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); | 7063 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); |
| 6829 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), | 7064 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), |
| 6830 newPropertyValue.get()); | 7065 newPropertyValue.get()); |
| 6831 } | 7066 } |
| 6832 fRet = ValueToFloat(pThis, newPropertyValue.get()); | 7067 fRet = ValueToFloat(pThis, newPropertyValue.get()); |
| 6833 } else if (FXJSE_Value_IsObject(arg)) { | 7068 } else if (FXJSE_Value_IsObject(arg)) { |
| 6834 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 7069 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
| 6835 GetObjectDefaultValue(arg, newPropertyValue.get()); | 7070 GetObjectDefaultValue(arg, newPropertyValue.get()); |
| 6836 fRet = ValueToFloat(pThis, newPropertyValue.get()); | 7071 fRet = ValueToFloat(pThis, newPropertyValue.get()); |
| 6837 } else if (FXJSE_Value_IsUTF8String(arg)) { | 7072 } else if (FXJSE_Value_IsUTF8String(arg)) { |
| 6838 CFX_ByteString bsOutput; | 7073 CFX_ByteString bsOutput; |
| 6839 FXJSE_Value_ToUTF8String(arg, bsOutput); | 7074 FXJSE_Value_ToUTF8String(arg, bsOutput); |
| 6840 fRet = (FX_FLOAT)StringToDouble(bsOutput.AsStringC()); | 7075 fRet = (FX_FLOAT)XFA_ByteStringToDouble(bsOutput.AsStringC()); |
| 6841 } else if (FXJSE_Value_IsUndefined(arg)) { | 7076 } else if (FXJSE_Value_IsUndefined(arg)) { |
| 6842 fRet = 0; | 7077 fRet = 0; |
| 6843 } else { | 7078 } else { |
| 6844 fRet = FXJSE_Value_ToFloat(arg); | 7079 fRet = FXJSE_Value_ToFloat(arg); |
| 6845 } | 7080 } |
| 6846 return fRet; | 7081 return fRet; |
| 6847 } | 7082 } |
| 7083 |
| 7084 // static |
| 6848 FX_DOUBLE CXFA_FM2JSContext::ValueToDouble(CFXJSE_Value* pThis, | 7085 FX_DOUBLE CXFA_FM2JSContext::ValueToDouble(CFXJSE_Value* pThis, |
| 6849 CFXJSE_Value* arg) { | 7086 CFXJSE_Value* arg) { |
| 6850 CXFA_FM2JSContext* pContext = | 7087 CXFA_FM2JSContext* pContext = |
| 6851 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 7088 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
| 6852 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 7089 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
| 6853 FX_DOUBLE dRet = 0; | 7090 FX_DOUBLE dRet = 0; |
| 6854 if (FXJSE_Value_IsArray(arg)) { | 7091 if (FXJSE_Value_IsArray(arg)) { |
| 6855 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 7092 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 6856 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 7093 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 6857 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 7094 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
| 6858 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue.get()); | 7095 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue.get()); |
| 6859 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsObjectValue.get()); | 7096 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsObjectValue.get()); |
| 6860 if (FXJSE_Value_IsNull(propertyValue.get())) { | 7097 if (FXJSE_Value_IsNull(propertyValue.get())) { |
| 6861 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 7098 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
| 6862 } else { | 7099 } else { |
| 6863 CFX_ByteString propertyStr; | 7100 CFX_ByteString propertyStr; |
| 6864 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); | 7101 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); |
| 6865 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), | 7102 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), |
| 6866 newPropertyValue.get()); | 7103 newPropertyValue.get()); |
| 6867 } | 7104 } |
| 6868 dRet = ValueToDouble(pThis, newPropertyValue.get()); | 7105 dRet = ValueToDouble(pThis, newPropertyValue.get()); |
| 6869 } else if (FXJSE_Value_IsObject(arg)) { | 7106 } else if (FXJSE_Value_IsObject(arg)) { |
| 6870 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 7107 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
| 6871 GetObjectDefaultValue(arg, newPropertyValue.get()); | 7108 GetObjectDefaultValue(arg, newPropertyValue.get()); |
| 6872 dRet = ValueToDouble(pThis, newPropertyValue.get()); | 7109 dRet = ValueToDouble(pThis, newPropertyValue.get()); |
| 6873 } else if (FXJSE_Value_IsUTF8String(arg)) { | 7110 } else if (FXJSE_Value_IsUTF8String(arg)) { |
| 6874 CFX_ByteString bsOutput; | 7111 CFX_ByteString bsOutput; |
| 6875 FXJSE_Value_ToUTF8String(arg, bsOutput); | 7112 FXJSE_Value_ToUTF8String(arg, bsOutput); |
| 6876 dRet = StringToDouble(bsOutput.AsStringC()); | 7113 dRet = XFA_ByteStringToDouble(bsOutput.AsStringC()); |
| 6877 } else if (FXJSE_Value_IsUndefined(arg)) { | 7114 } else if (FXJSE_Value_IsUndefined(arg)) { |
| 6878 dRet = 0; | 7115 dRet = 0; |
| 6879 } else { | 7116 } else { |
| 6880 dRet = FXJSE_Value_ToDouble(arg); | 7117 dRet = FXJSE_Value_ToDouble(arg); |
| 6881 } | 7118 } |
| 6882 return dRet; | 7119 return dRet; |
| 6883 } | 7120 } |
| 6884 | 7121 |
| 7122 // static |
| 6885 void CXFA_FM2JSContext::ValueToUTF8String(CFXJSE_Value* arg, | 7123 void CXFA_FM2JSContext::ValueToUTF8String(CFXJSE_Value* arg, |
| 6886 CFX_ByteString& szOutputString) { | 7124 CFX_ByteString& szOutputString) { |
| 6887 if (FXJSE_Value_IsNull(arg) || FXJSE_Value_IsUndefined(arg)) { | 7125 if (FXJSE_Value_IsNull(arg) || FXJSE_Value_IsUndefined(arg)) { |
| 6888 szOutputString = ""; | 7126 szOutputString = ""; |
| 6889 } else if (FXJSE_Value_IsBoolean(arg)) { | 7127 } else if (FXJSE_Value_IsBoolean(arg)) { |
| 6890 szOutputString = FXJSE_Value_ToBoolean(arg) ? "1" : "0"; | 7128 szOutputString = FXJSE_Value_ToBoolean(arg) ? "1" : "0"; |
| 6891 } else { | 7129 } else { |
| 6892 szOutputString = ""; | 7130 szOutputString = ""; |
| 6893 FXJSE_Value_ToUTF8String(arg, szOutputString); | 7131 FXJSE_Value_ToUTF8String(arg, szOutputString); |
| 6894 } | 7132 } |
| 6895 } | 7133 } |
| 6896 | 7134 |
| 6897 CXFA_FM2JSContext::CXFA_FM2JSContext() | 7135 CXFA_FM2JSContext::CXFA_FM2JSContext(v8::Isolate* pScriptIsolate, |
| 6898 : m_pFMClass(nullptr), m_pDocument(nullptr) {} | 7136 CFXJSE_Context* pScriptContext, |
| 6899 | 7137 CXFA_Document* pDoc) |
| 6900 CXFA_FM2JSContext::~CXFA_FM2JSContext() { | 7138 : m_pIsolate(pScriptIsolate), |
| 6901 } | 7139 m_pFMClass(FXJSE_DefineClass(pScriptContext, &formcalc_fm2js_descriptor)), |
| 6902 | 7140 m_pValue(new CFXJSE_Value(pScriptIsolate)), |
| 6903 void CXFA_FM2JSContext::Initialize(v8::Isolate* pScriptIsolate, | 7141 m_pDocument(pDoc) { |
| 6904 CFXJSE_Context* pScriptContext, | |
| 6905 CXFA_Document* pDoc) { | |
| 6906 m_pDocument = pDoc; | |
| 6907 m_pIsolate = pScriptIsolate; | |
| 6908 m_pFMClass = FXJSE_DefineClass(pScriptContext, &formcalc_fm2js_descriptor); | |
| 6909 m_pValue = std::unique_ptr<CFXJSE_Value>(new CFXJSE_Value(pScriptIsolate)); | |
| 6910 FXJSE_Value_SetNull(m_pValue.get()); | 7142 FXJSE_Value_SetNull(m_pValue.get()); |
| 6911 FXJSE_Value_SetObject(m_pValue.get(), this, m_pFMClass); | 7143 FXJSE_Value_SetObject(m_pValue.get(), this, m_pFMClass); |
| 6912 } | 7144 } |
| 6913 | 7145 |
| 7146 CXFA_FM2JSContext::~CXFA_FM2JSContext() {} |
| 7147 |
| 6914 void CXFA_FM2JSContext::GlobalPropertyGetter(CFXJSE_Value* pValue) { | 7148 void CXFA_FM2JSContext::GlobalPropertyGetter(CFXJSE_Value* pValue) { |
| 6915 FXJSE_Value_Set(pValue, m_pValue.get()); | 7149 FXJSE_Value_Set(pValue, m_pValue.get()); |
| 6916 } | 7150 } |
| 6917 | 7151 |
| 6918 void CXFA_FM2JSContext::ThrowScriptErrorMessage(int32_t iStringID, ...) { | 7152 void CXFA_FM2JSContext::ThrowScriptErrorMessage(int32_t iStringID, ...) { |
| 6919 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); | 7153 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); |
| 6920 ASSERT(pAppProvider); | 7154 ASSERT(pAppProvider); |
| 6921 CFX_WideString wsFormat; | 7155 CFX_WideString wsFormat; |
| 6922 pAppProvider->LoadString(iStringID, wsFormat); | 7156 pAppProvider->LoadString(iStringID, wsFormat); |
| 6923 CFX_WideString wsMessage; | 7157 CFX_WideString wsMessage; |
| 6924 va_list arg_ptr; | 7158 va_list arg_ptr; |
| 6925 va_start(arg_ptr, iStringID); | 7159 va_start(arg_ptr, iStringID); |
| 6926 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); | 7160 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); |
| 6927 va_end(arg_ptr); | 7161 va_end(arg_ptr); |
| 6928 FXJSE_ThrowMessage( | 7162 FXJSE_ThrowMessage( |
| 6929 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); | 7163 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); |
| 6930 } | 7164 } |
| OLD | NEW |