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 float 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 ((nRet > kFinancialPrecision || nRet < -kFinancialPrecision) && |
Lei Zhang
2016/05/30 23:15:59
fabs(nRet) ?
dsinclair
2016/05/31 13:39:51
We need to know if the -kFinancialPrecision < nRet
Lei Zhang
2016/05/31 18:03:48
In my mind, fabs() is clearer, but I'm ok either w
dsinclair
2016/05/31 18:42:40
Done.
| |
2549 (!bFlags)) { | 2711 (!bFlags)) { |
2550 FX_DOUBLE nDerivative = 0; | 2712 FX_DOUBLE nDerivative = 0; |
2551 nDerivative = | 2713 nDerivative = |
2552 ((nTemp + r * nPeriods * (nTemp / (1 + r))) * (nTemp - 1) - | 2714 ((nTemp + r * nPeriods * (nTemp / (1 + r))) * (nTemp - 1) - |
2553 (r * nTemp * nPeriods * (nTemp / (1 + r)))) / | 2715 (r * nTemp * nPeriods * (nTemp / (1 + r)))) / |
2554 ((nTemp - 1) * (nTemp - 1)); | 2716 ((nTemp - 1) * (nTemp - 1)); |
2555 if (nDerivative == 0) { | 2717 if (nDerivative == 0) { |
2556 bFlags = TRUE; | 2718 bFlags = TRUE; |
2557 continue; | 2719 continue; |
2558 } | 2720 } |
(...skipping 10 matching lines...) Expand all Loading... | |
2569 r = r * 12; | 2731 r = r * 12; |
2570 FXJSE_Value_SetDouble(args.GetReturnValue(), r); | 2732 FXJSE_Value_SetDouble(args.GetReturnValue(), r); |
2571 } | 2733 } |
2572 } | 2734 } |
2573 } | 2735 } |
2574 } else { | 2736 } else { |
2575 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2737 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
2576 L"Apr"); | 2738 L"Apr"); |
2577 } | 2739 } |
2578 } | 2740 } |
2741 | |
2742 // static | |
2579 void CXFA_FM2JSContext::CTerm(CFXJSE_Value* pThis, | 2743 void CXFA_FM2JSContext::CTerm(CFXJSE_Value* pThis, |
2580 const CFX_ByteStringC& szFuncName, | 2744 const CFX_ByteStringC& szFuncName, |
2581 CFXJSE_Arguments& args) { | 2745 CFXJSE_Arguments& args) { |
2582 CXFA_FM2JSContext* pContext = | 2746 CXFA_FM2JSContext* pContext = |
2583 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 2747 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
2584 if (args.GetLength() == 3) { | 2748 if (args.GetLength() == 3) { |
2585 FX_BOOL bFlags = FALSE; | 2749 FX_BOOL bFlags = FALSE; |
2586 FX_FLOAT nRate = 0; | 2750 FX_FLOAT nRate = 0; |
2587 FX_FLOAT nFutureValue = 0; | 2751 FX_FLOAT nFutureValue = 0; |
2588 FX_FLOAT nInitAmount = 0; | 2752 FX_FLOAT nInitAmount = 0; |
(...skipping 16 matching lines...) Expand all Loading... | |
2605 FXJSE_Value_SetFloat(args.GetReturnValue(), | 2769 FXJSE_Value_SetFloat(args.GetReturnValue(), |
2606 FXSYS_log((FX_FLOAT)(nFutureValue / nInitAmount)) / | 2770 FXSYS_log((FX_FLOAT)(nFutureValue / nInitAmount)) / |
2607 FXSYS_log((FX_FLOAT)(1 + nRate))); | 2771 FXSYS_log((FX_FLOAT)(1 + nRate))); |
2608 } | 2772 } |
2609 } | 2773 } |
2610 } else { | 2774 } else { |
2611 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2775 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
2612 L"CTerm"); | 2776 L"CTerm"); |
2613 } | 2777 } |
2614 } | 2778 } |
2779 | |
2780 // static | |
2615 void CXFA_FM2JSContext::FV(CFXJSE_Value* pThis, | 2781 void CXFA_FM2JSContext::FV(CFXJSE_Value* pThis, |
2616 const CFX_ByteStringC& szFuncName, | 2782 const CFX_ByteStringC& szFuncName, |
2617 CFXJSE_Arguments& args) { | 2783 CFXJSE_Arguments& args) { |
2618 CXFA_FM2JSContext* pContext = | 2784 CXFA_FM2JSContext* pContext = |
2619 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 2785 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
2620 if (args.GetLength() == 3) { | 2786 if (args.GetLength() == 3) { |
2621 FX_BOOL bFlags = FALSE; | 2787 FX_BOOL bFlags = FALSE; |
2622 FX_DOUBLE nAmount = 0; | 2788 FX_DOUBLE nAmount = 0; |
2623 FX_DOUBLE nRate = 0; | 2789 FX_DOUBLE nRate = 0; |
2624 FX_DOUBLE nPeriod = 0; | 2790 FX_DOUBLE nPeriod = 0; |
(...skipping 24 matching lines...) Expand all Loading... | |
2649 dResult = nAmount * (nTemp - 1) / nRate; | 2815 dResult = nAmount * (nTemp - 1) / nRate; |
2650 } | 2816 } |
2651 FXJSE_Value_SetDouble(args.GetReturnValue(), dResult); | 2817 FXJSE_Value_SetDouble(args.GetReturnValue(), dResult); |
2652 } | 2818 } |
2653 } | 2819 } |
2654 } else { | 2820 } else { |
2655 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2821 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
2656 L"FV"); | 2822 L"FV"); |
2657 } | 2823 } |
2658 } | 2824 } |
2825 | |
2826 // static | |
2659 void CXFA_FM2JSContext::IPmt(CFXJSE_Value* pThis, | 2827 void CXFA_FM2JSContext::IPmt(CFXJSE_Value* pThis, |
2660 const CFX_ByteStringC& szFuncName, | 2828 const CFX_ByteStringC& szFuncName, |
2661 CFXJSE_Arguments& args) { | 2829 CFXJSE_Arguments& args) { |
2662 CXFA_FM2JSContext* pContext = | 2830 CXFA_FM2JSContext* pContext = |
2663 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 2831 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
2664 if (args.GetLength() == 5) { | 2832 if (args.GetLength() == 5) { |
2665 FX_BOOL bFlags = FALSE; | 2833 FX_BOOL bFlags = FALSE; |
2666 FX_FLOAT nPrincpalAmount = 0; | 2834 FX_FLOAT nPrincpalAmount = 0; |
2667 FX_FLOAT nRate = 0; | 2835 FX_FLOAT nRate = 0; |
2668 FX_FLOAT nPayment = 0; | 2836 FX_FLOAT nPayment = 0; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2719 fResult = nSum; | 2887 fResult = nSum; |
2720 } | 2888 } |
2721 FXJSE_Value_SetFloat(args.GetReturnValue(), fResult); | 2889 FXJSE_Value_SetFloat(args.GetReturnValue(), fResult); |
2722 } | 2890 } |
2723 } | 2891 } |
2724 } else { | 2892 } else { |
2725 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2893 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
2726 L"IPmt"); | 2894 L"IPmt"); |
2727 } | 2895 } |
2728 } | 2896 } |
2897 | |
2898 // static | |
2729 void CXFA_FM2JSContext::NPV(CFXJSE_Value* pThis, | 2899 void CXFA_FM2JSContext::NPV(CFXJSE_Value* pThis, |
2730 const CFX_ByteStringC& szFuncName, | 2900 const CFX_ByteStringC& szFuncName, |
2731 CFXJSE_Arguments& args) { | 2901 CFXJSE_Arguments& args) { |
2732 CXFA_FM2JSContext* pContext = | 2902 CXFA_FM2JSContext* pContext = |
2733 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 2903 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
2734 int32_t argc = args.GetLength(); | 2904 int32_t argc = args.GetLength(); |
2735 if (argc > 2) { | 2905 if (argc > 2) { |
2736 FX_BOOL bFlags = FALSE; | 2906 FX_BOOL bFlags = FALSE; |
2737 std::vector<std::unique_ptr<CFXJSE_Value>> argValues; | 2907 std::vector<std::unique_ptr<CFXJSE_Value>> argValues; |
2738 for (int32_t i = 0; i < argc; i++) { | 2908 for (int32_t i = 0; i < argc; i++) { |
(...skipping 27 matching lines...) Expand all Loading... | |
2766 pData = 0; | 2936 pData = 0; |
2767 } | 2937 } |
2768 } else { | 2938 } else { |
2769 FXJSE_Value_SetNull(args.GetReturnValue()); | 2939 FXJSE_Value_SetNull(args.GetReturnValue()); |
2770 } | 2940 } |
2771 } else { | 2941 } else { |
2772 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2942 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
2773 L"NPV"); | 2943 L"NPV"); |
2774 } | 2944 } |
2775 } | 2945 } |
2946 | |
2947 // static | |
2776 void CXFA_FM2JSContext::Pmt(CFXJSE_Value* pThis, | 2948 void CXFA_FM2JSContext::Pmt(CFXJSE_Value* pThis, |
2777 const CFX_ByteStringC& szFuncName, | 2949 const CFX_ByteStringC& szFuncName, |
2778 CFXJSE_Arguments& args) { | 2950 CFXJSE_Arguments& args) { |
2779 CXFA_FM2JSContext* pContext = | 2951 CXFA_FM2JSContext* pContext = |
2780 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 2952 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
2781 if (args.GetLength() == 3) { | 2953 if (args.GetLength() == 3) { |
2782 FX_BOOL bFlags = FALSE; | 2954 FX_BOOL bFlags = FALSE; |
2783 FX_FLOAT nPrincipal = 0; | 2955 FX_FLOAT nPrincipal = 0; |
2784 FX_FLOAT nRate = 0; | 2956 FX_FLOAT nRate = 0; |
2785 FX_FLOAT nPeriods = 0; | 2957 FX_FLOAT nPeriods = 0; |
(...skipping 21 matching lines...) Expand all Loading... | |
2807 } | 2979 } |
2808 FXJSE_Value_SetFloat(args.GetReturnValue(), | 2980 FXJSE_Value_SetFloat(args.GetReturnValue(), |
2809 (nPrincipal * nRate * nSum) / (nSum - 1)); | 2981 (nPrincipal * nRate * nSum) / (nSum - 1)); |
2810 } | 2982 } |
2811 } | 2983 } |
2812 } else { | 2984 } else { |
2813 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 2985 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
2814 L"Pmt"); | 2986 L"Pmt"); |
2815 } | 2987 } |
2816 } | 2988 } |
2989 | |
2990 // static | |
2817 void CXFA_FM2JSContext::PPmt(CFXJSE_Value* pThis, | 2991 void CXFA_FM2JSContext::PPmt(CFXJSE_Value* pThis, |
2818 const CFX_ByteStringC& szFuncName, | 2992 const CFX_ByteStringC& szFuncName, |
2819 CFXJSE_Arguments& args) { | 2993 CFXJSE_Arguments& args) { |
2820 CXFA_FM2JSContext* pContext = | 2994 CXFA_FM2JSContext* pContext = |
2821 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 2995 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
2822 if (args.GetLength() == 5) { | 2996 if (args.GetLength() == 5) { |
2823 FX_BOOL bFlags = FALSE; | 2997 FX_BOOL bFlags = FALSE; |
2824 FX_FLOAT nPrincpalAmount = 0; | 2998 FX_FLOAT nPrincpalAmount = 0; |
2825 FX_FLOAT nRate = 0; | 2999 FX_FLOAT nRate = 0; |
2826 FX_FLOAT nPayment = 0; | 3000 FX_FLOAT nPayment = 0; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2878 } else { | 3052 } else { |
2879 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 3053 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
2880 } | 3054 } |
2881 } | 3055 } |
2882 } | 3056 } |
2883 } else { | 3057 } else { |
2884 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3058 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
2885 L"PPmt"); | 3059 L"PPmt"); |
2886 } | 3060 } |
2887 } | 3061 } |
3062 | |
3063 // static | |
2888 void CXFA_FM2JSContext::PV(CFXJSE_Value* pThis, | 3064 void CXFA_FM2JSContext::PV(CFXJSE_Value* pThis, |
2889 const CFX_ByteStringC& szFuncName, | 3065 const CFX_ByteStringC& szFuncName, |
2890 CFXJSE_Arguments& args) { | 3066 CFXJSE_Arguments& args) { |
2891 CXFA_FM2JSContext* pContext = | 3067 CXFA_FM2JSContext* pContext = |
2892 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3068 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
2893 if (args.GetLength() == 3) { | 3069 if (args.GetLength() == 3) { |
2894 FX_BOOL bFlags = FALSE; | 3070 FX_BOOL bFlags = FALSE; |
2895 FX_DOUBLE nAmount = 0; | 3071 FX_DOUBLE nAmount = 0; |
2896 FX_DOUBLE nRate = 0; | 3072 FX_DOUBLE nRate = 0; |
2897 FX_DOUBLE nPeriod = 0; | 3073 FX_DOUBLE nPeriod = 0; |
(...skipping 20 matching lines...) Expand all Loading... | |
2918 nTemp = 1 / nTemp; | 3094 nTemp = 1 / nTemp; |
2919 FXJSE_Value_SetDouble(args.GetReturnValue(), | 3095 FXJSE_Value_SetDouble(args.GetReturnValue(), |
2920 nAmount * ((1 - nTemp) / nRate)); | 3096 nAmount * ((1 - nTemp) / nRate)); |
2921 } | 3097 } |
2922 } | 3098 } |
2923 } else { | 3099 } else { |
2924 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3100 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
2925 L"PV"); | 3101 L"PV"); |
2926 } | 3102 } |
2927 } | 3103 } |
3104 | |
3105 // static | |
2928 void CXFA_FM2JSContext::Rate(CFXJSE_Value* pThis, | 3106 void CXFA_FM2JSContext::Rate(CFXJSE_Value* pThis, |
2929 const CFX_ByteStringC& szFuncName, | 3107 const CFX_ByteStringC& szFuncName, |
2930 CFXJSE_Arguments& args) { | 3108 CFXJSE_Arguments& args) { |
2931 CXFA_FM2JSContext* pContext = | 3109 CXFA_FM2JSContext* pContext = |
2932 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3110 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
2933 if (args.GetLength() == 3) { | 3111 if (args.GetLength() == 3) { |
2934 FX_BOOL bFlags = FALSE; | 3112 FX_BOOL bFlags = FALSE; |
2935 FX_FLOAT nFuture = 0; | 3113 FX_FLOAT nFuture = 0; |
2936 FX_FLOAT nPresent = 0; | 3114 FX_FLOAT nPresent = 0; |
2937 FX_FLOAT nTotalNumber = 0; | 3115 FX_FLOAT nTotalNumber = 0; |
(...skipping 17 matching lines...) Expand all Loading... | |
2955 (FXSYS_pow((FX_FLOAT)(nFuture / nPresent), | 3133 (FXSYS_pow((FX_FLOAT)(nFuture / nPresent), |
2956 (FX_FLOAT)(1 / nTotalNumber)) - | 3134 (FX_FLOAT)(1 / nTotalNumber)) - |
2957 1)); | 3135 1)); |
2958 } | 3136 } |
2959 } | 3137 } |
2960 } else { | 3138 } else { |
2961 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3139 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
2962 L"Rate"); | 3140 L"Rate"); |
2963 } | 3141 } |
2964 } | 3142 } |
3143 | |
3144 // static | |
2965 void CXFA_FM2JSContext::Term(CFXJSE_Value* pThis, | 3145 void CXFA_FM2JSContext::Term(CFXJSE_Value* pThis, |
2966 const CFX_ByteStringC& szFuncName, | 3146 const CFX_ByteStringC& szFuncName, |
2967 CFXJSE_Arguments& args) { | 3147 CFXJSE_Arguments& args) { |
2968 CXFA_FM2JSContext* pContext = | 3148 CXFA_FM2JSContext* pContext = |
2969 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3149 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
2970 if (args.GetLength() == 3) { | 3150 if (args.GetLength() == 3) { |
2971 FX_BOOL bFlags = FALSE; | 3151 FX_BOOL bFlags = FALSE; |
2972 FX_FLOAT nMount = 0; | 3152 FX_FLOAT nMount = 0; |
2973 FX_FLOAT nRate = 0; | 3153 FX_FLOAT nRate = 0; |
2974 FX_FLOAT nFuture = 0; | 3154 FX_FLOAT nFuture = 0; |
(...skipping 17 matching lines...) Expand all Loading... | |
2992 args.GetReturnValue(), | 3172 args.GetReturnValue(), |
2993 (FXSYS_log((FX_FLOAT)(nFuture / nMount * nRate) + 1) / | 3173 (FXSYS_log((FX_FLOAT)(nFuture / nMount * nRate) + 1) / |
2994 FXSYS_log((FX_FLOAT)(1 + nRate)))); | 3174 FXSYS_log((FX_FLOAT)(1 + nRate)))); |
2995 } | 3175 } |
2996 } | 3176 } |
2997 } else { | 3177 } else { |
2998 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3178 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
2999 L"Term"); | 3179 L"Term"); |
3000 } | 3180 } |
3001 } | 3181 } |
3182 | |
3183 // static | |
3002 void CXFA_FM2JSContext::Choose(CFXJSE_Value* pThis, | 3184 void CXFA_FM2JSContext::Choose(CFXJSE_Value* pThis, |
3003 const CFX_ByteStringC& szFuncName, | 3185 const CFX_ByteStringC& szFuncName, |
3004 CFXJSE_Arguments& args) { | 3186 CFXJSE_Arguments& args) { |
3005 CXFA_FM2JSContext* pContext = | 3187 CXFA_FM2JSContext* pContext = |
3006 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3188 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
3007 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 3189 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
3008 int32_t argc = args.GetLength(); | 3190 int32_t argc = args.GetLength(); |
3009 if (argc > 1) { | 3191 if (argc > 1) { |
3010 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 3192 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
3011 FX_BOOL argOneIsNull = FALSE; | 3193 FX_BOOL argOneIsNull = FALSE; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3078 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 3260 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
3079 } | 3261 } |
3080 } | 3262 } |
3081 } else { | 3263 } else { |
3082 CXFA_FM2JSContext* pContext = | 3264 CXFA_FM2JSContext* pContext = |
3083 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3265 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
3084 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3266 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
3085 L"Choose"); | 3267 L"Choose"); |
3086 } | 3268 } |
3087 } | 3269 } |
3270 | |
3271 // static | |
3088 void CXFA_FM2JSContext::Exists(CFXJSE_Value* pThis, | 3272 void CXFA_FM2JSContext::Exists(CFXJSE_Value* pThis, |
3089 const CFX_ByteStringC& szFuncName, | 3273 const CFX_ByteStringC& szFuncName, |
3090 CFXJSE_Arguments& args) { | 3274 CFXJSE_Arguments& args) { |
3091 if (args.GetLength() == 1) { | 3275 if (args.GetLength() == 1) { |
3092 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 3276 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
3093 FXJSE_Value_SetInteger(args.GetReturnValue(), | 3277 FXJSE_Value_SetInteger(args.GetReturnValue(), |
3094 FXJSE_Value_IsObject(argOne.get())); | 3278 FXJSE_Value_IsObject(argOne.get())); |
3095 } else { | 3279 } else { |
3096 CXFA_FM2JSContext* pContext = | 3280 CXFA_FM2JSContext* pContext = |
3097 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3281 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
3098 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3282 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
3099 L"Exists"); | 3283 L"Exists"); |
3100 } | 3284 } |
3101 } | 3285 } |
3286 | |
3287 // static | |
3102 void CXFA_FM2JSContext::HasValue(CFXJSE_Value* pThis, | 3288 void CXFA_FM2JSContext::HasValue(CFXJSE_Value* pThis, |
3103 const CFX_ByteStringC& szFuncName, | 3289 const CFX_ByteStringC& szFuncName, |
3104 CFXJSE_Arguments& args) { | 3290 CFXJSE_Arguments& args) { |
3105 if (args.GetLength() == 1) { | 3291 if (args.GetLength() == 1) { |
3106 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 3292 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
3107 if (FXJSE_Value_IsUTF8String(argOne.get())) { | 3293 if (FXJSE_Value_IsUTF8String(argOne.get())) { |
3108 CFX_ByteString valueStr; | 3294 CFX_ByteString valueStr; |
3109 FXJSE_Value_ToUTF8String(argOne.get(), valueStr); | 3295 FXJSE_Value_ToUTF8String(argOne.get(), valueStr); |
3110 valueStr.TrimLeft(); | 3296 valueStr.TrimLeft(); |
3111 FXJSE_Value_SetInteger(args.GetReturnValue(), (!valueStr.IsEmpty())); | 3297 FXJSE_Value_SetInteger(args.GetReturnValue(), (!valueStr.IsEmpty())); |
3112 } else if (FXJSE_Value_IsNumber(argOne.get()) || | 3298 } else if (FXJSE_Value_IsNumber(argOne.get()) || |
3113 FXJSE_Value_IsBoolean(argOne.get())) { | 3299 FXJSE_Value_IsBoolean(argOne.get())) { |
3114 FXJSE_Value_SetInteger(args.GetReturnValue(), TRUE); | 3300 FXJSE_Value_SetInteger(args.GetReturnValue(), TRUE); |
3115 } else { | 3301 } else { |
3116 FXJSE_Value_SetInteger(args.GetReturnValue(), FALSE); | 3302 FXJSE_Value_SetInteger(args.GetReturnValue(), FALSE); |
3117 } | 3303 } |
3118 } else { | 3304 } else { |
3119 CXFA_FM2JSContext* pContext = | 3305 CXFA_FM2JSContext* pContext = |
3120 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3306 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
3121 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3307 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
3122 L"HasValue"); | 3308 L"HasValue"); |
3123 } | 3309 } |
3124 } | 3310 } |
3311 | |
3312 // static | |
3125 void CXFA_FM2JSContext::Oneof(CFXJSE_Value* pThis, | 3313 void CXFA_FM2JSContext::Oneof(CFXJSE_Value* pThis, |
3126 const CFX_ByteStringC& szFuncName, | 3314 const CFX_ByteStringC& szFuncName, |
3127 CFXJSE_Arguments& args) { | 3315 CFXJSE_Arguments& args) { |
3128 int32_t argc = args.GetLength(); | 3316 if (args.GetLength() > 1) { |
3129 if (argc > 1) { | |
3130 FX_BOOL bFlags = FALSE; | 3317 FX_BOOL bFlags = FALSE; |
3131 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 3318 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
3132 CFXJSE_Value** parametersValue = nullptr; | 3319 CFXJSE_Value** parametersValue = nullptr; |
3133 int32_t iCount = 0; | 3320 int32_t iCount = 0; |
3134 unfoldArgs(pThis, args, parametersValue, iCount, 1); | 3321 unfoldArgs(pThis, args, parametersValue, iCount, 1); |
3135 for (int32_t i = 0; i < iCount; i++) { | 3322 for (int32_t i = 0; i < iCount; i++) { |
3136 if (simpleValueCompare(pThis, argOne.get(), parametersValue[i])) { | 3323 if (simpleValueCompare(pThis, argOne.get(), parametersValue[i])) { |
3137 bFlags = TRUE; | 3324 bFlags = TRUE; |
3138 break; | 3325 break; |
3139 } | 3326 } |
3140 } | 3327 } |
3141 FXJSE_Value_SetInteger(args.GetReturnValue(), bFlags); | 3328 FXJSE_Value_SetInteger(args.GetReturnValue(), bFlags); |
3142 for (int32_t i = 0; i < iCount; i++) { | 3329 for (int32_t i = 0; i < iCount; i++) { |
3143 delete parametersValue[i]; | 3330 delete parametersValue[i]; |
3144 } | 3331 } |
3145 FX_Free(parametersValue); | 3332 FX_Free(parametersValue); |
3146 } else { | 3333 } else { |
3147 CXFA_FM2JSContext* pContext = | 3334 CXFA_FM2JSContext* pContext = |
3148 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3335 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
3149 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3336 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
3150 L"Oneof"); | 3337 L"Oneof"); |
3151 } | 3338 } |
3152 } | 3339 } |
3340 | |
3341 // static | |
3153 void CXFA_FM2JSContext::Within(CFXJSE_Value* pThis, | 3342 void CXFA_FM2JSContext::Within(CFXJSE_Value* pThis, |
3154 const CFX_ByteStringC& szFuncName, | 3343 const CFX_ByteStringC& szFuncName, |
3155 CFXJSE_Arguments& args) { | 3344 CFXJSE_Arguments& args) { |
3156 int32_t argc = args.GetLength(); | 3345 if (args.GetLength() == 3) { |
3157 if (argc == 3) { | |
3158 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 3346 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
3159 if (FXJSE_Value_IsNull(argOne.get())) { | 3347 if (FXJSE_Value_IsNull(argOne.get())) { |
3160 FXJSE_Value_SetUndefined(args.GetReturnValue()); | 3348 FXJSE_Value_SetUndefined(args.GetReturnValue()); |
3161 } else { | 3349 } else { |
3162 std::unique_ptr<CFXJSE_Value> argLow = GetSimpleValue(pThis, args, 1); | 3350 std::unique_ptr<CFXJSE_Value> argLow = GetSimpleValue(pThis, args, 1); |
3163 std::unique_ptr<CFXJSE_Value> argHeight = GetSimpleValue(pThis, args, 2); | 3351 std::unique_ptr<CFXJSE_Value> argHeight = GetSimpleValue(pThis, args, 2); |
3164 if (FXJSE_Value_IsNumber(argOne.get())) { | 3352 if (FXJSE_Value_IsNumber(argOne.get())) { |
3165 FX_FLOAT oneNumber = ValueToFloat(pThis, argOne.get()); | 3353 FX_FLOAT oneNumber = ValueToFloat(pThis, argOne.get()); |
3166 FX_FLOAT lowNumber = ValueToFloat(pThis, argLow.get()); | 3354 FX_FLOAT lowNumber = ValueToFloat(pThis, argLow.get()); |
3167 FX_FLOAT heightNumber = ValueToFloat(pThis, argHeight.get()); | 3355 FX_FLOAT heightNumber = ValueToFloat(pThis, argHeight.get()); |
(...skipping 13 matching lines...) Expand all Loading... | |
3181 (oneString.Compare(heightString.AsStringC()) <= 0))); | 3369 (oneString.Compare(heightString.AsStringC()) <= 0))); |
3182 } | 3370 } |
3183 } | 3371 } |
3184 } else { | 3372 } else { |
3185 CXFA_FM2JSContext* pContext = | 3373 CXFA_FM2JSContext* pContext = |
3186 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3374 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
3187 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3375 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
3188 L"Within"); | 3376 L"Within"); |
3189 } | 3377 } |
3190 } | 3378 } |
3379 | |
3380 // static | |
3191 void CXFA_FM2JSContext::If(CFXJSE_Value* pThis, | 3381 void CXFA_FM2JSContext::If(CFXJSE_Value* pThis, |
3192 const CFX_ByteStringC& szFuncName, | 3382 const CFX_ByteStringC& szFuncName, |
3193 CFXJSE_Arguments& args) { | 3383 CFXJSE_Arguments& args) { |
3194 if (args.GetLength() == 3) { | 3384 if (args.GetLength() == 3) { |
3195 std::unique_ptr<CFXJSE_Value> argCondition = GetSimpleValue(pThis, args, 0); | 3385 std::unique_ptr<CFXJSE_Value> argCondition = GetSimpleValue(pThis, args, 0); |
3196 std::unique_ptr<CFXJSE_Value> argFirstValue = | 3386 std::unique_ptr<CFXJSE_Value> argFirstValue = |
3197 GetSimpleValue(pThis, args, 1); | 3387 GetSimpleValue(pThis, args, 1); |
3198 std::unique_ptr<CFXJSE_Value> argSecondValue = | 3388 std::unique_ptr<CFXJSE_Value> argSecondValue = |
3199 GetSimpleValue(pThis, args, 2); | 3389 GetSimpleValue(pThis, args, 2); |
3200 FX_BOOL bCondition = FXJSE_Value_ToBoolean(argCondition.get()); | 3390 FX_BOOL bCondition = FXJSE_Value_ToBoolean(argCondition.get()); |
3201 FXJSE_Value_Set(args.GetReturnValue(), | 3391 FXJSE_Value_Set(args.GetReturnValue(), |
3202 bCondition ? argFirstValue.get() : argSecondValue.get()); | 3392 bCondition ? argFirstValue.get() : argSecondValue.get()); |
3203 } else { | 3393 } else { |
3204 CXFA_FM2JSContext* pContext = | 3394 CXFA_FM2JSContext* pContext = |
3205 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3395 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
3206 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3396 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
3207 L"If"); | 3397 L"If"); |
3208 } | 3398 } |
3209 } | 3399 } |
3400 | |
3401 // static | |
3210 void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis, | 3402 void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis, |
3211 const CFX_ByteStringC& szFuncName, | 3403 const CFX_ByteStringC& szFuncName, |
3212 CFXJSE_Arguments& args) { | 3404 CFXJSE_Arguments& args) { |
3213 CXFA_FM2JSContext* pContext = | 3405 CXFA_FM2JSContext* pContext = |
3214 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3406 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
3215 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 3407 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
3216 if (args.GetLength() == 1) { | 3408 if (args.GetLength() == 1) { |
3217 std::unique_ptr<CFXJSE_Value> scriptValue = GetSimpleValue(pThis, args, 0); | 3409 std::unique_ptr<CFXJSE_Value> scriptValue = GetSimpleValue(pThis, args, 0); |
3218 CFX_ByteString utf8ScriptString; | 3410 CFX_ByteString utf8ScriptString; |
3219 ValueToUTF8String(scriptValue.get(), utf8ScriptString); | 3411 ValueToUTF8String(scriptValue.get(), utf8ScriptString); |
(...skipping 15 matching lines...) Expand all Loading... | |
3235 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(), | 3427 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()).c_str(), |
3236 returnValue.get()); | 3428 returnValue.get()); |
3237 FXJSE_Value_Set(args.GetReturnValue(), returnValue.get()); | 3429 FXJSE_Value_Set(args.GetReturnValue(), returnValue.get()); |
3238 FXJSE_Context_Release(pContext); | 3430 FXJSE_Context_Release(pContext); |
3239 } | 3431 } |
3240 } else { | 3432 } else { |
3241 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3433 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
3242 L"Eval"); | 3434 L"Eval"); |
3243 } | 3435 } |
3244 } | 3436 } |
3437 | |
3438 // static | |
3245 void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis, | 3439 void CXFA_FM2JSContext::Ref(CFXJSE_Value* pThis, |
3246 const CFX_ByteStringC& szFuncName, | 3440 const CFX_ByteStringC& szFuncName, |
3247 CFXJSE_Arguments& args) { | 3441 CFXJSE_Arguments& args) { |
3248 CXFA_FM2JSContext* pContext = | 3442 CXFA_FM2JSContext* pContext = |
3249 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3443 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
3250 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 3444 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
3251 if (args.GetLength() == 1) { | 3445 if (args.GetLength() == 1) { |
3252 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 3446 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
3253 if (FXJSE_Value_IsNull(argOne.get())) { | 3447 if (FXJSE_Value_IsNull(argOne.get())) { |
3254 CFXJSE_Value* rgValues[3]; | 3448 CFXJSE_Value* rgValues[3]; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3307 FXJSE_Value_IsNumber(argOne.get())) { | 3501 FXJSE_Value_IsNumber(argOne.get())) { |
3308 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); | 3502 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); |
3309 } else { | 3503 } else { |
3310 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 3504 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
3311 } | 3505 } |
3312 } else { | 3506 } else { |
3313 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3507 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
3314 L"Ref"); | 3508 L"Ref"); |
3315 } | 3509 } |
3316 } | 3510 } |
3511 | |
3512 // static | |
3317 void CXFA_FM2JSContext::UnitType(CFXJSE_Value* pThis, | 3513 void CXFA_FM2JSContext::UnitType(CFXJSE_Value* pThis, |
3318 const CFX_ByteStringC& szFuncName, | 3514 const CFX_ByteStringC& szFuncName, |
3319 CFXJSE_Arguments& args) { | 3515 CFXJSE_Arguments& args) { |
3320 if (args.GetLength() == 1) { | 3516 if (args.GetLength() == 1) { |
3321 std::unique_ptr<CFXJSE_Value> unitspanValue = | 3517 std::unique_ptr<CFXJSE_Value> unitspanValue = |
3322 GetSimpleValue(pThis, args, 0); | 3518 GetSimpleValue(pThis, args, 0); |
3323 if (FXJSE_Value_IsNull(unitspanValue.get())) { | 3519 if (FXJSE_Value_IsNull(unitspanValue.get())) { |
3324 FXJSE_Value_SetNull(args.GetReturnValue()); | 3520 FXJSE_Value_SetNull(args.GetReturnValue()); |
3325 return; | 3521 return; |
3326 } | 3522 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3423 break; | 3619 break; |
3424 } | 3620 } |
3425 } | 3621 } |
3426 } else { | 3622 } else { |
3427 CXFA_FM2JSContext* pContext = | 3623 CXFA_FM2JSContext* pContext = |
3428 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3624 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
3429 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3625 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
3430 L"UnitType"); | 3626 L"UnitType"); |
3431 } | 3627 } |
3432 } | 3628 } |
3629 | |
3630 // static | |
3433 void CXFA_FM2JSContext::UnitValue(CFXJSE_Value* pThis, | 3631 void CXFA_FM2JSContext::UnitValue(CFXJSE_Value* pThis, |
3434 const CFX_ByteStringC& szFuncName, | 3632 const CFX_ByteStringC& szFuncName, |
3435 CFXJSE_Arguments& args) { | 3633 CFXJSE_Arguments& args) { |
3436 int32_t argc = args.GetLength(); | 3634 int32_t argc = args.GetLength(); |
3437 if ((argc == 1) || (argc == 2)) { | 3635 if ((argc == 1) || (argc == 2)) { |
3438 std::unique_ptr<CFXJSE_Value> unitspanValue = | 3636 std::unique_ptr<CFXJSE_Value> unitspanValue = |
3439 GetSimpleValue(pThis, args, 0); | 3637 GetSimpleValue(pThis, args, 0); |
3440 CFX_ByteString unitspanString; | 3638 CFX_ByteString unitspanString; |
3441 FX_DOUBLE dFirstNumber = 0; | 3639 FX_DOUBLE dFirstNumber = 0; |
3442 CFX_ByteString strFirstUnit; | 3640 CFX_ByteString strFirstUnit; |
(...skipping 10 matching lines...) Expand all Loading... | |
3453 *(pData + u) == 0x0A || *(pData + u) == 0x0D) { | 3651 *(pData + u) == 0x0A || *(pData + u) == 0x0D) { |
3454 ++u; | 3652 ++u; |
3455 } | 3653 } |
3456 while (u < unitspanString.GetLength()) { | 3654 while (u < unitspanString.GetLength()) { |
3457 if ((*(pData + u) > '9' || *(pData + u) < '0') && | 3655 if ((*(pData + u) > '9' || *(pData + u) < '0') && |
3458 *(pData + u) != '.' && *(pData + u) != '-') { | 3656 *(pData + u) != '.' && *(pData + u) != '-') { |
3459 break; | 3657 break; |
3460 } | 3658 } |
3461 ++u; | 3659 ++u; |
3462 } | 3660 } |
3463 FX_CHAR* pTemp = NULL; | 3661 FX_CHAR* pTemp = nullptr; |
3464 dFirstNumber = strtod(pData, &pTemp); | 3662 dFirstNumber = strtod(pData, &pTemp); |
3465 while (*(pData + u) == ' ' || *(pData + u) == 0x09 || | 3663 while (*(pData + u) == ' ' || *(pData + u) == 0x09 || |
3466 *(pData + u) == 0x0B || *(pData + u) == 0x0C || | 3664 *(pData + u) == 0x0B || *(pData + u) == 0x0C || |
3467 *(pData + u) == 0x0A || *(pData + u) == 0x0D) { | 3665 *(pData + u) == 0x0A || *(pData + u) == 0x0D) { |
3468 ++u; | 3666 ++u; |
3469 } | 3667 } |
3470 int32_t uLen = unitspanString.GetLength(); | 3668 int32_t uLen = unitspanString.GetLength(); |
3471 while (u < uLen) { | 3669 while (u < uLen) { |
3472 if (*(pData + u) == ' ') { | 3670 if (*(pData + u) == ' ') { |
3473 break; | 3671 break; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3579 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 3777 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
3580 } | 3778 } |
3581 } | 3779 } |
3582 } else { | 3780 } else { |
3583 CXFA_FM2JSContext* pContext = | 3781 CXFA_FM2JSContext* pContext = |
3584 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 3782 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
3585 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3783 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
3586 L"UnitValue"); | 3784 L"UnitValue"); |
3587 } | 3785 } |
3588 } | 3786 } |
3787 | |
3788 // static | |
3589 void CXFA_FM2JSContext::At(CFXJSE_Value* pThis, | 3789 void CXFA_FM2JSContext::At(CFXJSE_Value* pThis, |
3590 const CFX_ByteStringC& szFuncName, | 3790 const CFX_ByteStringC& szFuncName, |
3591 CFXJSE_Arguments& args) { | 3791 CFXJSE_Arguments& args) { |
3592 CXFA_FM2JSContext* pContext = | |
3593 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
3594 if (args.GetLength() == 2) { | 3792 if (args.GetLength() == 2) { |
3595 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 3793 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
3596 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | 3794 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
3597 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get())) { | 3795 if (ValueIsNull(pThis, argOne.get()) || ValueIsNull(pThis, argTwo.get())) { |
3598 FXJSE_Value_SetNull(args.GetReturnValue()); | 3796 FXJSE_Value_SetNull(args.GetReturnValue()); |
3599 } else { | 3797 } else { |
3600 CFX_ByteString stringTwo; | 3798 CFX_ByteString stringTwo; |
3601 ValueToUTF8String(argTwo.get(), stringTwo); | 3799 ValueToUTF8String(argTwo.get(), stringTwo); |
3602 if (stringTwo.IsEmpty()) { | 3800 if (stringTwo.IsEmpty()) { |
3603 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); | 3801 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); |
3604 } else { | 3802 } else { |
3605 CFX_ByteString stringOne; | 3803 CFX_ByteString stringOne; |
3606 ValueToUTF8String(argOne.get(), stringOne); | 3804 ValueToUTF8String(argOne.get(), stringOne); |
3607 FX_STRSIZE iPosition = stringOne.Find(stringTwo.AsStringC()); | 3805 FX_STRSIZE iPosition = stringOne.Find(stringTwo.AsStringC()); |
3608 FXJSE_Value_SetInteger(args.GetReturnValue(), iPosition + 1); | 3806 FXJSE_Value_SetInteger(args.GetReturnValue(), iPosition + 1); |
3609 } | 3807 } |
3610 } | 3808 } |
3611 } else { | 3809 } else { |
3810 CXFA_FM2JSContext* pContext = | |
3811 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
3612 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3812 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
3613 L"At"); | 3813 L"At"); |
3614 } | 3814 } |
3615 } | 3815 } |
3816 | |
3817 // static | |
3616 void CXFA_FM2JSContext::Concat(CFXJSE_Value* pThis, | 3818 void CXFA_FM2JSContext::Concat(CFXJSE_Value* pThis, |
3617 const CFX_ByteStringC& szFuncName, | 3819 const CFX_ByteStringC& szFuncName, |
3618 CFXJSE_Arguments& args) { | 3820 CFXJSE_Arguments& args) { |
3619 CXFA_FM2JSContext* pContext = | |
3620 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
3621 int32_t argc = args.GetLength(); | 3821 int32_t argc = args.GetLength(); |
3622 if (argc >= 1) { | 3822 if (argc >= 1) { |
3623 CFX_ByteString resultString; | 3823 CFX_ByteString resultString; |
3624 FX_BOOL bAllNull = TRUE; | 3824 FX_BOOL bAllNull = TRUE; |
3625 | 3825 |
3626 for (int32_t i = 0; i < argc; i++) { | 3826 for (int32_t i = 0; i < argc; i++) { |
3627 std::unique_ptr<CFXJSE_Value> value = GetSimpleValue(pThis, args, i); | 3827 std::unique_ptr<CFXJSE_Value> value = GetSimpleValue(pThis, args, i); |
3628 if (!ValueIsNull(pThis, value.get())) { | 3828 if (!ValueIsNull(pThis, value.get())) { |
3629 CFX_ByteString valueStr; | 3829 CFX_ByteString valueStr; |
3630 ValueToUTF8String(value.get(), valueStr); | 3830 ValueToUTF8String(value.get(), valueStr); |
3631 resultString += valueStr; | 3831 resultString += valueStr; |
3632 bAllNull = FALSE; | 3832 bAllNull = FALSE; |
3633 } | 3833 } |
3634 } | 3834 } |
3635 | 3835 |
3636 if (bAllNull) { | 3836 if (bAllNull) { |
3637 FXJSE_Value_SetNull(args.GetReturnValue()); | 3837 FXJSE_Value_SetNull(args.GetReturnValue()); |
3638 } else { | 3838 } else { |
3639 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 3839 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
3640 resultString.AsStringC()); | 3840 resultString.AsStringC()); |
3641 } | 3841 } |
3642 } else { | 3842 } else { |
3843 CXFA_FM2JSContext* pContext = | |
3844 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
3643 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3845 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
3644 L"Concat"); | 3846 L"Concat"); |
3645 } | 3847 } |
3646 } | 3848 } |
3849 | |
3850 // static | |
3647 void CXFA_FM2JSContext::Decode(CFXJSE_Value* pThis, | 3851 void CXFA_FM2JSContext::Decode(CFXJSE_Value* pThis, |
3648 const CFX_ByteStringC& szFuncName, | 3852 const CFX_ByteStringC& szFuncName, |
3649 CFXJSE_Arguments& args) { | 3853 CFXJSE_Arguments& args) { |
3650 CXFA_FM2JSContext* pContext = | |
3651 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
3652 int32_t argc = args.GetLength(); | 3854 int32_t argc = args.GetLength(); |
3653 if (argc == 1) { | 3855 if (argc == 1) { |
3654 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 3856 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
3655 if (ValueIsNull(pThis, argOne.get())) { | 3857 if (ValueIsNull(pThis, argOne.get())) { |
3656 FXJSE_Value_SetNull(args.GetReturnValue()); | 3858 FXJSE_Value_SetNull(args.GetReturnValue()); |
3657 } else { | 3859 } else { |
3658 CFX_ByteString toDecodeString; | 3860 CFX_ByteString toDecodeString; |
3659 ValueToUTF8String(argOne.get(), toDecodeString); | 3861 ValueToUTF8String(argOne.get(), toDecodeString); |
3660 CFX_ByteTextBuf resultBuf; | 3862 CFX_ByteTextBuf resultBuf; |
3661 DecodeURL(toDecodeString.AsStringC(), resultBuf); | 3863 DecodeURL(toDecodeString.AsStringC(), resultBuf); |
(...skipping 13 matching lines...) Expand all Loading... | |
3675 if (identifyString.EqualNoCase("html")) { | 3877 if (identifyString.EqualNoCase("html")) { |
3676 DecodeHTML(toDecodeString.AsStringC(), resultBuf); | 3878 DecodeHTML(toDecodeString.AsStringC(), resultBuf); |
3677 } else if (identifyString.EqualNoCase("xml")) { | 3879 } else if (identifyString.EqualNoCase("xml")) { |
3678 DecodeXML(toDecodeString.AsStringC(), resultBuf); | 3880 DecodeXML(toDecodeString.AsStringC(), resultBuf); |
3679 } else { | 3881 } else { |
3680 DecodeURL(toDecodeString.AsStringC(), resultBuf); | 3882 DecodeURL(toDecodeString.AsStringC(), resultBuf); |
3681 } | 3883 } |
3682 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); | 3884 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); |
3683 } | 3885 } |
3684 } else { | 3886 } else { |
3887 CXFA_FM2JSContext* pContext = | |
3888 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
3685 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 3889 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
3686 L"Decode"); | 3890 L"Decode"); |
3687 } | 3891 } |
3688 } | 3892 } |
3893 | |
3894 // static | |
3689 void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString, | 3895 void CXFA_FM2JSContext::DecodeURL(const CFX_ByteStringC& szURLString, |
3690 CFX_ByteTextBuf& szResultString) { | 3896 CFX_ByteTextBuf& szResultString) { |
3691 CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString); | 3897 CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString); |
3692 const FX_WCHAR* pData = wsURLString.c_str(); | 3898 const FX_WCHAR* pData = wsURLString.c_str(); |
3693 int32_t iLen = wsURLString.GetLength(); | 3899 int32_t iLen = wsURLString.GetLength(); |
3694 int32_t i = 0; | 3900 int32_t i = 0; |
3695 FX_WCHAR ch = 0; | 3901 FX_WCHAR ch = 0; |
3696 FX_WCHAR chTemp = 0; | 3902 FX_WCHAR chTemp = 0; |
3697 CFX_WideTextBuf wsResultBuf; | 3903 CFX_WideTextBuf wsResultBuf; |
3698 while (i < iLen) { | 3904 while (i < iLen) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3734 wsResultBuf.AppendChar(ch); | 3940 wsResultBuf.AppendChar(ch); |
3735 } | 3941 } |
3736 ++i; | 3942 ++i; |
3737 } | 3943 } |
3738 wsResultBuf.AppendChar(0); | 3944 wsResultBuf.AppendChar(0); |
3739 szResultString.Clear(); | 3945 szResultString.Clear(); |
3740 szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), | 3946 szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), |
3741 wsResultBuf.GetLength()) | 3947 wsResultBuf.GetLength()) |
3742 .AsStringC(); | 3948 .AsStringC(); |
3743 } | 3949 } |
3950 | |
3951 // static | |
3744 void CXFA_FM2JSContext::DecodeHTML(const CFX_ByteStringC& szHTMLString, | 3952 void CXFA_FM2JSContext::DecodeHTML(const CFX_ByteStringC& szHTMLString, |
3745 CFX_ByteTextBuf& szResultString) { | 3953 CFX_ByteTextBuf& szResultString) { |
3746 CFX_WideString wsHTMLString = CFX_WideString::FromUTF8(szHTMLString); | 3954 CFX_WideString wsHTMLString = CFX_WideString::FromUTF8(szHTMLString); |
3747 FX_WCHAR strString[9]; | 3955 FX_WCHAR strString[9]; |
3748 int32_t iStrIndex = 0; | 3956 int32_t iStrIndex = 0; |
3749 int32_t iLen = wsHTMLString.GetLength(); | 3957 int32_t iLen = wsHTMLString.GetLength(); |
3750 int32_t i = 0; | 3958 int32_t i = 0; |
3751 int32_t iCode = 0; | 3959 int32_t iCode = 0; |
3752 FX_WCHAR ch = 0; | 3960 FX_WCHAR ch = 0; |
3753 const FX_WCHAR* pData = wsHTMLString.c_str(); | 3961 const FX_WCHAR* pData = wsHTMLString.c_str(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3808 iStrIndex = 0; | 4016 iStrIndex = 0; |
3809 strString[iStrIndex] = 0; | 4017 strString[iStrIndex] = 0; |
3810 ++i; | 4018 ++i; |
3811 } | 4019 } |
3812 wsResultBuf.AppendChar(0); | 4020 wsResultBuf.AppendChar(0); |
3813 szResultString.Clear(); | 4021 szResultString.Clear(); |
3814 szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), | 4022 szResultString << FX_UTF8Encode(wsResultBuf.GetBuffer(), |
3815 wsResultBuf.GetLength()) | 4023 wsResultBuf.GetLength()) |
3816 .AsStringC(); | 4024 .AsStringC(); |
3817 } | 4025 } |
4026 | |
4027 // static | |
3818 void CXFA_FM2JSContext::DecodeXML(const CFX_ByteStringC& szXMLString, | 4028 void CXFA_FM2JSContext::DecodeXML(const CFX_ByteStringC& szXMLString, |
3819 CFX_ByteTextBuf& szResultString) { | 4029 CFX_ByteTextBuf& szResultString) { |
3820 CFX_WideString wsXMLString = CFX_WideString::FromUTF8(szXMLString); | 4030 CFX_WideString wsXMLString = CFX_WideString::FromUTF8(szXMLString); |
3821 FX_WCHAR strString[9]; | 4031 FX_WCHAR strString[9]; |
3822 int32_t iStrIndex = 0; | 4032 int32_t iStrIndex = 0; |
3823 int32_t iLen = wsXMLString.GetLength(); | 4033 int32_t iLen = wsXMLString.GetLength(); |
3824 int32_t i = 0; | 4034 int32_t i = 0; |
3825 int32_t iCode = 0; | 4035 int32_t iCode = 0; |
3826 FX_WCHAR ch = 0; | 4036 FX_WCHAR ch = 0; |
3827 const FX_WCHAR* pData = wsXMLString.c_str(); | 4037 const FX_WCHAR* pData = wsXMLString.c_str(); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3905 iStrIndex = 0; | 4115 iStrIndex = 0; |
3906 strString[iStrIndex] = 0; | 4116 strString[iStrIndex] = 0; |
3907 ++i; | 4117 ++i; |
3908 iCode = 0; | 4118 iCode = 0; |
3909 } | 4119 } |
3910 wsXMLBuf.AppendChar(0); | 4120 wsXMLBuf.AppendChar(0); |
3911 szResultString.Clear(); | 4121 szResultString.Clear(); |
3912 szResultString << FX_UTF8Encode(wsXMLBuf.GetBuffer(), wsXMLBuf.GetLength()) | 4122 szResultString << FX_UTF8Encode(wsXMLBuf.GetBuffer(), wsXMLBuf.GetLength()) |
3913 .AsStringC(); | 4123 .AsStringC(); |
3914 } | 4124 } |
4125 | |
4126 // static | |
3915 void CXFA_FM2JSContext::Encode(CFXJSE_Value* pThis, | 4127 void CXFA_FM2JSContext::Encode(CFXJSE_Value* pThis, |
3916 const CFX_ByteStringC& szFuncName, | 4128 const CFX_ByteStringC& szFuncName, |
3917 CFXJSE_Arguments& args) { | 4129 CFXJSE_Arguments& args) { |
3918 CXFA_FM2JSContext* pContext = | |
3919 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
3920 int32_t argc = args.GetLength(); | 4130 int32_t argc = args.GetLength(); |
3921 if (argc == 1) { | 4131 if (argc == 1) { |
3922 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4132 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
3923 if (ValueIsNull(pThis, argOne.get())) { | 4133 if (ValueIsNull(pThis, argOne.get())) { |
3924 FXJSE_Value_SetNull(args.GetReturnValue()); | 4134 FXJSE_Value_SetNull(args.GetReturnValue()); |
3925 } else { | 4135 } else { |
3926 CFX_ByteString toEncodeString; | 4136 CFX_ByteString toEncodeString; |
3927 ValueToUTF8String(argOne.get(), toEncodeString); | 4137 ValueToUTF8String(argOne.get(), toEncodeString); |
3928 CFX_ByteTextBuf resultBuf; | 4138 CFX_ByteTextBuf resultBuf; |
3929 EncodeURL(toEncodeString.AsStringC(), resultBuf); | 4139 EncodeURL(toEncodeString.AsStringC(), resultBuf); |
(...skipping 13 matching lines...) Expand all Loading... | |
3943 if (identifyString.EqualNoCase("html")) { | 4153 if (identifyString.EqualNoCase("html")) { |
3944 EncodeHTML(toEncodeString.AsStringC(), resultBuf); | 4154 EncodeHTML(toEncodeString.AsStringC(), resultBuf); |
3945 } else if (identifyString.EqualNoCase("xml")) { | 4155 } else if (identifyString.EqualNoCase("xml")) { |
3946 EncodeXML(toEncodeString.AsStringC(), resultBuf); | 4156 EncodeXML(toEncodeString.AsStringC(), resultBuf); |
3947 } else { | 4157 } else { |
3948 EncodeURL(toEncodeString.AsStringC(), resultBuf); | 4158 EncodeURL(toEncodeString.AsStringC(), resultBuf); |
3949 } | 4159 } |
3950 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); | 4160 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultBuf.AsStringC()); |
3951 } | 4161 } |
3952 } else { | 4162 } else { |
4163 CXFA_FM2JSContext* pContext = | |
4164 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
3953 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4165 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
3954 L"Encode"); | 4166 L"Encode"); |
3955 } | 4167 } |
3956 } | 4168 } |
4169 | |
4170 // static | |
3957 void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString, | 4171 void CXFA_FM2JSContext::EncodeURL(const CFX_ByteStringC& szURLString, |
3958 CFX_ByteTextBuf& szResultBuf) { | 4172 CFX_ByteTextBuf& szResultBuf) { |
3959 CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString); | 4173 CFX_WideString wsURLString = CFX_WideString::FromUTF8(szURLString); |
3960 CFX_WideTextBuf wsResultBuf; | 4174 CFX_WideTextBuf wsResultBuf; |
3961 FX_WCHAR ch = 0; | 4175 FX_WCHAR ch = 0; |
3962 int32_t iLength = wsURLString.GetLength(); | 4176 int32_t iLength = wsURLString.GetLength(); |
3963 FX_WCHAR strEncode[4]; | 4177 FX_WCHAR strEncode[4]; |
3964 strEncode[0] = '%'; | 4178 strEncode[0] = '%'; |
3965 strEncode[3] = 0; | 4179 strEncode[3] = 0; |
3966 FX_WCHAR strUnsafe[] = {' ', '<', '>', '"', '#', '%', '{', '}', | 4180 FX_WCHAR strUnsafe[] = {' ', '<', '>', '"', '#', '%', '{', '}', |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4054 iIndex -= 2; | 4268 iIndex -= 2; |
4055 wsResultBuf << FX_WSTRC(strEncode); | 4269 wsResultBuf << FX_WSTRC(strEncode); |
4056 } | 4270 } |
4057 } | 4271 } |
4058 } | 4272 } |
4059 wsResultBuf.AppendChar(0); | 4273 wsResultBuf.AppendChar(0); |
4060 szResultBuf.Clear(); | 4274 szResultBuf.Clear(); |
4061 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()) | 4275 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()) |
4062 .AsStringC(); | 4276 .AsStringC(); |
4063 } | 4277 } |
4278 | |
4279 // static | |
4064 void CXFA_FM2JSContext::EncodeHTML(const CFX_ByteStringC& szHTMLString, | 4280 void CXFA_FM2JSContext::EncodeHTML(const CFX_ByteStringC& szHTMLString, |
4065 CFX_ByteTextBuf& szResultBuf) { | 4281 CFX_ByteTextBuf& szResultBuf) { |
4066 CFX_ByteString str = szHTMLString.c_str(); | 4282 CFX_ByteString str = szHTMLString.c_str(); |
4067 CFX_WideString wsHTMLString = CFX_WideString::FromUTF8(str.AsStringC()); | 4283 CFX_WideString wsHTMLString = CFX_WideString::FromUTF8(str.AsStringC()); |
4068 const FX_WCHAR* strCode = L"0123456789abcdef"; | 4284 const FX_WCHAR* strCode = L"0123456789abcdef"; |
4069 FX_WCHAR strEncode[9]; | 4285 FX_WCHAR strEncode[9]; |
4070 strEncode[0] = '&'; | 4286 strEncode[0] = '&'; |
4071 strEncode[1] = '#'; | 4287 strEncode[1] = '#'; |
4072 strEncode[2] = 'x'; | 4288 strEncode[2] = 'x'; |
4073 strEncode[5] = ';'; | 4289 strEncode[5] = ';'; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4108 wsResultBuf << FX_WSTRC(strEncode); | 4324 wsResultBuf << FX_WSTRC(strEncode); |
4109 } | 4325 } |
4110 } | 4326 } |
4111 ++i; | 4327 ++i; |
4112 } | 4328 } |
4113 wsResultBuf.AppendChar(0); | 4329 wsResultBuf.AppendChar(0); |
4114 szResultBuf.Clear(); | 4330 szResultBuf.Clear(); |
4115 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()) | 4331 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()) |
4116 .AsStringC(); | 4332 .AsStringC(); |
4117 } | 4333 } |
4334 | |
4335 // static | |
4118 void CXFA_FM2JSContext::EncodeXML(const CFX_ByteStringC& szXMLString, | 4336 void CXFA_FM2JSContext::EncodeXML(const CFX_ByteStringC& szXMLString, |
4119 CFX_ByteTextBuf& szResultBuf) { | 4337 CFX_ByteTextBuf& szResultBuf) { |
4120 CFX_WideString wsXMLString = CFX_WideString::FromUTF8(szXMLString); | 4338 CFX_WideString wsXMLString = CFX_WideString::FromUTF8(szXMLString); |
4121 CFX_WideTextBuf wsResultBuf; | 4339 CFX_WideTextBuf wsResultBuf; |
4122 enum { | 4340 enum { |
4123 QUOT, | 4341 QUOT, |
4124 AMP, | 4342 AMP, |
4125 APOS, | 4343 APOS, |
4126 LT, | 4344 LT, |
4127 GT, | 4345 GT, |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4189 wsResultBuf << FX_WSTRC(strEncode); | 4407 wsResultBuf << FX_WSTRC(strEncode); |
4190 } | 4408 } |
4191 } break; | 4409 } break; |
4192 } | 4410 } |
4193 } | 4411 } |
4194 wsResultBuf.AppendChar(0); | 4412 wsResultBuf.AppendChar(0); |
4195 szResultBuf.Clear(); | 4413 szResultBuf.Clear(); |
4196 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()) | 4414 szResultBuf << FX_UTF8Encode(wsResultBuf.GetBuffer(), wsResultBuf.GetLength()) |
4197 .AsStringC(); | 4415 .AsStringC(); |
4198 } | 4416 } |
4417 | |
4418 // static | |
4199 FX_BOOL CXFA_FM2JSContext::HTMLSTR2Code(const CFX_WideStringC& pData, | 4419 FX_BOOL CXFA_FM2JSContext::HTMLSTR2Code(const CFX_WideStringC& pData, |
4200 uint32_t& iCode) { | 4420 uint32_t& iCode) { |
4201 uint32_t uHash = FX_HashCode_GetW(pData, false); | 4421 uint32_t uHash = FX_HashCode_GetW(pData, false); |
4202 int32_t iStart = 0; | 4422 int32_t iStart = 0; |
4203 int32_t iEnd = FX_ArraySize(reservesForDecode) - 1; | 4423 int32_t iEnd = FX_ArraySize(reservesForDecode) - 1; |
4204 do { | 4424 do { |
4205 int32_t iMid = (iStart + iEnd) / 2; | 4425 int32_t iMid = (iStart + iEnd) / 2; |
4206 XFA_FMHtmlHashedReserveCode htmlhashedreservecode = reservesForDecode[iMid]; | 4426 XFA_FMHtmlHashedReserveCode htmlhashedreservecode = reservesForDecode[iMid]; |
4207 if (uHash == htmlhashedreservecode.m_uHash) { | 4427 if (uHash == htmlhashedreservecode.m_uHash) { |
4208 iCode = htmlhashedreservecode.m_uCode; | 4428 iCode = htmlhashedreservecode.m_uCode; |
4209 return TRUE; | 4429 return TRUE; |
4210 } | 4430 } |
4211 if (uHash < htmlhashedreservecode.m_uHash) { | 4431 if (uHash < htmlhashedreservecode.m_uHash) { |
4212 iEnd = iMid - 1; | 4432 iEnd = iMid - 1; |
4213 } else { | 4433 } else { |
4214 iStart = iMid + 1; | 4434 iStart = iMid + 1; |
4215 } | 4435 } |
4216 } while (iStart <= iEnd); | 4436 } while (iStart <= iEnd); |
4217 return FALSE; | 4437 return FALSE; |
4218 } | 4438 } |
4439 | |
4440 // static | |
4219 FX_BOOL CXFA_FM2JSContext::HTMLCode2STR(uint32_t iCode, | 4441 FX_BOOL CXFA_FM2JSContext::HTMLCode2STR(uint32_t iCode, |
4220 CFX_WideString& wsHTMLReserve) { | 4442 CFX_WideString& wsHTMLReserve) { |
4221 XFA_FMHtmlReserveCode htmlreservecode; | 4443 XFA_FMHtmlReserveCode htmlreservecode; |
4222 int32_t iStart = 0, | 4444 int32_t iStart = 0, |
4223 iEnd = (sizeof(reservesForEncode) / sizeof(reservesForEncode[0])) - 1; | 4445 iEnd = (sizeof(reservesForEncode) / sizeof(reservesForEncode[0])) - 1; |
4224 int32_t iMid = (iStart + iEnd) / 2; | 4446 int32_t iMid = (iStart + iEnd) / 2; |
4225 do { | 4447 do { |
4226 iMid = (iStart + iEnd) / 2; | 4448 iMid = (iStart + iEnd) / 2; |
4227 htmlreservecode = reservesForEncode[iMid]; | 4449 htmlreservecode = reservesForEncode[iMid]; |
4228 if (iCode == htmlreservecode.m_uCode) { | 4450 if (iCode == htmlreservecode.m_uCode) { |
4229 wsHTMLReserve = htmlreservecode.m_htmlReserve; | 4451 wsHTMLReserve = htmlreservecode.m_htmlReserve; |
4230 return TRUE; | 4452 return TRUE; |
4231 } else if (iCode < htmlreservecode.m_uCode) { | 4453 } else if (iCode < htmlreservecode.m_uCode) { |
4232 iEnd = iMid - 1; | 4454 iEnd = iMid - 1; |
4233 } else { | 4455 } else { |
4234 iStart = iMid + 1; | 4456 iStart = iMid + 1; |
4235 } | 4457 } |
4236 } while (iStart <= iEnd); | 4458 } while (iStart <= iEnd); |
4237 return FALSE; | 4459 return FALSE; |
4238 } | 4460 } |
4239 static FX_BOOL XFA_PATTERN_STRING_Type(const CFX_ByteStringC& szPattern, | 4461 |
4240 uint32_t& patternType) { | 4462 // 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, | 4463 void CXFA_FM2JSContext::Format(CFXJSE_Value* pThis, |
4324 const CFX_ByteStringC& szFuncName, | 4464 const CFX_ByteStringC& szFuncName, |
4325 CFXJSE_Arguments& args) { | 4465 CFXJSE_Arguments& args) { |
4326 CXFA_FM2JSContext* pContext = | 4466 CXFA_FM2JSContext* pContext = |
4327 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 4467 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
4328 int32_t argc = args.GetLength(); | 4468 if (args.GetLength() >= 2) { |
4329 if (argc >= 2) { | |
4330 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4469 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
4331 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | 4470 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
4332 CFX_ByteString szPattern; | 4471 CFX_ByteString szPattern; |
4333 ValueToUTF8String(argOne.get(), szPattern); | 4472 ValueToUTF8String(argOne.get(), szPattern); |
4334 CFX_ByteString szValue; | 4473 CFX_ByteString szValue; |
4335 ValueToUTF8String(argTwo.get(), szValue); | 4474 ValueToUTF8String(argTwo.get(), szValue); |
4336 CXFA_Document* pDoc = pContext->GetDocument(); | 4475 CXFA_Document* pDoc = pContext->GetDocument(); |
4337 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 4476 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
4338 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 4477 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
4339 ASSERT(pThisNode); | 4478 ASSERT(pThisNode); |
4340 CXFA_WidgetData widgetData(pThisNode); | 4479 CXFA_WidgetData widgetData(pThisNode); |
4341 IFX_Locale* pLocale = widgetData.GetLocal(); | 4480 IFX_Locale* pLocale = widgetData.GetLocal(); |
4342 uint32_t patternType; | 4481 uint32_t patternType; |
4343 FX_BOOL bCompelte = | |
4344 XFA_PATTERN_STRING_Type(szPattern.AsStringC(), patternType); | |
4345 CFX_WideString wsPattern = CFX_WideString::FromUTF8(szPattern.AsStringC()); | 4482 CFX_WideString wsPattern = CFX_WideString::FromUTF8(szPattern.AsStringC()); |
4346 CFX_WideString wsValue = CFX_WideString::FromUTF8(szValue.AsStringC()); | 4483 CFX_WideString wsValue = CFX_WideString::FromUTF8(szValue.AsStringC()); |
4347 if (!bCompelte) { | 4484 if (!PatternStringType(szPattern.AsStringC(), patternType)) { |
4348 switch (patternType) { | 4485 switch (patternType) { |
4349 case XFA_VT_DATETIME: { | 4486 case XFA_VT_DATETIME: { |
4350 FX_STRSIZE iTChar = wsPattern.Find(L'T'); | 4487 FX_STRSIZE iTChar = wsPattern.Find(L'T'); |
4351 CFX_WideString wsDatePattern(L"date{"); | 4488 CFX_WideString wsDatePattern(L"date{"); |
4352 wsDatePattern += wsPattern.Left(iTChar); | 4489 wsDatePattern += wsPattern.Left(iTChar); |
4353 wsDatePattern += FX_WSTRC(L"} "); | 4490 wsDatePattern += FX_WSTRC(L"} "); |
4354 CFX_WideString wsTimePattern(L"time{"); | 4491 CFX_WideString wsTimePattern(L"time{"); |
4355 wsTimePattern += wsPattern.Mid(iTChar + 1); | 4492 wsTimePattern += wsPattern.Mid(iTChar + 1); |
4356 wsTimePattern += FX_WSTRC(L"}"); | 4493 wsTimePattern += FX_WSTRC(L"}"); |
4357 wsPattern = wsDatePattern + wsTimePattern; | 4494 wsPattern = wsDatePattern + wsTimePattern; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4399 args.GetReturnValue(), | 4536 args.GetReturnValue(), |
4400 FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()).AsStringC()); | 4537 FX_UTF8Encode(wsRet.c_str(), wsRet.GetLength()).AsStringC()); |
4401 } else { | 4538 } else { |
4402 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 4539 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
4403 } | 4540 } |
4404 } else { | 4541 } else { |
4405 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4542 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
4406 L"Format"); | 4543 L"Format"); |
4407 } | 4544 } |
4408 } | 4545 } |
4546 | |
4547 // static | |
4409 void CXFA_FM2JSContext::Left(CFXJSE_Value* pThis, | 4548 void CXFA_FM2JSContext::Left(CFXJSE_Value* pThis, |
4410 const CFX_ByteStringC& szFuncName, | 4549 const CFX_ByteStringC& szFuncName, |
4411 CFXJSE_Arguments& args) { | 4550 CFXJSE_Arguments& args) { |
4412 CXFA_FM2JSContext* pContext = | |
4413 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
4414 if (args.GetLength() == 2) { | 4551 if (args.GetLength() == 2) { |
4415 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4552 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
4416 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | 4553 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
4417 FX_BOOL argIsNull = FALSE; | 4554 FX_BOOL argIsNull = FALSE; |
4418 if ((ValueIsNull(pThis, argOne.get())) || | 4555 if ((ValueIsNull(pThis, argOne.get())) || |
4419 (ValueIsNull(pThis, argTwo.get()))) { | 4556 (ValueIsNull(pThis, argTwo.get()))) { |
4420 argIsNull = TRUE; | 4557 argIsNull = TRUE; |
4421 } | 4558 } |
4422 if (argIsNull) { | 4559 if (argIsNull) { |
4423 FXJSE_Value_SetNull(args.GetReturnValue()); | 4560 FXJSE_Value_SetNull(args.GetReturnValue()); |
4424 } else { | 4561 } else { |
4425 CFX_ByteString sourceString; | 4562 CFX_ByteString sourceString; |
4426 ValueToUTF8String(argOne.get(), sourceString); | 4563 ValueToUTF8String(argOne.get(), sourceString); |
4427 int32_t count = ValueToInteger(pThis, argTwo.get()); | 4564 int32_t count = ValueToInteger(pThis, argTwo.get()); |
4428 if (count < 0) { | 4565 if (count < 0) { |
4429 count = 0; | 4566 count = 0; |
4430 } | 4567 } |
4431 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 4568 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
4432 sourceString.Left(count).AsStringC()); | 4569 sourceString.Left(count).AsStringC()); |
4433 } | 4570 } |
4434 } else { | 4571 } else { |
4572 CXFA_FM2JSContext* pContext = | |
4573 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
4435 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4574 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
4436 L"Left"); | 4575 L"Left"); |
4437 } | 4576 } |
4438 } | 4577 } |
4578 | |
4579 // static | |
4439 void CXFA_FM2JSContext::Len(CFXJSE_Value* pThis, | 4580 void CXFA_FM2JSContext::Len(CFXJSE_Value* pThis, |
4440 const CFX_ByteStringC& szFuncName, | 4581 const CFX_ByteStringC& szFuncName, |
4441 CFXJSE_Arguments& args) { | 4582 CFXJSE_Arguments& args) { |
4442 CXFA_FM2JSContext* pContext = | |
4443 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
4444 if (args.GetLength() == 1) { | 4583 if (args.GetLength() == 1) { |
4445 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4584 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
4446 if (ValueIsNull(pThis, argOne.get())) { | 4585 if (ValueIsNull(pThis, argOne.get())) { |
4447 FXJSE_Value_SetNull(args.GetReturnValue()); | 4586 FXJSE_Value_SetNull(args.GetReturnValue()); |
4448 } else { | 4587 } else { |
4449 CFX_ByteString sourceString; | 4588 CFX_ByteString sourceString; |
4450 ValueToUTF8String(argOne.get(), sourceString); | 4589 ValueToUTF8String(argOne.get(), sourceString); |
4451 FXJSE_Value_SetInteger(args.GetReturnValue(), sourceString.GetLength()); | 4590 FXJSE_Value_SetInteger(args.GetReturnValue(), sourceString.GetLength()); |
4452 } | 4591 } |
4453 } else { | 4592 } else { |
4593 CXFA_FM2JSContext* pContext = | |
4594 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
4454 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4595 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
4455 L"Len"); | 4596 L"Len"); |
4456 } | 4597 } |
4457 } | 4598 } |
4599 | |
4600 // static | |
4458 void CXFA_FM2JSContext::Lower(CFXJSE_Value* pThis, | 4601 void CXFA_FM2JSContext::Lower(CFXJSE_Value* pThis, |
4459 const CFX_ByteStringC& szFuncName, | 4602 const CFX_ByteStringC& szFuncName, |
4460 CFXJSE_Arguments& args) { | 4603 CFXJSE_Arguments& args) { |
4461 int32_t argc = args.GetLength(); | 4604 int32_t argc = args.GetLength(); |
4462 if ((argc > 0) && (argc < 3)) { | 4605 if ((argc > 0) && (argc < 3)) { |
4463 CFX_ByteString argString; | 4606 CFX_ByteString argString; |
4464 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4607 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
4465 if (ValueIsNull(pThis, argOne.get())) { | 4608 if (ValueIsNull(pThis, argOne.get())) { |
4466 FXJSE_Value_SetNull(args.GetReturnValue()); | 4609 FXJSE_Value_SetNull(args.GetReturnValue()); |
4467 } else { | 4610 } else { |
(...skipping 23 matching lines...) Expand all Loading... | |
4491 FX_UTF8Encode(lowStringBuf.GetBuffer(), lowStringBuf.GetLength()) | 4634 FX_UTF8Encode(lowStringBuf.GetBuffer(), lowStringBuf.GetLength()) |
4492 .AsStringC()); | 4635 .AsStringC()); |
4493 } | 4636 } |
4494 } else { | 4637 } else { |
4495 CXFA_FM2JSContext* pContext = | 4638 CXFA_FM2JSContext* pContext = |
4496 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 4639 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
4497 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4640 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
4498 L"Lower"); | 4641 L"Lower"); |
4499 } | 4642 } |
4500 } | 4643 } |
4644 | |
4645 // static | |
4501 void CXFA_FM2JSContext::Ltrim(CFXJSE_Value* pThis, | 4646 void CXFA_FM2JSContext::Ltrim(CFXJSE_Value* pThis, |
4502 const CFX_ByteStringC& szFuncName, | 4647 const CFX_ByteStringC& szFuncName, |
4503 CFXJSE_Arguments& args) { | 4648 CFXJSE_Arguments& args) { |
4504 CXFA_FM2JSContext* pContext = | |
4505 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
4506 if (args.GetLength() == 1) { | 4649 if (args.GetLength() == 1) { |
4507 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4650 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
4508 if (ValueIsNull(pThis, argOne.get())) { | 4651 if (ValueIsNull(pThis, argOne.get())) { |
4509 FXJSE_Value_SetNull(args.GetReturnValue()); | 4652 FXJSE_Value_SetNull(args.GetReturnValue()); |
4510 } else { | 4653 } else { |
4511 CFX_ByteString sourceString; | 4654 CFX_ByteString sourceString; |
4512 ValueToUTF8String(argOne.get(), sourceString); | 4655 ValueToUTF8String(argOne.get(), sourceString); |
4513 sourceString.TrimLeft(); | 4656 sourceString.TrimLeft(); |
4514 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 4657 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
4515 sourceString.AsStringC()); | 4658 sourceString.AsStringC()); |
4516 } | 4659 } |
4517 } else { | 4660 } else { |
4661 CXFA_FM2JSContext* pContext = | |
4662 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
4518 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4663 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
4519 L"Ltrim"); | 4664 L"Ltrim"); |
4520 } | 4665 } |
4521 } | 4666 } |
4667 | |
4668 // static | |
4522 void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis, | 4669 void CXFA_FM2JSContext::Parse(CFXJSE_Value* pThis, |
4523 const CFX_ByteStringC& szFuncName, | 4670 const CFX_ByteStringC& szFuncName, |
4524 CFXJSE_Arguments& args) { | 4671 CFXJSE_Arguments& args) { |
4525 CXFA_FM2JSContext* pContext = | 4672 CXFA_FM2JSContext* pContext = |
4526 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 4673 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
4527 if (args.GetLength() == 2) { | 4674 if (args.GetLength() == 2) { |
4528 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4675 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
4529 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | 4676 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
4530 if (ValueIsNull(pThis, argTwo.get())) { | 4677 if (ValueIsNull(pThis, argTwo.get())) { |
4531 FXJSE_Value_SetNull(args.GetReturnValue()); | 4678 FXJSE_Value_SetNull(args.GetReturnValue()); |
4532 } else { | 4679 } else { |
4533 CFX_ByteString szPattern; | 4680 CFX_ByteString szPattern; |
4534 ValueToUTF8String(argOne.get(), szPattern); | 4681 ValueToUTF8String(argOne.get(), szPattern); |
4535 CFX_ByteString szValue; | 4682 CFX_ByteString szValue; |
4536 ValueToUTF8String(argTwo.get(), szValue); | 4683 ValueToUTF8String(argTwo.get(), szValue); |
4537 CXFA_Document* pDoc = pContext->GetDocument(); | 4684 CXFA_Document* pDoc = pContext->GetDocument(); |
4538 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); | 4685 IFX_LocaleMgr* pMgr = (IFX_LocaleMgr*)pDoc->GetLocalMgr(); |
4539 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); | 4686 CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject()); |
4540 ASSERT(pThisNode); | 4687 ASSERT(pThisNode); |
4541 CXFA_WidgetData widgetData(pThisNode); | 4688 CXFA_WidgetData widgetData(pThisNode); |
4542 IFX_Locale* pLocale = widgetData.GetLocal(); | 4689 IFX_Locale* pLocale = widgetData.GetLocal(); |
4543 uint32_t patternType; | 4690 uint32_t patternType; |
4544 FX_BOOL bCompletePattern = | |
4545 XFA_PATTERN_STRING_Type(szPattern.AsStringC(), patternType); | |
4546 CFX_WideString wsPattern = | 4691 CFX_WideString wsPattern = |
4547 CFX_WideString::FromUTF8(szPattern.AsStringC()); | 4692 CFX_WideString::FromUTF8(szPattern.AsStringC()); |
4548 CFX_WideString wsValue = CFX_WideString::FromUTF8(szValue.AsStringC()); | 4693 CFX_WideString wsValue = CFX_WideString::FromUTF8(szValue.AsStringC()); |
4549 CFX_ByteString szParsedValue; | 4694 CFX_ByteString szParsedValue; |
4550 if (bCompletePattern) { | 4695 if (PatternStringType(szPattern.AsStringC(), patternType)) { |
4551 CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, pLocale, | 4696 CXFA_LocaleValue localeValue(patternType, wsValue, wsPattern, pLocale, |
4552 (CXFA_LocaleMgr*)pMgr); | 4697 (CXFA_LocaleMgr*)pMgr); |
4553 if (localeValue.IsValid()) { | 4698 if (localeValue.IsValid()) { |
4554 szParsedValue = FX_UTF8Encode(localeValue.GetValue()); | 4699 szParsedValue = FX_UTF8Encode(localeValue.GetValue()); |
4555 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 4700 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
4556 szParsedValue.AsStringC()); | 4701 szParsedValue.AsStringC()); |
4557 } else { | 4702 } else { |
4558 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 4703 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
4559 } | 4704 } |
4560 } else { | 4705 } else { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4653 } | 4798 } |
4654 } break; | 4799 } break; |
4655 } | 4800 } |
4656 } | 4801 } |
4657 } | 4802 } |
4658 } else { | 4803 } else { |
4659 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4804 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
4660 L"Parse"); | 4805 L"Parse"); |
4661 } | 4806 } |
4662 } | 4807 } |
4808 | |
4809 // static | |
4663 void CXFA_FM2JSContext::Replace(CFXJSE_Value* pThis, | 4810 void CXFA_FM2JSContext::Replace(CFXJSE_Value* pThis, |
4664 const CFX_ByteStringC& szFuncName, | 4811 const CFX_ByteStringC& szFuncName, |
4665 CFXJSE_Arguments& args) { | 4812 CFXJSE_Arguments& args) { |
4666 int32_t argc = args.GetLength(); | 4813 int32_t argc = args.GetLength(); |
4667 if ((argc == 2) || (argc == 3)) { | 4814 if ((argc == 2) || (argc == 3)) { |
4668 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4815 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
4669 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | 4816 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
4670 CFX_ByteString oneString; | 4817 CFX_ByteString oneString; |
4671 CFX_ByteString twoString; | 4818 CFX_ByteString twoString; |
4672 CFX_ByteString threeString; | 4819 CFX_ByteString threeString; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4713 } | 4860 } |
4714 resultString.AppendChar(0); | 4861 resultString.AppendChar(0); |
4715 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); | 4862 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); |
4716 } else { | 4863 } else { |
4717 CXFA_FM2JSContext* pContext = | 4864 CXFA_FM2JSContext* pContext = |
4718 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 4865 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
4719 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4866 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
4720 L"Replace"); | 4867 L"Replace"); |
4721 } | 4868 } |
4722 } | 4869 } |
4870 | |
4871 // static | |
4723 void CXFA_FM2JSContext::Right(CFXJSE_Value* pThis, | 4872 void CXFA_FM2JSContext::Right(CFXJSE_Value* pThis, |
4724 const CFX_ByteStringC& szFuncName, | 4873 const CFX_ByteStringC& szFuncName, |
4725 CFXJSE_Arguments& args) { | 4874 CFXJSE_Arguments& args) { |
4726 CXFA_FM2JSContext* pContext = | |
4727 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
4728 if (args.GetLength() == 2) { | 4875 if (args.GetLength() == 2) { |
4729 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4876 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
4730 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); | 4877 std::unique_ptr<CFXJSE_Value> argTwo = GetSimpleValue(pThis, args, 1); |
4731 FX_BOOL argIsNull = FALSE; | 4878 FX_BOOL argIsNull = FALSE; |
4732 if ((ValueIsNull(pThis, argOne.get())) || | 4879 if ((ValueIsNull(pThis, argOne.get())) || |
4733 (ValueIsNull(pThis, argTwo.get()))) { | 4880 (ValueIsNull(pThis, argTwo.get()))) { |
4734 argIsNull = TRUE; | 4881 argIsNull = TRUE; |
4735 } | 4882 } |
4736 if (argIsNull) { | 4883 if (argIsNull) { |
4737 FXJSE_Value_SetNull(args.GetReturnValue()); | 4884 FXJSE_Value_SetNull(args.GetReturnValue()); |
4738 } else { | 4885 } else { |
4739 CFX_ByteString sourceString; | 4886 CFX_ByteString sourceString; |
4740 ValueToUTF8String(argOne.get(), sourceString); | 4887 ValueToUTF8String(argOne.get(), sourceString); |
4741 int32_t count = ValueToInteger(pThis, argTwo.get()); | 4888 int32_t count = ValueToInteger(pThis, argTwo.get()); |
4742 if (count < 0) { | 4889 if (count < 0) { |
4743 count = 0; | 4890 count = 0; |
4744 } | 4891 } |
4745 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 4892 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
4746 sourceString.Right(count).AsStringC()); | 4893 sourceString.Right(count).AsStringC()); |
4747 } | 4894 } |
4748 } else { | 4895 } else { |
4896 CXFA_FM2JSContext* pContext = | |
4897 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
4749 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4898 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
4750 L"Right"); | 4899 L"Right"); |
4751 } | 4900 } |
4752 } | 4901 } |
4902 | |
4903 // static | |
4753 void CXFA_FM2JSContext::Rtrim(CFXJSE_Value* pThis, | 4904 void CXFA_FM2JSContext::Rtrim(CFXJSE_Value* pThis, |
4754 const CFX_ByteStringC& szFuncName, | 4905 const CFX_ByteStringC& szFuncName, |
4755 CFXJSE_Arguments& args) { | 4906 CFXJSE_Arguments& args) { |
4756 CXFA_FM2JSContext* pContext = | |
4757 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
4758 if (args.GetLength() == 1) { | 4907 if (args.GetLength() == 1) { |
4759 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4908 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
4760 if (ValueIsNull(pThis, argOne.get())) { | 4909 if (ValueIsNull(pThis, argOne.get())) { |
4761 FXJSE_Value_SetNull(args.GetReturnValue()); | 4910 FXJSE_Value_SetNull(args.GetReturnValue()); |
4762 } else { | 4911 } else { |
4763 CFX_ByteString sourceString; | 4912 CFX_ByteString sourceString; |
4764 ValueToUTF8String(argOne.get(), sourceString); | 4913 ValueToUTF8String(argOne.get(), sourceString); |
4765 sourceString.TrimRight(); | 4914 sourceString.TrimRight(); |
4766 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 4915 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
4767 sourceString.AsStringC()); | 4916 sourceString.AsStringC()); |
4768 } | 4917 } |
4769 } else { | 4918 } else { |
4919 CXFA_FM2JSContext* pContext = | |
4920 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
4770 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4921 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
4771 L"Rtrim"); | 4922 L"Rtrim"); |
4772 } | 4923 } |
4773 } | 4924 } |
4925 | |
4926 // static | |
4774 void CXFA_FM2JSContext::Space(CFXJSE_Value* pThis, | 4927 void CXFA_FM2JSContext::Space(CFXJSE_Value* pThis, |
4775 const CFX_ByteStringC& szFuncName, | 4928 const CFX_ByteStringC& szFuncName, |
4776 CFXJSE_Arguments& args) { | 4929 CFXJSE_Arguments& args) { |
4777 CXFA_FM2JSContext* pContext = | |
4778 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
4779 if (args.GetLength() == 1) { | 4930 if (args.GetLength() == 1) { |
4780 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4931 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
4781 if (FXJSE_Value_IsNull(argOne.get())) { | 4932 if (FXJSE_Value_IsNull(argOne.get())) { |
4782 FXJSE_Value_SetNull(args.GetReturnValue()); | 4933 FXJSE_Value_SetNull(args.GetReturnValue()); |
4783 } else { | 4934 } else { |
4784 int32_t count = 0; | 4935 int32_t count = 0; |
4785 count = ValueToInteger(pThis, argOne.get()); | 4936 count = ValueToInteger(pThis, argOne.get()); |
4786 count = (count < 0) ? 0 : count; | 4937 count = (count < 0) ? 0 : count; |
4787 CFX_ByteTextBuf spaceString; | 4938 CFX_ByteTextBuf spaceString; |
4788 int32_t index = 0; | 4939 int32_t index = 0; |
4789 while (index < count) { | 4940 while (index < count) { |
4790 spaceString.AppendByte(' '); | 4941 spaceString.AppendByte(' '); |
4791 index++; | 4942 index++; |
4792 } | 4943 } |
4793 spaceString.AppendByte(0); | 4944 spaceString.AppendByte(0); |
4794 FXJSE_Value_SetUTF8String(args.GetReturnValue(), spaceString.AsStringC()); | 4945 FXJSE_Value_SetUTF8String(args.GetReturnValue(), spaceString.AsStringC()); |
4795 } | 4946 } |
4796 } else { | 4947 } else { |
4948 CXFA_FM2JSContext* pContext = | |
4949 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | |
4797 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 4950 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
4798 L"Space"); | 4951 L"Space"); |
4799 } | 4952 } |
4800 } | 4953 } |
4954 | |
4955 // static | |
4801 void CXFA_FM2JSContext::Str(CFXJSE_Value* pThis, | 4956 void CXFA_FM2JSContext::Str(CFXJSE_Value* pThis, |
4802 const CFX_ByteStringC& szFuncName, | 4957 const CFX_ByteStringC& szFuncName, |
4803 CFXJSE_Arguments& args) { | 4958 CFXJSE_Arguments& args) { |
4804 int32_t argc = args.GetLength(); | 4959 int32_t argc = args.GetLength(); |
4805 if ((argc > 0) && (argc < 4)) { | 4960 if ((argc > 0) && (argc < 4)) { |
4806 FX_BOOL bFlags = FALSE; | 4961 FX_BOOL bFlags = FALSE; |
4807 FX_FLOAT fNumber = 0.0f; | 4962 FX_FLOAT fNumber = 0.0f; |
4808 int32_t iWidth = 10; | 4963 int32_t iWidth = 10; |
4809 int32_t iPrecision = 0; | 4964 int32_t iPrecision = 0; |
4810 std::unique_ptr<CFXJSE_Value> numberValue = GetSimpleValue(pThis, args, 0); | 4965 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 { | 5064 } else { |
4910 FXJSE_Value_SetNull(args.GetReturnValue()); | 5065 FXJSE_Value_SetNull(args.GetReturnValue()); |
4911 } | 5066 } |
4912 } else { | 5067 } else { |
4913 CXFA_FM2JSContext* pContext = | 5068 CXFA_FM2JSContext* pContext = |
4914 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5069 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
4915 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5070 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
4916 L"Str"); | 5071 L"Str"); |
4917 } | 5072 } |
4918 } | 5073 } |
5074 | |
5075 // static | |
4919 void CXFA_FM2JSContext::Stuff(CFXJSE_Value* pThis, | 5076 void CXFA_FM2JSContext::Stuff(CFXJSE_Value* pThis, |
4920 const CFX_ByteStringC& szFuncName, | 5077 const CFX_ByteStringC& szFuncName, |
4921 CFXJSE_Arguments& args) { | 5078 CFXJSE_Arguments& args) { |
4922 int32_t argc = args.GetLength(); | 5079 int32_t argc = args.GetLength(); |
4923 if ((argc == 3) || (argc == 4)) { | 5080 if ((argc == 3) || (argc == 4)) { |
4924 CFX_ByteString sourceString; | 5081 CFX_ByteString sourceString; |
4925 CFX_ByteString insertString; | 5082 CFX_ByteString insertString; |
4926 int32_t iLength = 0; | 5083 int32_t iLength = 0; |
4927 int32_t iStart = 0; | 5084 int32_t iStart = 0; |
4928 int32_t iDelete = 0; | 5085 int32_t iDelete = 0; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4966 } | 5123 } |
4967 resultString.AppendChar(0); | 5124 resultString.AppendChar(0); |
4968 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); | 5125 FXJSE_Value_SetUTF8String(args.GetReturnValue(), resultString.AsStringC()); |
4969 } else { | 5126 } else { |
4970 CXFA_FM2JSContext* pContext = | 5127 CXFA_FM2JSContext* pContext = |
4971 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5128 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
4972 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5129 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
4973 L"Stuff"); | 5130 L"Stuff"); |
4974 } | 5131 } |
4975 } | 5132 } |
5133 | |
5134 // static | |
4976 void CXFA_FM2JSContext::Substr(CFXJSE_Value* pThis, | 5135 void CXFA_FM2JSContext::Substr(CFXJSE_Value* pThis, |
4977 const CFX_ByteStringC& szFuncName, | 5136 const CFX_ByteStringC& szFuncName, |
4978 CFXJSE_Arguments& args) { | 5137 CFXJSE_Arguments& args) { |
4979 int32_t argc = args.GetLength(); | 5138 if (args.GetLength() == 3) { |
4980 if (argc == 3) { | |
4981 std::unique_ptr<CFXJSE_Value> stringValue = GetSimpleValue(pThis, args, 0); | 5139 std::unique_ptr<CFXJSE_Value> stringValue = GetSimpleValue(pThis, args, 0); |
4982 std::unique_ptr<CFXJSE_Value> startValue = GetSimpleValue(pThis, args, 1); | 5140 std::unique_ptr<CFXJSE_Value> startValue = GetSimpleValue(pThis, args, 1); |
4983 std::unique_ptr<CFXJSE_Value> endValue = GetSimpleValue(pThis, args, 2); | 5141 std::unique_ptr<CFXJSE_Value> endValue = GetSimpleValue(pThis, args, 2); |
4984 if (ValueIsNull(pThis, stringValue.get()) || | 5142 if (ValueIsNull(pThis, stringValue.get()) || |
4985 (ValueIsNull(pThis, startValue.get())) || | 5143 (ValueIsNull(pThis, startValue.get())) || |
4986 (ValueIsNull(pThis, endValue.get()))) { | 5144 (ValueIsNull(pThis, endValue.get()))) { |
4987 FXJSE_Value_SetNull(args.GetReturnValue()); | 5145 FXJSE_Value_SetNull(args.GetReturnValue()); |
4988 } else { | 5146 } else { |
4989 CFX_ByteString szSourceStr; | 5147 CFX_ByteString szSourceStr; |
4990 int32_t iStart = 0; | 5148 int32_t iStart = 0; |
(...skipping 19 matching lines...) Expand all Loading... | |
5010 szSourceStr.Mid(iStart, iCount).AsStringC()); | 5168 szSourceStr.Mid(iStart, iCount).AsStringC()); |
5011 } | 5169 } |
5012 } | 5170 } |
5013 } else { | 5171 } else { |
5014 CXFA_FM2JSContext* pContext = | 5172 CXFA_FM2JSContext* pContext = |
5015 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5173 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5016 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5174 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
5017 L"Substr"); | 5175 L"Substr"); |
5018 } | 5176 } |
5019 } | 5177 } |
5178 | |
5179 // static | |
5020 void CXFA_FM2JSContext::Uuid(CFXJSE_Value* pThis, | 5180 void CXFA_FM2JSContext::Uuid(CFXJSE_Value* pThis, |
5021 const CFX_ByteStringC& szFuncName, | 5181 const CFX_ByteStringC& szFuncName, |
5022 CFXJSE_Arguments& args) { | 5182 CFXJSE_Arguments& args) { |
5023 int32_t argc = args.GetLength(); | 5183 int32_t argc = args.GetLength(); |
5024 if ((argc == 0) || (argc == 1)) { | 5184 if ((argc == 0) || (argc == 1)) { |
5025 int32_t iNum = 0; | 5185 int32_t iNum = 0; |
5026 if (argc == 1) { | 5186 if (argc == 1) { |
5027 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 5187 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
5028 iNum = (int32_t)ValueToFloat(pThis, argOne.get()); | 5188 iNum = (int32_t)ValueToFloat(pThis, argOne.get()); |
5029 } | 5189 } |
5030 FX_GUID guid; | 5190 FX_GUID guid; |
5031 FX_GUID_CreateV4(&guid); | 5191 FX_GUID_CreateV4(&guid); |
5032 CFX_ByteString bsUId; | 5192 CFX_ByteString bsUId; |
5033 FX_GUID_ToString(&guid, bsUId, iNum); | 5193 FX_GUID_ToString(&guid, bsUId, iNum); |
5034 FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsUId.AsStringC()); | 5194 FXJSE_Value_SetUTF8String(args.GetReturnValue(), bsUId.AsStringC()); |
5035 } else { | 5195 } else { |
5036 CXFA_FM2JSContext* pContext = | 5196 CXFA_FM2JSContext* pContext = |
5037 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5197 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5038 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5198 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
5039 L"Uuid"); | 5199 L"Uuid"); |
5040 } | 5200 } |
5041 } | 5201 } |
5202 | |
5203 // static | |
5042 void CXFA_FM2JSContext::Upper(CFXJSE_Value* pThis, | 5204 void CXFA_FM2JSContext::Upper(CFXJSE_Value* pThis, |
5043 const CFX_ByteStringC& szFuncName, | 5205 const CFX_ByteStringC& szFuncName, |
5044 CFXJSE_Arguments& args) { | 5206 CFXJSE_Arguments& args) { |
5045 int32_t argc = args.GetLength(); | 5207 int32_t argc = args.GetLength(); |
5046 if ((argc > 0) && (argc < 3)) { | 5208 if ((argc > 0) && (argc < 3)) { |
5047 CFX_ByteString argString; | 5209 CFX_ByteString argString; |
5048 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 5210 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
5049 if (ValueIsNull(pThis, argOne.get())) { | 5211 if (ValueIsNull(pThis, argOne.get())) { |
5050 FXJSE_Value_SetNull(args.GetReturnValue()); | 5212 FXJSE_Value_SetNull(args.GetReturnValue()); |
5051 } else { | 5213 } else { |
(...skipping 23 matching lines...) Expand all Loading... | |
5075 FX_UTF8Encode(upperStringBuf.GetBuffer(), upperStringBuf.GetLength()) | 5237 FX_UTF8Encode(upperStringBuf.GetBuffer(), upperStringBuf.GetLength()) |
5076 .AsStringC()); | 5238 .AsStringC()); |
5077 } | 5239 } |
5078 } else { | 5240 } else { |
5079 CXFA_FM2JSContext* pContext = | 5241 CXFA_FM2JSContext* pContext = |
5080 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5242 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5081 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5243 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
5082 L"Upper"); | 5244 L"Upper"); |
5083 } | 5245 } |
5084 } | 5246 } |
5247 | |
5248 // static | |
5085 void CXFA_FM2JSContext::WordNum(CFXJSE_Value* pThis, | 5249 void CXFA_FM2JSContext::WordNum(CFXJSE_Value* pThis, |
5086 const CFX_ByteStringC& szFuncName, | 5250 const CFX_ByteStringC& szFuncName, |
5087 CFXJSE_Arguments& args) { | 5251 CFXJSE_Arguments& args) { |
5088 int32_t argc = args.GetLength(); | 5252 int32_t argc = args.GetLength(); |
5089 if ((argc > 0) && (argc < 4)) { | 5253 if ((argc > 0) && (argc < 4)) { |
5090 FX_BOOL bFlags = FALSE; | 5254 FX_BOOL bFlags = FALSE; |
5091 FX_FLOAT fNumber = 0.0f; | 5255 FX_FLOAT fNumber = 0.0f; |
5092 int32_t iIdentifier = 0; | 5256 int32_t iIdentifier = 0; |
5093 CFX_ByteString localeString; | 5257 CFX_ByteString localeString; |
5094 std::unique_ptr<CFXJSE_Value> numberValue = GetSimpleValue(pThis, args, 0); | 5258 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 { | 5292 } else { |
5129 FXJSE_Value_SetNull(args.GetReturnValue()); | 5293 FXJSE_Value_SetNull(args.GetReturnValue()); |
5130 } | 5294 } |
5131 } else { | 5295 } else { |
5132 CXFA_FM2JSContext* pContext = | 5296 CXFA_FM2JSContext* pContext = |
5133 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5297 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5134 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5298 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
5135 L"WordNum"); | 5299 L"WordNum"); |
5136 } | 5300 } |
5137 } | 5301 } |
5302 | |
5303 // static | |
5138 void CXFA_FM2JSContext::TrillionUS(const CFX_ByteStringC& szData, | 5304 void CXFA_FM2JSContext::TrillionUS(const CFX_ByteStringC& szData, |
5139 CFX_ByteTextBuf& strBuf) { | 5305 CFX_ByteTextBuf& strBuf) { |
5140 CFX_ByteStringC pUnits[] = {"zero", "one", "two", "three", "four", | 5306 CFX_ByteStringC pUnits[] = {"zero", "one", "two", "three", "four", |
5141 "five", "six", "seven", "eight", "nine"}; | 5307 "five", "six", "seven", "eight", "nine"}; |
5142 CFX_ByteStringC pCapUnits[] = {"Zero", "One", "Two", "Three", "Four", | 5308 CFX_ByteStringC pCapUnits[] = {"Zero", "One", "Two", "Three", "Four", |
5143 "Five", "Six", "Seven", "Eight", "Nine"}; | 5309 "Five", "Six", "Seven", "Eight", "Nine"}; |
5144 CFX_ByteStringC pTens[] = {"Ten", "Eleven", "Twelve", "Thirteen", | 5310 CFX_ByteStringC pTens[] = {"Ten", "Eleven", "Twelve", "Thirteen", |
5145 "Fourteen", "Fifteen", "Sixteen", "Seventeen", | 5311 "Fourteen", "Fifteen", "Sixteen", "Seventeen", |
5146 "Eighteen", "Nineteen"}; | 5312 "Eighteen", "Nineteen"}; |
5147 CFX_ByteStringC pLastTens[] = {"Twenty", "Thirty", "Forty", "Fifty", | 5313 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']; | 5391 strBuf << pCapUnits[*(pData + iIndex + 2) - '0']; |
5226 } | 5392 } |
5227 } | 5393 } |
5228 if (iIndex < iLength - 3) { | 5394 if (iIndex < iLength - 3) { |
5229 strBuf << pComm[iComm]; | 5395 strBuf << pComm[iComm]; |
5230 --iComm; | 5396 --iComm; |
5231 } | 5397 } |
5232 iIndex += 3; | 5398 iIndex += 3; |
5233 } | 5399 } |
5234 } | 5400 } |
5401 | |
5402 // static | |
5235 void CXFA_FM2JSContext::WordUS(const CFX_ByteStringC& szData, | 5403 void CXFA_FM2JSContext::WordUS(const CFX_ByteStringC& szData, |
5236 int32_t iStyle, | 5404 int32_t iStyle, |
5237 CFX_ByteTextBuf& strBuf) { | 5405 CFX_ByteTextBuf& strBuf) { |
5238 const FX_CHAR* pData = szData.c_str(); | 5406 const FX_CHAR* pData = szData.c_str(); |
5239 int32_t iLength = szData.GetLength(); | 5407 int32_t iLength = szData.GetLength(); |
5240 switch (iStyle) { | 5408 switch (iStyle) { |
5241 case 0: { | 5409 case 0: { |
5242 int32_t iIndex = 0; | 5410 int32_t iIndex = 0; |
5243 while (iIndex < iLength) { | 5411 while (iIndex < iLength) { |
5244 if (*(pData + iIndex) == '.') { | 5412 if (*(pData + iIndex) == '.') { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5323 strBuf << " Trillion "; | 5491 strBuf << " Trillion "; |
5324 } | 5492 } |
5325 } | 5493 } |
5326 strBuf << " Cents"; | 5494 strBuf << " Cents"; |
5327 } | 5495 } |
5328 } break; | 5496 } break; |
5329 default: | 5497 default: |
5330 break; | 5498 break; |
5331 } | 5499 } |
5332 } | 5500 } |
5501 | |
5502 // static | |
5333 void CXFA_FM2JSContext::Get(CFXJSE_Value* pThis, | 5503 void CXFA_FM2JSContext::Get(CFXJSE_Value* pThis, |
5334 const CFX_ByteStringC& szFuncName, | 5504 const CFX_ByteStringC& szFuncName, |
5335 CFXJSE_Arguments& args) { | 5505 CFXJSE_Arguments& args) { |
5336 CXFA_FM2JSContext* pContext = | 5506 CXFA_FM2JSContext* pContext = |
5337 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5507 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5338 int32_t argc = args.GetLength(); | 5508 if (args.GetLength() == 1) { |
5339 if (argc == 1) { | |
5340 CXFA_Document* pDoc = pContext->GetDocument(); | 5509 CXFA_Document* pDoc = pContext->GetDocument(); |
5341 if (!pDoc) { | 5510 if (!pDoc) { |
5342 return; | 5511 return; |
5343 } | 5512 } |
5344 IXFA_AppProvider* pAppProvider = | 5513 IXFA_AppProvider* pAppProvider = |
5345 pDoc->GetParser()->GetNotify()->GetAppProvider(); | 5514 pDoc->GetParser()->GetNotify()->GetAppProvider(); |
5346 if (!pAppProvider) { | 5515 if (!pAppProvider) { |
5347 return; | 5516 return; |
5348 } | 5517 } |
5349 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 5518 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
5350 CFX_ByteString urlString; | 5519 CFX_ByteString urlString; |
5351 ValueToUTF8String(argOne.get(), urlString); | 5520 ValueToUTF8String(argOne.get(), urlString); |
5352 IFX_FileRead* pFile = pAppProvider->DownloadURL( | 5521 IFX_FileRead* pFile = pAppProvider->DownloadURL( |
5353 CFX_WideString::FromUTF8(urlString.AsStringC())); | 5522 CFX_WideString::FromUTF8(urlString.AsStringC())); |
5354 if (pFile) { | 5523 if (pFile) { |
5355 int32_t size = pFile->GetSize(); | 5524 int32_t size = pFile->GetSize(); |
5356 uint8_t* pData = FX_Alloc(uint8_t, size); | 5525 uint8_t* pData = FX_Alloc(uint8_t, size); |
5357 pFile->ReadBlock(pData, size); | 5526 pFile->ReadBlock(pData, size); |
5358 FXJSE_Value_SetUTF8String(args.GetReturnValue(), | 5527 FXJSE_Value_SetUTF8String(args.GetReturnValue(), |
5359 CFX_ByteStringC(pData, size)); | 5528 CFX_ByteStringC(pData, size)); |
5360 FX_Free(pData); | 5529 FX_Free(pData); |
5361 pFile->Release(); | 5530 pFile->Release(); |
5362 } | 5531 } |
5363 } else { | 5532 } else { |
5364 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5533 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
5365 L"Get"); | 5534 L"Get"); |
5366 } | 5535 } |
5367 } | 5536 } |
5537 | |
5538 // static | |
5368 void CXFA_FM2JSContext::Post(CFXJSE_Value* pThis, | 5539 void CXFA_FM2JSContext::Post(CFXJSE_Value* pThis, |
5369 const CFX_ByteStringC& szFuncName, | 5540 const CFX_ByteStringC& szFuncName, |
5370 CFXJSE_Arguments& args) { | 5541 CFXJSE_Arguments& args) { |
5371 CXFA_FM2JSContext* pContext = | 5542 CXFA_FM2JSContext* pContext = |
5372 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5543 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5373 int32_t argc = args.GetLength(); | 5544 int32_t argc = args.GetLength(); |
5374 if ((argc >= 2) && (argc <= 5)) { | 5545 if ((argc >= 2) && (argc <= 5)) { |
5375 CXFA_Document* pDoc = pContext->GetDocument(); | 5546 CXFA_Document* pDoc = pContext->GetDocument(); |
5376 if (!pDoc) { | 5547 if (!pDoc) { |
5377 return; | 5548 return; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5415 FX_UTF8Encode(decodedResponse.c_str(), decodedResponse.GetLength()) | 5586 FX_UTF8Encode(decodedResponse.c_str(), decodedResponse.GetLength()) |
5416 .AsStringC()); | 5587 .AsStringC()); |
5417 } else { | 5588 } else { |
5418 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); | 5589 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); |
5419 } | 5590 } |
5420 } else { | 5591 } else { |
5421 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5592 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
5422 L"Post"); | 5593 L"Post"); |
5423 } | 5594 } |
5424 } | 5595 } |
5596 | |
5597 // static | |
5425 void CXFA_FM2JSContext::Put(CFXJSE_Value* pThis, | 5598 void CXFA_FM2JSContext::Put(CFXJSE_Value* pThis, |
5426 const CFX_ByteStringC& szFuncName, | 5599 const CFX_ByteStringC& szFuncName, |
5427 CFXJSE_Arguments& args) { | 5600 CFXJSE_Arguments& args) { |
5428 CXFA_FM2JSContext* pContext = | 5601 CXFA_FM2JSContext* pContext = |
5429 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5602 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5430 int32_t argc = args.GetLength(); | 5603 int32_t argc = args.GetLength(); |
5431 if ((argc == 2) || (argc == 3)) { | 5604 if ((argc == 2) || (argc == 3)) { |
5432 CXFA_Document* pDoc = pContext->GetDocument(); | 5605 CXFA_Document* pDoc = pContext->GetDocument(); |
5433 if (!pDoc) { | 5606 if (!pDoc) { |
5434 return; | 5607 return; |
(...skipping 21 matching lines...) Expand all Loading... | |
5456 if (bFlags) { | 5629 if (bFlags) { |
5457 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); | 5630 FXJSE_Value_SetUTF8String(args.GetReturnValue(), ""); |
5458 } else { | 5631 } else { |
5459 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); | 5632 pContext->ThrowScriptErrorMessage(XFA_IDS_SERVER_DENY); |
5460 } | 5633 } |
5461 } else { | 5634 } else { |
5462 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 5635 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
5463 L"Put"); | 5636 L"Put"); |
5464 } | 5637 } |
5465 } | 5638 } |
5639 | |
5640 // static | |
5466 void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis, | 5641 void CXFA_FM2JSContext::assign_value_operator(CFXJSE_Value* pThis, |
5467 const CFX_ByteStringC& szFuncName, | 5642 const CFX_ByteStringC& szFuncName, |
5468 CFXJSE_Arguments& args) { | 5643 CFXJSE_Arguments& args) { |
5469 CXFA_FM2JSContext* pContext = | 5644 CXFA_FM2JSContext* pContext = |
5470 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5645 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5471 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 5646 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
5472 if (args.GetLength() == 2) { | 5647 if (args.GetLength() == 2) { |
5473 std::unique_ptr<CFXJSE_Value> lValue = args.GetValue(0); | 5648 std::unique_ptr<CFXJSE_Value> lValue = args.GetValue(0); |
5474 std::unique_ptr<CFXJSE_Value> rValue = GetSimpleValue(pThis, args, 1); | 5649 std::unique_ptr<CFXJSE_Value> rValue = GetSimpleValue(pThis, args, 1); |
5475 FX_BOOL bSetStatus = TRUE; | 5650 FX_BOOL bSetStatus = TRUE; |
(...skipping 26 matching lines...) Expand all Loading... | |
5502 bSetStatus = SetObjectDefaultValue(lValue.get(), rValue.get()); | 5677 bSetStatus = SetObjectDefaultValue(lValue.get(), rValue.get()); |
5503 if (!bSetStatus) { | 5678 if (!bSetStatus) { |
5504 pContext->ThrowScriptErrorMessage(XFA_IDS_NOT_DEFAUL_VALUE); | 5679 pContext->ThrowScriptErrorMessage(XFA_IDS_NOT_DEFAUL_VALUE); |
5505 } | 5680 } |
5506 } | 5681 } |
5507 FXJSE_Value_Set(args.GetReturnValue(), rValue.get()); | 5682 FXJSE_Value_Set(args.GetReturnValue(), rValue.get()); |
5508 } else { | 5683 } else { |
5509 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5684 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
5510 } | 5685 } |
5511 } | 5686 } |
5687 | |
5688 // static | |
5512 void CXFA_FM2JSContext::logical_or_operator(CFXJSE_Value* pThis, | 5689 void CXFA_FM2JSContext::logical_or_operator(CFXJSE_Value* pThis, |
5513 const CFX_ByteStringC& szFuncName, | 5690 const CFX_ByteStringC& szFuncName, |
5514 CFXJSE_Arguments& args) { | 5691 CFXJSE_Arguments& args) { |
5515 if (args.GetLength() == 2) { | 5692 if (args.GetLength() == 2) { |
5516 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5693 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
5517 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5694 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
5518 if (FXJSE_Value_IsNull(argFirst.get()) && | 5695 if (FXJSE_Value_IsNull(argFirst.get()) && |
5519 FXJSE_Value_IsNull(argSecond.get())) { | 5696 FXJSE_Value_IsNull(argSecond.get())) { |
5520 FXJSE_Value_SetNull(args.GetReturnValue()); | 5697 FXJSE_Value_SetNull(args.GetReturnValue()); |
5521 } else { | 5698 } else { |
5522 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); | 5699 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); |
5523 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); | 5700 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); |
5524 FXJSE_Value_SetInteger(args.GetReturnValue(), (first || second) ? 1 : 0); | 5701 FXJSE_Value_SetInteger(args.GetReturnValue(), (first || second) ? 1 : 0); |
5525 } | 5702 } |
5526 } else { | 5703 } else { |
5527 CXFA_FM2JSContext* pContext = | 5704 CXFA_FM2JSContext* pContext = |
5528 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5705 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5529 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5706 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
5530 } | 5707 } |
5531 } | 5708 } |
5709 | |
5710 // static | |
5532 void CXFA_FM2JSContext::logical_and_operator(CFXJSE_Value* pThis, | 5711 void CXFA_FM2JSContext::logical_and_operator(CFXJSE_Value* pThis, |
5533 const CFX_ByteStringC& szFuncName, | 5712 const CFX_ByteStringC& szFuncName, |
5534 CFXJSE_Arguments& args) { | 5713 CFXJSE_Arguments& args) { |
5535 if (args.GetLength() == 2) { | 5714 if (args.GetLength() == 2) { |
5536 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5715 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
5537 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5716 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
5538 if (FXJSE_Value_IsNull(argFirst.get()) && | 5717 if (FXJSE_Value_IsNull(argFirst.get()) && |
5539 FXJSE_Value_IsNull(argSecond.get())) { | 5718 FXJSE_Value_IsNull(argSecond.get())) { |
5540 FXJSE_Value_SetNull(args.GetReturnValue()); | 5719 FXJSE_Value_SetNull(args.GetReturnValue()); |
5541 } else { | 5720 } else { |
5542 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); | 5721 FX_FLOAT first = ValueToFloat(pThis, argFirst.get()); |
5543 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); | 5722 FX_FLOAT second = ValueToFloat(pThis, argSecond.get()); |
5544 FXJSE_Value_SetInteger(args.GetReturnValue(), (first && second) ? 1 : 0); | 5723 FXJSE_Value_SetInteger(args.GetReturnValue(), (first && second) ? 1 : 0); |
5545 } | 5724 } |
5546 } else { | 5725 } else { |
5547 CXFA_FM2JSContext* pContext = | 5726 CXFA_FM2JSContext* pContext = |
5548 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5727 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5549 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5728 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
5550 } | 5729 } |
5551 } | 5730 } |
5731 | |
5732 // static | |
5552 void CXFA_FM2JSContext::equality_operator(CFXJSE_Value* pThis, | 5733 void CXFA_FM2JSContext::equality_operator(CFXJSE_Value* pThis, |
5553 const CFX_ByteStringC& szFuncName, | 5734 const CFX_ByteStringC& szFuncName, |
5554 CFXJSE_Arguments& args) { | 5735 CFXJSE_Arguments& args) { |
5555 if (args.GetLength() == 2) { | 5736 if (args.GetLength() == 2) { |
5556 if (fm_ref_equal(pThis, args)) { | 5737 if (fm_ref_equal(pThis, args)) { |
5557 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); | 5738 FXJSE_Value_SetInteger(args.GetReturnValue(), 1); |
5558 } else { | 5739 } else { |
5559 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5740 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
5560 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5741 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
5561 if (FXJSE_Value_IsNull(argFirst.get()) || | 5742 if (FXJSE_Value_IsNull(argFirst.get()) || |
(...skipping 17 matching lines...) Expand all Loading... | |
5579 FXJSE_Value_SetInteger(args.GetReturnValue(), | 5760 FXJSE_Value_SetInteger(args.GetReturnValue(), |
5580 (first == second) ? 1 : 0); | 5761 (first == second) ? 1 : 0); |
5581 } | 5762 } |
5582 } | 5763 } |
5583 } else { | 5764 } else { |
5584 CXFA_FM2JSContext* pContext = | 5765 CXFA_FM2JSContext* pContext = |
5585 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5766 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5586 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5767 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
5587 } | 5768 } |
5588 } | 5769 } |
5770 | |
5771 // static | |
5589 void CXFA_FM2JSContext::notequality_operator(CFXJSE_Value* pThis, | 5772 void CXFA_FM2JSContext::notequality_operator(CFXJSE_Value* pThis, |
5590 const CFX_ByteStringC& szFuncName, | 5773 const CFX_ByteStringC& szFuncName, |
5591 CFXJSE_Arguments& args) { | 5774 CFXJSE_Arguments& args) { |
5592 if (args.GetLength() == 2) { | 5775 if (args.GetLength() == 2) { |
5593 if (fm_ref_equal(pThis, args)) { | 5776 if (fm_ref_equal(pThis, args)) { |
5594 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 5777 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
5595 } else { | 5778 } else { |
5596 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5779 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
5597 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5780 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
5598 if (FXJSE_Value_IsNull(argFirst.get()) || | 5781 if (FXJSE_Value_IsNull(argFirst.get()) || |
(...skipping 16 matching lines...) Expand all Loading... | |
5615 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5798 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
5616 FXJSE_Value_SetInteger(args.GetReturnValue(), first != second); | 5799 FXJSE_Value_SetInteger(args.GetReturnValue(), first != second); |
5617 } | 5800 } |
5618 } | 5801 } |
5619 } else { | 5802 } else { |
5620 CXFA_FM2JSContext* pContext = | 5803 CXFA_FM2JSContext* pContext = |
5621 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5804 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5622 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5805 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
5623 } | 5806 } |
5624 } | 5807 } |
5808 | |
5809 // static | |
5625 FX_BOOL CXFA_FM2JSContext::fm_ref_equal(CFXJSE_Value* pThis, | 5810 FX_BOOL CXFA_FM2JSContext::fm_ref_equal(CFXJSE_Value* pThis, |
5626 CFXJSE_Arguments& args) { | 5811 CFXJSE_Arguments& args) { |
5627 FX_BOOL bRet = FALSE; | 5812 FX_BOOL bRet = FALSE; |
5628 CXFA_FM2JSContext* pContext = | 5813 CXFA_FM2JSContext* pContext = |
5629 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5814 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5630 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 5815 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
5631 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0); | 5816 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0); |
5632 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1); | 5817 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1); |
5633 if (FXJSE_Value_IsArray(argFirst.get()) && | 5818 if (FXJSE_Value_IsArray(argFirst.get()) && |
5634 FXJSE_Value_IsArray(argSecond.get())) { | 5819 FXJSE_Value_IsArray(argSecond.get())) { |
5635 std::unique_ptr<CFXJSE_Value> firstFlagValue(new CFXJSE_Value(pIsolate)); | 5820 std::unique_ptr<CFXJSE_Value> firstFlagValue(new CFXJSE_Value(pIsolate)); |
5636 std::unique_ptr<CFXJSE_Value> secondFlagValue(new CFXJSE_Value(pIsolate)); | 5821 std::unique_ptr<CFXJSE_Value> secondFlagValue(new CFXJSE_Value(pIsolate)); |
5637 FXJSE_Value_GetObjectPropByIdx(argFirst.get(), 0, firstFlagValue.get()); | 5822 FXJSE_Value_GetObjectPropByIdx(argFirst.get(), 0, firstFlagValue.get()); |
5638 FXJSE_Value_GetObjectPropByIdx(argSecond.get(), 0, secondFlagValue.get()); | 5823 FXJSE_Value_GetObjectPropByIdx(argSecond.get(), 0, secondFlagValue.get()); |
5639 if ((FXJSE_Value_ToInteger(firstFlagValue.get()) == 3) && | 5824 if ((FXJSE_Value_ToInteger(firstFlagValue.get()) == 3) && |
5640 (FXJSE_Value_ToInteger(secondFlagValue.get()) == 3)) { | 5825 (FXJSE_Value_ToInteger(secondFlagValue.get()) == 3)) { |
5641 std::unique_ptr<CFXJSE_Value> firstJSObject(new CFXJSE_Value(pIsolate)); | 5826 std::unique_ptr<CFXJSE_Value> firstJSObject(new CFXJSE_Value(pIsolate)); |
5642 std::unique_ptr<CFXJSE_Value> secondJSObject(new CFXJSE_Value(pIsolate)); | 5827 std::unique_ptr<CFXJSE_Value> secondJSObject(new CFXJSE_Value(pIsolate)); |
5643 FXJSE_Value_GetObjectPropByIdx(argFirst.get(), 2, firstJSObject.get()); | 5828 FXJSE_Value_GetObjectPropByIdx(argFirst.get(), 2, firstJSObject.get()); |
5644 FXJSE_Value_GetObjectPropByIdx(argSecond.get(), 2, secondJSObject.get()); | 5829 FXJSE_Value_GetObjectPropByIdx(argSecond.get(), 2, secondJSObject.get()); |
5645 if (!FXJSE_Value_IsNull(firstJSObject.get()) && | 5830 if (!FXJSE_Value_IsNull(firstJSObject.get()) && |
5646 !FXJSE_Value_IsNull(secondJSObject.get())) { | 5831 !FXJSE_Value_IsNull(secondJSObject.get())) { |
5647 bRet = (FXJSE_Value_ToObject(firstJSObject.get(), NULL) == | 5832 bRet = (FXJSE_Value_ToObject(firstJSObject.get(), nullptr) == |
5648 FXJSE_Value_ToObject(secondJSObject.get(), NULL)); | 5833 FXJSE_Value_ToObject(secondJSObject.get(), nullptr)); |
5649 } | 5834 } |
5650 } | 5835 } |
5651 } | 5836 } |
5652 return bRet; | 5837 return bRet; |
5653 } | 5838 } |
5839 | |
5840 // static | |
5654 void CXFA_FM2JSContext::less_operator(CFXJSE_Value* pThis, | 5841 void CXFA_FM2JSContext::less_operator(CFXJSE_Value* pThis, |
5655 const CFX_ByteStringC& szFuncName, | 5842 const CFX_ByteStringC& szFuncName, |
5656 CFXJSE_Arguments& args) { | 5843 CFXJSE_Arguments& args) { |
5657 if (args.GetLength() == 2) { | 5844 if (args.GetLength() == 2) { |
5658 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5845 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
5659 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5846 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
5660 if (FXJSE_Value_IsNull(argFirst.get()) || | 5847 if (FXJSE_Value_IsNull(argFirst.get()) || |
5661 FXJSE_Value_IsNull(argSecond.get())) { | 5848 FXJSE_Value_IsNull(argSecond.get())) { |
5662 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 5849 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
5663 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) && | 5850 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) && |
5664 FXJSE_Value_IsUTF8String(argSecond.get())) { | 5851 FXJSE_Value_IsUTF8String(argSecond.get())) { |
5665 CFX_ByteString firstOutput; | 5852 CFX_ByteString firstOutput; |
5666 CFX_ByteString secondOutput; | 5853 CFX_ByteString secondOutput; |
5667 FXJSE_Value_ToUTF8String(argFirst.get(), firstOutput); | 5854 FXJSE_Value_ToUTF8String(argFirst.get(), firstOutput); |
5668 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); | 5855 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); |
5669 FXJSE_Value_SetInteger( | 5856 FXJSE_Value_SetInteger( |
5670 args.GetReturnValue(), | 5857 args.GetReturnValue(), |
5671 firstOutput.Compare(secondOutput.AsStringC()) == -1); | 5858 firstOutput.Compare(secondOutput.AsStringC()) == -1); |
5672 } else { | 5859 } else { |
5673 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5860 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
5674 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5861 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
5675 FXJSE_Value_SetInteger(args.GetReturnValue(), (first < second) ? 1 : 0); | 5862 FXJSE_Value_SetInteger(args.GetReturnValue(), (first < second) ? 1 : 0); |
5676 } | 5863 } |
5677 } else { | 5864 } else { |
5678 CXFA_FM2JSContext* pContext = | 5865 CXFA_FM2JSContext* pContext = |
5679 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5866 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5680 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5867 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
5681 } | 5868 } |
5682 } | 5869 } |
5870 | |
5871 // static | |
5683 void CXFA_FM2JSContext::lessequal_operator(CFXJSE_Value* pThis, | 5872 void CXFA_FM2JSContext::lessequal_operator(CFXJSE_Value* pThis, |
5684 const CFX_ByteStringC& szFuncName, | 5873 const CFX_ByteStringC& szFuncName, |
5685 CFXJSE_Arguments& args) { | 5874 CFXJSE_Arguments& args) { |
5686 if (args.GetLength() == 2) { | 5875 if (args.GetLength() == 2) { |
5687 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5876 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
5688 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5877 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
5689 if (FXJSE_Value_IsNull(argFirst.get()) || | 5878 if (FXJSE_Value_IsNull(argFirst.get()) || |
5690 FXJSE_Value_IsNull(argSecond.get())) { | 5879 FXJSE_Value_IsNull(argSecond.get())) { |
5691 FXJSE_Value_SetInteger(args.GetReturnValue(), | 5880 FXJSE_Value_SetInteger(args.GetReturnValue(), |
5692 (FXJSE_Value_IsNull(argFirst.get()) && | 5881 (FXJSE_Value_IsNull(argFirst.get()) && |
(...skipping 13 matching lines...) Expand all Loading... | |
5706 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5895 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
5707 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5896 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
5708 FXJSE_Value_SetInteger(args.GetReturnValue(), (first <= second) ? 1 : 0); | 5897 FXJSE_Value_SetInteger(args.GetReturnValue(), (first <= second) ? 1 : 0); |
5709 } | 5898 } |
5710 } else { | 5899 } else { |
5711 CXFA_FM2JSContext* pContext = | 5900 CXFA_FM2JSContext* pContext = |
5712 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5901 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5713 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5902 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
5714 } | 5903 } |
5715 } | 5904 } |
5905 | |
5906 // static | |
5716 void CXFA_FM2JSContext::greater_operator(CFXJSE_Value* pThis, | 5907 void CXFA_FM2JSContext::greater_operator(CFXJSE_Value* pThis, |
5717 const CFX_ByteStringC& szFuncName, | 5908 const CFX_ByteStringC& szFuncName, |
5718 CFXJSE_Arguments& args) { | 5909 CFXJSE_Arguments& args) { |
5719 if (args.GetLength() == 2) { | 5910 if (args.GetLength() == 2) { |
5720 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5911 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
5721 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5912 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
5722 if (FXJSE_Value_IsNull(argFirst.get()) || | 5913 if (FXJSE_Value_IsNull(argFirst.get()) || |
5723 FXJSE_Value_IsNull(argSecond.get())) { | 5914 FXJSE_Value_IsNull(argSecond.get())) { |
5724 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); | 5915 FXJSE_Value_SetInteger(args.GetReturnValue(), 0); |
5725 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) && | 5916 } else if (FXJSE_Value_IsUTF8String(argFirst.get()) && |
5726 FXJSE_Value_IsUTF8String(argSecond.get())) { | 5917 FXJSE_Value_IsUTF8String(argSecond.get())) { |
5727 CFX_ByteString firstOutput; | 5918 CFX_ByteString firstOutput; |
5728 CFX_ByteString secondOutput; | 5919 CFX_ByteString secondOutput; |
5729 FXJSE_Value_ToUTF8String(argFirst.get(), firstOutput); | 5920 FXJSE_Value_ToUTF8String(argFirst.get(), firstOutput); |
5730 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); | 5921 FXJSE_Value_ToUTF8String(argSecond.get(), secondOutput); |
5731 FXJSE_Value_SetInteger( | 5922 FXJSE_Value_SetInteger( |
5732 args.GetReturnValue(), | 5923 args.GetReturnValue(), |
5733 firstOutput.Compare(secondOutput.AsStringC()) == 1); | 5924 firstOutput.Compare(secondOutput.AsStringC()) == 1); |
5734 } else { | 5925 } else { |
5735 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5926 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
5736 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5927 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
5737 FXJSE_Value_SetInteger(args.GetReturnValue(), (first > second) ? 1 : 0); | 5928 FXJSE_Value_SetInteger(args.GetReturnValue(), (first > second) ? 1 : 0); |
5738 } | 5929 } |
5739 } else { | 5930 } else { |
5740 CXFA_FM2JSContext* pContext = | 5931 CXFA_FM2JSContext* pContext = |
5741 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5932 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5742 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5933 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
5743 } | 5934 } |
5744 } | 5935 } |
5936 | |
5937 // static | |
5745 void CXFA_FM2JSContext::greaterequal_operator(CFXJSE_Value* pThis, | 5938 void CXFA_FM2JSContext::greaterequal_operator(CFXJSE_Value* pThis, |
5746 const CFX_ByteStringC& szFuncName, | 5939 const CFX_ByteStringC& szFuncName, |
5747 CFXJSE_Arguments& args) { | 5940 CFXJSE_Arguments& args) { |
5748 if (args.GetLength() == 2) { | 5941 if (args.GetLength() == 2) { |
5749 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5942 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
5750 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 5943 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
5751 if (FXJSE_Value_IsNull(argFirst.get()) || | 5944 if (FXJSE_Value_IsNull(argFirst.get()) || |
5752 FXJSE_Value_IsNull(argSecond.get())) { | 5945 FXJSE_Value_IsNull(argSecond.get())) { |
5753 FXJSE_Value_SetInteger(args.GetReturnValue(), | 5946 FXJSE_Value_SetInteger(args.GetReturnValue(), |
5754 (FXJSE_Value_IsNull(argFirst.get()) && | 5947 (FXJSE_Value_IsNull(argFirst.get()) && |
(...skipping 13 matching lines...) Expand all Loading... | |
5768 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5961 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
5769 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5962 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
5770 FXJSE_Value_SetInteger(args.GetReturnValue(), (first >= second) ? 1 : 0); | 5963 FXJSE_Value_SetInteger(args.GetReturnValue(), (first >= second) ? 1 : 0); |
5771 } | 5964 } |
5772 } else { | 5965 } else { |
5773 CXFA_FM2JSContext* pContext = | 5966 CXFA_FM2JSContext* pContext = |
5774 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5967 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5775 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5968 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
5776 } | 5969 } |
5777 } | 5970 } |
5971 | |
5972 // static | |
5778 void CXFA_FM2JSContext::plus_operator(CFXJSE_Value* pThis, | 5973 void CXFA_FM2JSContext::plus_operator(CFXJSE_Value* pThis, |
5779 const CFX_ByteStringC& szFuncName, | 5974 const CFX_ByteStringC& szFuncName, |
5780 CFXJSE_Arguments& args) { | 5975 CFXJSE_Arguments& args) { |
5781 if (args.GetLength() == 2) { | 5976 if (args.GetLength() == 2) { |
5782 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0); | 5977 std::unique_ptr<CFXJSE_Value> argFirst = args.GetValue(0); |
5783 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1); | 5978 std::unique_ptr<CFXJSE_Value> argSecond = args.GetValue(1); |
5784 if (ValueIsNull(pThis, argFirst.get()) && | 5979 if (ValueIsNull(pThis, argFirst.get()) && |
5785 ValueIsNull(pThis, argSecond.get())) { | 5980 ValueIsNull(pThis, argSecond.get())) { |
5786 FXJSE_Value_SetNull(args.GetReturnValue()); | 5981 FXJSE_Value_SetNull(args.GetReturnValue()); |
5787 } else { | 5982 } else { |
5788 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 5983 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
5789 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 5984 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
5790 FXJSE_Value_SetDouble(args.GetReturnValue(), first + second); | 5985 FXJSE_Value_SetDouble(args.GetReturnValue(), first + second); |
5791 } | 5986 } |
5792 } else { | 5987 } else { |
5793 CXFA_FM2JSContext* pContext = | 5988 CXFA_FM2JSContext* pContext = |
5794 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 5989 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5795 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 5990 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
5796 } | 5991 } |
5797 } | 5992 } |
5993 | |
5994 // static | |
5798 void CXFA_FM2JSContext::minus_operator(CFXJSE_Value* pThis, | 5995 void CXFA_FM2JSContext::minus_operator(CFXJSE_Value* pThis, |
5799 const CFX_ByteStringC& szFuncName, | 5996 const CFX_ByteStringC& szFuncName, |
5800 CFXJSE_Arguments& args) { | 5997 CFXJSE_Arguments& args) { |
5801 if (args.GetLength() == 2) { | 5998 if (args.GetLength() == 2) { |
5802 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 5999 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
5803 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 6000 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
5804 if (FXJSE_Value_IsNull(argFirst.get()) && | 6001 if (FXJSE_Value_IsNull(argFirst.get()) && |
5805 FXJSE_Value_IsNull(argSecond.get())) { | 6002 FXJSE_Value_IsNull(argSecond.get())) { |
5806 FXJSE_Value_SetNull(args.GetReturnValue()); | 6003 FXJSE_Value_SetNull(args.GetReturnValue()); |
5807 } else { | 6004 } else { |
5808 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 6005 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
5809 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 6006 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
5810 FXJSE_Value_SetDouble(args.GetReturnValue(), first - second); | 6007 FXJSE_Value_SetDouble(args.GetReturnValue(), first - second); |
5811 } | 6008 } |
5812 } else { | 6009 } else { |
5813 CXFA_FM2JSContext* pContext = | 6010 CXFA_FM2JSContext* pContext = |
5814 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6011 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5815 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6012 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
5816 } | 6013 } |
5817 } | 6014 } |
6015 | |
6016 // static | |
5818 void CXFA_FM2JSContext::multiple_operator(CFXJSE_Value* pThis, | 6017 void CXFA_FM2JSContext::multiple_operator(CFXJSE_Value* pThis, |
5819 const CFX_ByteStringC& szFuncName, | 6018 const CFX_ByteStringC& szFuncName, |
5820 CFXJSE_Arguments& args) { | 6019 CFXJSE_Arguments& args) { |
5821 if (args.GetLength() == 2) { | 6020 if (args.GetLength() == 2) { |
5822 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 6021 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
5823 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 6022 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
5824 if (FXJSE_Value_IsNull(argFirst.get()) && | 6023 if (FXJSE_Value_IsNull(argFirst.get()) && |
5825 FXJSE_Value_IsNull(argSecond.get())) { | 6024 FXJSE_Value_IsNull(argSecond.get())) { |
5826 FXJSE_Value_SetNull(args.GetReturnValue()); | 6025 FXJSE_Value_SetNull(args.GetReturnValue()); |
5827 } else { | 6026 } else { |
5828 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 6027 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
5829 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 6028 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
5830 FXJSE_Value_SetDouble(args.GetReturnValue(), first * second); | 6029 FXJSE_Value_SetDouble(args.GetReturnValue(), first * second); |
5831 } | 6030 } |
5832 } else { | 6031 } else { |
5833 CXFA_FM2JSContext* pContext = | 6032 CXFA_FM2JSContext* pContext = |
5834 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6033 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5835 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6034 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
5836 } | 6035 } |
5837 } | 6036 } |
6037 | |
6038 // static | |
5838 void CXFA_FM2JSContext::divide_operator(CFXJSE_Value* pThis, | 6039 void CXFA_FM2JSContext::divide_operator(CFXJSE_Value* pThis, |
5839 const CFX_ByteStringC& szFuncName, | 6040 const CFX_ByteStringC& szFuncName, |
5840 CFXJSE_Arguments& args) { | 6041 CFXJSE_Arguments& args) { |
5841 CXFA_FM2JSContext* pContext = | 6042 CXFA_FM2JSContext* pContext = |
5842 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6043 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5843 if (args.GetLength() == 2) { | 6044 if (args.GetLength() == 2) { |
5844 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); | 6045 std::unique_ptr<CFXJSE_Value> argFirst = GetSimpleValue(pThis, args, 0); |
5845 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); | 6046 std::unique_ptr<CFXJSE_Value> argSecond = GetSimpleValue(pThis, args, 1); |
5846 if (FXJSE_Value_IsNull(argFirst.get()) && | 6047 if (FXJSE_Value_IsNull(argFirst.get()) && |
5847 FXJSE_Value_IsNull(argSecond.get())) { | 6048 FXJSE_Value_IsNull(argSecond.get())) { |
5848 FXJSE_Value_SetNull(args.GetReturnValue()); | 6049 FXJSE_Value_SetNull(args.GetReturnValue()); |
5849 } else { | 6050 } else { |
5850 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); | 6051 FX_DOUBLE first = ValueToDouble(pThis, argFirst.get()); |
5851 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); | 6052 FX_DOUBLE second = ValueToDouble(pThis, argSecond.get()); |
5852 if (second == 0.0) { | 6053 if (second == 0.0) { |
5853 pContext->ThrowScriptErrorMessage(XFA_IDS_DIVIDE_ZERO); | 6054 pContext->ThrowScriptErrorMessage(XFA_IDS_DIVIDE_ZERO); |
5854 } else { | 6055 } else { |
5855 FXJSE_Value_SetDouble(args.GetReturnValue(), first / second); | 6056 FXJSE_Value_SetDouble(args.GetReturnValue(), first / second); |
5856 } | 6057 } |
5857 } | 6058 } |
5858 } else { | 6059 } else { |
5859 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6060 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
5860 } | 6061 } |
5861 } | 6062 } |
6063 | |
6064 // static | |
5862 void CXFA_FM2JSContext::positive_operator(CFXJSE_Value* pThis, | 6065 void CXFA_FM2JSContext::positive_operator(CFXJSE_Value* pThis, |
5863 const CFX_ByteStringC& szFuncName, | 6066 const CFX_ByteStringC& szFuncName, |
5864 CFXJSE_Arguments& args) { | 6067 CFXJSE_Arguments& args) { |
5865 int32_t iLength = args.GetLength(); | 6068 if (args.GetLength() == 1) { |
5866 if (iLength == 1) { | |
5867 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 6069 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
5868 if (FXJSE_Value_IsNull(argOne.get())) { | 6070 if (FXJSE_Value_IsNull(argOne.get())) { |
5869 FXJSE_Value_SetNull(args.GetReturnValue()); | 6071 FXJSE_Value_SetNull(args.GetReturnValue()); |
5870 } else { | 6072 } else { |
5871 FXJSE_Value_SetDouble(args.GetReturnValue(), | 6073 FXJSE_Value_SetDouble(args.GetReturnValue(), |
5872 0.0 + ValueToDouble(pThis, argOne.get())); | 6074 0.0 + ValueToDouble(pThis, argOne.get())); |
5873 } | 6075 } |
5874 } else { | 6076 } else { |
5875 CXFA_FM2JSContext* pContext = | 6077 CXFA_FM2JSContext* pContext = |
5876 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6078 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5877 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6079 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
5878 } | 6080 } |
5879 } | 6081 } |
6082 | |
6083 // static | |
5880 void CXFA_FM2JSContext::negative_operator(CFXJSE_Value* pThis, | 6084 void CXFA_FM2JSContext::negative_operator(CFXJSE_Value* pThis, |
5881 const CFX_ByteStringC& szFuncName, | 6085 const CFX_ByteStringC& szFuncName, |
5882 CFXJSE_Arguments& args) { | 6086 CFXJSE_Arguments& args) { |
5883 int32_t iLength = args.GetLength(); | 6087 if (args.GetLength() == 1) { |
5884 if (iLength == 1) { | |
5885 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 6088 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
5886 if (FXJSE_Value_IsNull(argOne.get())) { | 6089 if (FXJSE_Value_IsNull(argOne.get())) { |
5887 FXJSE_Value_SetNull(args.GetReturnValue()); | 6090 FXJSE_Value_SetNull(args.GetReturnValue()); |
5888 } else { | 6091 } else { |
5889 FXJSE_Value_SetDouble(args.GetReturnValue(), | 6092 FXJSE_Value_SetDouble(args.GetReturnValue(), |
5890 0.0 - ValueToDouble(pThis, argOne.get())); | 6093 0.0 - ValueToDouble(pThis, argOne.get())); |
5891 } | 6094 } |
5892 } else { | 6095 } else { |
5893 CXFA_FM2JSContext* pContext = | 6096 CXFA_FM2JSContext* pContext = |
5894 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6097 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5895 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6098 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
5896 } | 6099 } |
5897 } | 6100 } |
6101 | |
6102 // static | |
5898 void CXFA_FM2JSContext::logical_not_operator(CFXJSE_Value* pThis, | 6103 void CXFA_FM2JSContext::logical_not_operator(CFXJSE_Value* pThis, |
5899 const CFX_ByteStringC& szFuncName, | 6104 const CFX_ByteStringC& szFuncName, |
5900 CFXJSE_Arguments& args) { | 6105 CFXJSE_Arguments& args) { |
5901 int32_t iLength = args.GetLength(); | 6106 if (args.GetLength() == 1) { |
5902 if (iLength == 1) { | |
5903 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 6107 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
5904 if (FXJSE_Value_IsNull(argOne.get())) { | 6108 if (FXJSE_Value_IsNull(argOne.get())) { |
5905 FXJSE_Value_SetNull(args.GetReturnValue()); | 6109 FXJSE_Value_SetNull(args.GetReturnValue()); |
5906 } else { | 6110 } else { |
5907 FX_DOUBLE first = ValueToDouble(pThis, argOne.get()); | 6111 FX_DOUBLE first = ValueToDouble(pThis, argOne.get()); |
5908 FXJSE_Value_SetInteger(args.GetReturnValue(), (first == 0.0) ? 1 : 0); | 6112 FXJSE_Value_SetInteger(args.GetReturnValue(), (first == 0.0) ? 1 : 0); |
5909 } | 6113 } |
5910 } else { | 6114 } else { |
5911 CXFA_FM2JSContext* pContext = | 6115 CXFA_FM2JSContext* pContext = |
5912 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6116 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5913 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6117 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
5914 } | 6118 } |
5915 } | 6119 } |
6120 | |
6121 // static | |
5916 void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis, | 6122 void CXFA_FM2JSContext::dot_accessor(CFXJSE_Value* pThis, |
5917 const CFX_ByteStringC& szFuncName, | 6123 const CFX_ByteStringC& szFuncName, |
5918 CFXJSE_Arguments& args) { | 6124 CFXJSE_Arguments& args) { |
5919 CXFA_FM2JSContext* pContext = | 6125 CXFA_FM2JSContext* pContext = |
5920 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6126 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
5921 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6127 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
5922 int32_t argc = args.GetLength(); | 6128 int32_t argc = args.GetLength(); |
5923 if ((argc == 4) || (argc == 5)) { | 6129 if ((argc == 4) || (argc == 5)) { |
5924 FX_BOOL bIsStar = TRUE; | 6130 FX_BOOL bIsStar = TRUE; |
5925 std::unique_ptr<CFXJSE_Value> argAccessor = args.GetValue(0); | 6131 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()); | 6259 CFX_WideString::FromUTF8(szSomExp.AsStringC()); |
6054 pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, | 6260 pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, |
6055 wsPropertyName.c_str(), | 6261 wsPropertyName.c_str(), |
6056 wsSomExpression.c_str()); | 6262 wsSomExpression.c_str()); |
6057 } | 6263 } |
6058 } | 6264 } |
6059 } else { | 6265 } else { |
6060 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6266 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
6061 } | 6267 } |
6062 } | 6268 } |
6269 | |
6270 // static | |
6063 void CXFA_FM2JSContext::dotdot_accessor(CFXJSE_Value* pThis, | 6271 void CXFA_FM2JSContext::dotdot_accessor(CFXJSE_Value* pThis, |
6064 const CFX_ByteStringC& szFuncName, | 6272 const CFX_ByteStringC& szFuncName, |
6065 CFXJSE_Arguments& args) { | 6273 CFXJSE_Arguments& args) { |
6066 CXFA_FM2JSContext* pContext = | 6274 CXFA_FM2JSContext* pContext = |
6067 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6275 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
6068 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6276 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
6069 int32_t argc = args.GetLength(); | 6277 int32_t argc = args.GetLength(); |
6070 if ((argc == 4) || (argc == 5)) { | 6278 if ((argc == 4) || (argc == 5)) { |
6071 FX_BOOL bIsStar = TRUE; | 6279 FX_BOOL bIsStar = TRUE; |
6072 std::unique_ptr<CFXJSE_Value> argAccessor = args.GetValue(0); | 6280 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()); | 6403 CFX_WideString::FromUTF8(szSomExp.AsStringC()); |
6196 pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, | 6404 pContext->ThrowScriptErrorMessage(XFA_IDS_ACCESS_PROPERTY_IN_NOT_OBJECT, |
6197 wsPropertyName.c_str(), | 6405 wsPropertyName.c_str(), |
6198 wsSomExpression.c_str()); | 6406 wsSomExpression.c_str()); |
6199 } | 6407 } |
6200 } | 6408 } |
6201 } else { | 6409 } else { |
6202 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6410 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
6203 } | 6411 } |
6204 } | 6412 } |
6413 | |
6414 // static | |
6205 void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis, | 6415 void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis, |
6206 const CFX_ByteStringC& szFuncName, | 6416 const CFX_ByteStringC& szFuncName, |
6207 CFXJSE_Arguments& args) { | 6417 CFXJSE_Arguments& args) { |
6208 CXFA_FM2JSContext* pContext = | 6418 CXFA_FM2JSContext* pContext = |
6209 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6419 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
6210 int32_t argc = args.GetLength(); | 6420 if (args.GetLength() == 1) { |
6211 if (argc == 1) { | |
6212 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 6421 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
6213 CFX_ByteString argString; | 6422 CFX_ByteString argString; |
6214 ValueToUTF8String(argOne.get(), argString); | 6423 ValueToUTF8String(argOne.get(), argString); |
6215 if (argString.IsEmpty()) { | 6424 if (argString.IsEmpty()) { |
6216 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 6425 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
6217 } else { | 6426 } else { |
6218 CFX_WideString scriptString = | 6427 CFX_WideString scriptString = |
6219 CFX_WideString::FromUTF8(argString.AsStringC()); | 6428 CFX_WideString::FromUTF8(argString.AsStringC()); |
6220 CFX_WideTextBuf wsJavaScriptBuf; | 6429 CFX_WideTextBuf wsJavaScriptBuf; |
6221 CFX_WideString wsError; | 6430 CFX_WideString wsError; |
6222 XFA_FM2JS_Translate(scriptString.AsStringC(), wsJavaScriptBuf, wsError); | 6431 XFA_FM2JS_Translate(scriptString.AsStringC(), wsJavaScriptBuf, wsError); |
6223 if (wsError.IsEmpty()) { | 6432 if (wsError.IsEmpty()) { |
6224 CFX_WideString javaScript = wsJavaScriptBuf.MakeString(); | 6433 CFX_WideString javaScript = wsJavaScriptBuf.MakeString(); |
6225 FXJSE_Value_SetUTF8String( | 6434 FXJSE_Value_SetUTF8String( |
6226 args.GetReturnValue(), | 6435 args.GetReturnValue(), |
6227 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()) | 6436 FX_UTF8Encode(javaScript.c_str(), javaScript.GetLength()) |
6228 .AsStringC()); | 6437 .AsStringC()); |
6229 } else { | 6438 } else { |
6230 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6439 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
6231 } | 6440 } |
6232 } | 6441 } |
6233 } else { | 6442 } else { |
6234 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 6443 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
6235 L"Eval"); | 6444 L"Eval"); |
6236 } | 6445 } |
6237 } | 6446 } |
6447 | |
6448 // static | |
6238 void CXFA_FM2JSContext::is_fm_object(CFXJSE_Value* pThis, | 6449 void CXFA_FM2JSContext::is_fm_object(CFXJSE_Value* pThis, |
6239 const CFX_ByteStringC& szFuncName, | 6450 const CFX_ByteStringC& szFuncName, |
6240 CFXJSE_Arguments& args) { | 6451 CFXJSE_Arguments& args) { |
6241 int32_t iLength = args.GetLength(); | 6452 if (args.GetLength() == 1) { |
6242 if (iLength == 1) { | |
6243 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 6453 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
6244 FXJSE_Value_SetBoolean(args.GetReturnValue(), | 6454 FXJSE_Value_SetBoolean(args.GetReturnValue(), |
6245 FXJSE_Value_IsObject(argOne.get())); | 6455 FXJSE_Value_IsObject(argOne.get())); |
6246 } else { | 6456 } else { |
6247 FXJSE_Value_SetBoolean(args.GetReturnValue(), FALSE); | 6457 FXJSE_Value_SetBoolean(args.GetReturnValue(), FALSE); |
6248 } | 6458 } |
6249 } | 6459 } |
6460 | |
6461 // static | |
6250 void CXFA_FM2JSContext::is_fm_array(CFXJSE_Value* pThis, | 6462 void CXFA_FM2JSContext::is_fm_array(CFXJSE_Value* pThis, |
6251 const CFX_ByteStringC& szFuncName, | 6463 const CFX_ByteStringC& szFuncName, |
6252 CFXJSE_Arguments& args) { | 6464 CFXJSE_Arguments& args) { |
6253 int32_t iLength = args.GetLength(); | 6465 if (args.GetLength() == 1) { |
6254 if (iLength == 1) { | |
6255 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 6466 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
6256 FX_BOOL bIsArray = FXJSE_Value_IsArray(argOne.get()); | 6467 FX_BOOL bIsArray = FXJSE_Value_IsArray(argOne.get()); |
6257 FXJSE_Value_SetBoolean(args.GetReturnValue(), bIsArray); | 6468 FXJSE_Value_SetBoolean(args.GetReturnValue(), bIsArray); |
6258 } else { | 6469 } else { |
6259 FXJSE_Value_SetBoolean(args.GetReturnValue(), FALSE); | 6470 FXJSE_Value_SetBoolean(args.GetReturnValue(), FALSE); |
6260 } | 6471 } |
6261 } | 6472 } |
6473 | |
6474 // static | |
6262 void CXFA_FM2JSContext::get_fm_value(CFXJSE_Value* pThis, | 6475 void CXFA_FM2JSContext::get_fm_value(CFXJSE_Value* pThis, |
6263 const CFX_ByteStringC& szFuncName, | 6476 const CFX_ByteStringC& szFuncName, |
6264 CFXJSE_Arguments& args) { | 6477 CFXJSE_Arguments& args) { |
6265 CXFA_FM2JSContext* pContext = | 6478 CXFA_FM2JSContext* pContext = |
6266 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6479 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
6267 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6480 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
6268 int32_t iLength = args.GetLength(); | 6481 if (args.GetLength() == 1) { |
6269 if (iLength == 1) { | |
6270 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 6482 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
6271 if (FXJSE_Value_IsArray(argOne.get())) { | 6483 if (FXJSE_Value_IsArray(argOne.get())) { |
6272 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 6484 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
6273 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 6485 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
6274 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 1, propertyValue.get()); | 6486 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 1, propertyValue.get()); |
6275 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, jsObjectValue.get()); | 6487 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, jsObjectValue.get()); |
6276 if (FXJSE_Value_IsNull(propertyValue.get())) { | 6488 if (FXJSE_Value_IsNull(propertyValue.get())) { |
6277 GetObjectDefaultValue(jsObjectValue.get(), args.GetReturnValue()); | 6489 GetObjectDefaultValue(jsObjectValue.get(), args.GetReturnValue()); |
6278 } else { | 6490 } else { |
6279 CFX_ByteString propertyStr; | 6491 CFX_ByteString propertyStr; |
6280 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); | 6492 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); |
6281 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), | 6493 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), |
6282 args.GetReturnValue()); | 6494 args.GetReturnValue()); |
6283 } | 6495 } |
6284 } else if (FXJSE_Value_IsObject(argOne.get())) { | 6496 } else if (FXJSE_Value_IsObject(argOne.get())) { |
6285 GetObjectDefaultValue(argOne.get(), args.GetReturnValue()); | 6497 GetObjectDefaultValue(argOne.get(), args.GetReturnValue()); |
6286 } else { | 6498 } else { |
6287 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); | 6499 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); |
6288 } | 6500 } |
6289 } else { | 6501 } else { |
6290 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6502 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
6291 } | 6503 } |
6292 } | 6504 } |
6505 | |
6506 // static | |
6293 void CXFA_FM2JSContext::get_fm_jsobj(CFXJSE_Value* pThis, | 6507 void CXFA_FM2JSContext::get_fm_jsobj(CFXJSE_Value* pThis, |
6294 const CFX_ByteStringC& szFuncName, | 6508 const CFX_ByteStringC& szFuncName, |
6295 CFXJSE_Arguments& args) { | 6509 CFXJSE_Arguments& args) { |
6296 CXFA_FM2JSContext* pContext = | 6510 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); | 6511 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
6301 if (FXJSE_Value_IsArray(argOne.get())) { | 6512 if (FXJSE_Value_IsArray(argOne.get())) { |
6302 #ifndef NDEBUG | 6513 #ifndef NDEBUG |
6514 CXFA_FM2JSContext* pContext = | |
dsinclair
2016/05/30 21:10:51
I duplicated this because it will be compiled out
| |
6515 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); | |
6303 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6516 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
6304 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 6517 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
6305 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get()); | 6518 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get()); |
6306 ASSERT(FXJSE_Value_ToInteger(lengthValue.get()) >= 3); | 6519 ASSERT(FXJSE_Value_ToInteger(lengthValue.get()) >= 3); |
6307 #endif | 6520 #endif |
6308 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, args.GetReturnValue()); | 6521 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 2, args.GetReturnValue()); |
6309 } else { | 6522 } else { |
6310 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); | 6523 FXJSE_Value_Set(args.GetReturnValue(), argOne.get()); |
6311 } | 6524 } |
6312 } else { | 6525 } else { |
6526 CXFA_FM2JSContext* pContext = | |
6527 static_cast<CXFA_FM2JSContext*>(FXJSE_Value_ToObject(pThis, nullptr)); | |
6313 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6528 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
6314 } | 6529 } |
6315 } | 6530 } |
6531 | |
6532 // static | |
6316 void CXFA_FM2JSContext::fm_var_filter(CFXJSE_Value* pThis, | 6533 void CXFA_FM2JSContext::fm_var_filter(CFXJSE_Value* pThis, |
6317 const CFX_ByteStringC& szFuncName, | 6534 const CFX_ByteStringC& szFuncName, |
6318 CFXJSE_Arguments& args) { | 6535 CFXJSE_Arguments& args) { |
6319 CXFA_FM2JSContext* pContext = | 6536 CXFA_FM2JSContext* pContext = |
6320 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6537 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
6321 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6538 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
6322 int32_t argc = args.GetLength(); | 6539 if (args.GetLength() == 1) { |
6323 if (argc == 1) { | |
6324 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | 6540 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
6325 if (FXJSE_Value_IsArray(argOne.get())) { | 6541 if (FXJSE_Value_IsArray(argOne.get())) { |
6326 #ifndef NDEBUG | 6542 #ifndef NDEBUG |
6327 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 6543 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
6328 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get()); | 6544 FXJSE_Value_GetObjectProp(argOne.get(), "length", lengthValue.get()); |
6329 ASSERT(FXJSE_Value_ToInteger(lengthValue.get()) >= 3); | 6545 ASSERT(FXJSE_Value_ToInteger(lengthValue.get()) >= 3); |
6330 #endif | 6546 #endif |
6331 std::unique_ptr<CFXJSE_Value> flagsValue(new CFXJSE_Value(pIsolate)); | 6547 std::unique_ptr<CFXJSE_Value> flagsValue(new CFXJSE_Value(pIsolate)); |
6332 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 0, flagsValue.get()); | 6548 FXJSE_Value_GetObjectPropByIdx(argOne.get(), 0, flagsValue.get()); |
6333 int32_t iFlags = FXJSE_Value_ToInteger(flagsValue.get()); | 6549 int32_t iFlags = FXJSE_Value_ToInteger(flagsValue.get()); |
(...skipping 23 matching lines...) Expand all Loading... | |
6357 } | 6573 } |
6358 } else { | 6574 } else { |
6359 std::unique_ptr<CFXJSE_Value> simpleValue = | 6575 std::unique_ptr<CFXJSE_Value> simpleValue = |
6360 GetSimpleValue(pThis, args, 0); | 6576 GetSimpleValue(pThis, args, 0); |
6361 FXJSE_Value_Set(args.GetReturnValue(), simpleValue.get()); | 6577 FXJSE_Value_Set(args.GetReturnValue(), simpleValue.get()); |
6362 } | 6578 } |
6363 } else { | 6579 } else { |
6364 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); | 6580 pContext->ThrowScriptErrorMessage(XFA_IDS_COMPILER_ERROR); |
6365 } | 6581 } |
6366 } | 6582 } |
6583 | |
6584 // static | |
6367 void CXFA_FM2JSContext::concat_fm_object(CFXJSE_Value* pThis, | 6585 void CXFA_FM2JSContext::concat_fm_object(CFXJSE_Value* pThis, |
6368 const CFX_ByteStringC& szFuncName, | 6586 const CFX_ByteStringC& szFuncName, |
6369 CFXJSE_Arguments& args) { | 6587 CFXJSE_Arguments& args) { |
6370 CXFA_FM2JSContext* pContext = | 6588 CXFA_FM2JSContext* pContext = |
6371 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6589 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
6372 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6590 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
6373 uint32_t iLength = 0; | 6591 uint32_t iLength = 0; |
6374 int32_t argCount = args.GetLength(); | 6592 int32_t argc = args.GetLength(); |
6375 std::vector<std::unique_ptr<CFXJSE_Value>> argValues; | 6593 std::vector<std::unique_ptr<CFXJSE_Value>> argValues; |
6376 for (int32_t i = 0; i < argCount; i++) { | 6594 for (int32_t i = 0; i < argc; i++) { |
6377 argValues.push_back(args.GetValue(i)); | 6595 argValues.push_back(args.GetValue(i)); |
6378 if (FXJSE_Value_IsArray(argValues[i].get())) { | 6596 if (FXJSE_Value_IsArray(argValues[i].get())) { |
6379 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 6597 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
6380 FXJSE_Value_GetObjectProp(argValues[i].get(), "length", | 6598 FXJSE_Value_GetObjectProp(argValues[i].get(), "length", |
6381 lengthValue.get()); | 6599 lengthValue.get()); |
6382 int32_t length = FXJSE_Value_ToInteger(lengthValue.get()); | 6600 int32_t length = FXJSE_Value_ToInteger(lengthValue.get()); |
6383 iLength = iLength + ((length > 2) ? (length - 2) : 0); | 6601 iLength = iLength + ((length > 2) ? (length - 2) : 0); |
6384 } | 6602 } |
6385 iLength += 1; | 6603 iLength += 1; |
6386 } | 6604 } |
6387 CFXJSE_Value** returnValues = FX_Alloc(CFXJSE_Value*, iLength); | 6605 CFXJSE_Value** returnValues = FX_Alloc(CFXJSE_Value*, iLength); |
6388 for (int32_t i = 0; i < (int32_t)iLength; i++) | 6606 for (int32_t i = 0; i < (int32_t)iLength; i++) |
6389 returnValues[i] = new CFXJSE_Value(pIsolate); | 6607 returnValues[i] = new CFXJSE_Value(pIsolate); |
6390 | 6608 |
6391 int32_t index = 0; | 6609 int32_t index = 0; |
6392 for (int32_t i = 0; i < argCount; i++) { | 6610 for (int32_t i = 0; i < argc; i++) { |
6393 if (FXJSE_Value_IsArray(argValues[i].get())) { | 6611 if (FXJSE_Value_IsArray(argValues[i].get())) { |
6394 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 6612 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
6395 FXJSE_Value_GetObjectProp(argValues[i].get(), "length", | 6613 FXJSE_Value_GetObjectProp(argValues[i].get(), "length", |
6396 lengthValue.get()); | 6614 lengthValue.get()); |
6397 int32_t length = FXJSE_Value_ToInteger(lengthValue.get()); | 6615 int32_t length = FXJSE_Value_ToInteger(lengthValue.get()); |
6398 for (int32_t j = 2; j < length; j++) { | 6616 for (int32_t j = 2; j < length; j++) { |
6399 FXJSE_Value_GetObjectPropByIdx(argValues[i].get(), j, | 6617 FXJSE_Value_GetObjectPropByIdx(argValues[i].get(), j, |
6400 returnValues[index]); | 6618 returnValues[index]); |
6401 index++; | 6619 index++; |
6402 } | 6620 } |
6403 } | 6621 } |
6404 FXJSE_Value_Set(returnValues[index], argValues[i].get()); | 6622 FXJSE_Value_Set(returnValues[index], argValues[i].get()); |
6405 index++; | 6623 index++; |
6406 } | 6624 } |
6407 FXJSE_Value_SetArray(args.GetReturnValue(), iLength, returnValues); | 6625 FXJSE_Value_SetArray(args.GetReturnValue(), iLength, returnValues); |
6408 for (int32_t i = 0; i < (int32_t)iLength; i++) | 6626 for (int32_t i = 0; i < (int32_t)iLength; i++) |
6409 delete returnValues[i]; | 6627 delete returnValues[i]; |
6410 | 6628 |
6411 FX_Free(returnValues); | 6629 FX_Free(returnValues); |
6412 } | 6630 } |
6631 | |
6632 // static | |
6413 std::unique_ptr<CFXJSE_Value> CXFA_FM2JSContext::GetSimpleValue( | 6633 std::unique_ptr<CFXJSE_Value> CXFA_FM2JSContext::GetSimpleValue( |
6414 CFXJSE_Value* pThis, | 6634 CFXJSE_Value* pThis, |
6415 CFXJSE_Arguments& args, | 6635 CFXJSE_Arguments& args, |
6416 uint32_t index) { | 6636 uint32_t index) { |
6417 CXFA_FM2JSContext* pContext = | 6637 CXFA_FM2JSContext* pContext = |
6418 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6638 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
6419 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6639 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
6420 ASSERT(index < (uint32_t)args.GetLength()); | 6640 ASSERT(index < (uint32_t)args.GetLength()); |
6421 std::unique_ptr<CFXJSE_Value> argIndex = args.GetValue(index); | 6641 std::unique_ptr<CFXJSE_Value> argIndex = args.GetValue(index); |
6422 if (FXJSE_Value_IsArray(argIndex.get())) { | 6642 if (FXJSE_Value_IsArray(argIndex.get())) { |
(...skipping 20 matching lines...) Expand all Loading... | |
6443 return simpleValue; | 6663 return simpleValue; |
6444 } else if (FXJSE_Value_IsObject(argIndex.get())) { | 6664 } else if (FXJSE_Value_IsObject(argIndex.get())) { |
6445 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); | 6665 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); |
6446 GetObjectDefaultValue(argIndex.get(), defaultValue.get()); | 6666 GetObjectDefaultValue(argIndex.get(), defaultValue.get()); |
6447 return defaultValue; | 6667 return defaultValue; |
6448 } else { | 6668 } else { |
6449 return argIndex; | 6669 return argIndex; |
6450 } | 6670 } |
6451 } | 6671 } |
6452 | 6672 |
6673 // static | |
6453 FX_BOOL CXFA_FM2JSContext::ValueIsNull(CFXJSE_Value* pThis, CFXJSE_Value* arg) { | 6674 FX_BOOL CXFA_FM2JSContext::ValueIsNull(CFXJSE_Value* pThis, CFXJSE_Value* arg) { |
6454 CXFA_FM2JSContext* pContext = | 6675 CXFA_FM2JSContext* pContext = |
6455 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6676 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
6456 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6677 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
6457 FX_BOOL isNull = FALSE; | 6678 FX_BOOL isNull = FALSE; |
6458 if (FXJSE_Value_IsNull(arg)) { | 6679 if (FXJSE_Value_IsNull(arg)) { |
6459 isNull = TRUE; | 6680 isNull = TRUE; |
6460 } else if (FXJSE_Value_IsArray(arg)) { | 6681 } else if (FXJSE_Value_IsArray(arg)) { |
6461 int32_t iLength = hvalue_get_array_length(pThis, arg); | 6682 int32_t iLength = hvalue_get_array_length(pThis, arg); |
6462 if (iLength > 2) { | 6683 if (iLength > 2) { |
(...skipping 24 matching lines...) Expand all Loading... | |
6487 } else if (FXJSE_Value_IsObject(arg)) { | 6708 } else if (FXJSE_Value_IsObject(arg)) { |
6488 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); | 6709 std::unique_ptr<CFXJSE_Value> defaultValue(new CFXJSE_Value(pIsolate)); |
6489 GetObjectDefaultValue(arg, defaultValue.get()); | 6710 GetObjectDefaultValue(arg, defaultValue.get()); |
6490 if (FXJSE_Value_IsNull(defaultValue.get())) { | 6711 if (FXJSE_Value_IsNull(defaultValue.get())) { |
6491 isNull = TRUE; | 6712 isNull = TRUE; |
6492 } | 6713 } |
6493 } | 6714 } |
6494 return isNull; | 6715 return isNull; |
6495 } | 6716 } |
6496 | 6717 |
6718 // static | |
6497 int32_t CXFA_FM2JSContext::hvalue_get_array_length(CFXJSE_Value* pThis, | 6719 int32_t CXFA_FM2JSContext::hvalue_get_array_length(CFXJSE_Value* pThis, |
6498 CFXJSE_Value* arg) { | 6720 CFXJSE_Value* arg) { |
6499 CXFA_FM2JSContext* pContext = | 6721 CXFA_FM2JSContext* pContext = |
6500 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6722 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
6501 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6723 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
6502 int32_t iLength = 0; | 6724 int32_t iLength = 0; |
6503 if (FXJSE_Value_IsArray(arg)) { | 6725 if (FXJSE_Value_IsArray(arg)) { |
6504 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 6726 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
6505 FXJSE_Value_GetObjectProp(arg, "length", lengthValue.get()); | 6727 FXJSE_Value_GetObjectProp(arg, "length", lengthValue.get()); |
6506 iLength = FXJSE_Value_ToInteger(lengthValue.get()); | 6728 iLength = FXJSE_Value_ToInteger(lengthValue.get()); |
6507 } | 6729 } |
6508 return iLength; | 6730 return iLength; |
6509 } | 6731 } |
6732 | |
6733 // static | |
6510 FX_BOOL CXFA_FM2JSContext::simpleValueCompare(CFXJSE_Value* pThis, | 6734 FX_BOOL CXFA_FM2JSContext::simpleValueCompare(CFXJSE_Value* pThis, |
6511 CFXJSE_Value* firstValue, | 6735 CFXJSE_Value* firstValue, |
6512 CFXJSE_Value* secondValue) { | 6736 CFXJSE_Value* secondValue) { |
6513 FX_BOOL bReturn = FALSE; | 6737 FX_BOOL bReturn = FALSE; |
6514 if (FXJSE_Value_IsUTF8String(firstValue)) { | 6738 if (FXJSE_Value_IsUTF8String(firstValue)) { |
6515 CFX_ByteString firstString, secondString; | 6739 CFX_ByteString firstString, secondString; |
6516 ValueToUTF8String(firstValue, firstString); | 6740 ValueToUTF8String(firstValue, firstString); |
6517 ValueToUTF8String(secondValue, secondString); | 6741 ValueToUTF8String(secondValue, secondString); |
6518 bReturn = firstString == secondString; | 6742 bReturn = firstString == secondString; |
6519 } else if (FXJSE_Value_IsNumber(firstValue)) { | 6743 } else if (FXJSE_Value_IsNumber(firstValue)) { |
6520 FX_FLOAT first = ValueToFloat(pThis, firstValue); | 6744 FX_FLOAT first = ValueToFloat(pThis, firstValue); |
6521 FX_FLOAT second = ValueToFloat(pThis, secondValue); | 6745 FX_FLOAT second = ValueToFloat(pThis, secondValue); |
6522 bReturn = (first == second); | 6746 bReturn = (first == second); |
6523 } else if (FXJSE_Value_IsBoolean(firstValue)) { | 6747 } else if (FXJSE_Value_IsBoolean(firstValue)) { |
6524 bReturn = (FXJSE_Value_ToBoolean(firstValue) == | 6748 bReturn = (FXJSE_Value_ToBoolean(firstValue) == |
6525 FXJSE_Value_ToBoolean(secondValue)); | 6749 FXJSE_Value_ToBoolean(secondValue)); |
6526 } else if (FXJSE_Value_IsNull(firstValue) && | 6750 } else if (FXJSE_Value_IsNull(firstValue) && |
6527 FXJSE_Value_IsNull(secondValue)) { | 6751 FXJSE_Value_IsNull(secondValue)) { |
6528 bReturn = TRUE; | 6752 bReturn = TRUE; |
6529 } | 6753 } |
6530 return bReturn; | 6754 return bReturn; |
6531 } | 6755 } |
6756 | |
6757 // static | |
6532 void CXFA_FM2JSContext::unfoldArgs(CFXJSE_Value* pThis, | 6758 void CXFA_FM2JSContext::unfoldArgs(CFXJSE_Value* pThis, |
6533 CFXJSE_Arguments& args, | 6759 CFXJSE_Arguments& args, |
6534 CFXJSE_Value**& resultValues, | 6760 CFXJSE_Value**& resultValues, |
6535 int32_t& iCount, | 6761 int32_t& iCount, |
6536 int32_t iStart) { | 6762 int32_t iStart) { |
6537 CXFA_FM2JSContext* pContext = | 6763 CXFA_FM2JSContext* pContext = |
6538 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6764 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
6539 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6765 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
6540 iCount = 0; | 6766 iCount = 0; |
6541 int32_t argc = args.GetLength(); | 6767 int32_t argc = args.GetLength(); |
6542 | |
6543 std::vector<std::unique_ptr<CFXJSE_Value>> argsValue; | 6768 std::vector<std::unique_ptr<CFXJSE_Value>> argsValue; |
6544 for (int32_t i = 0; i < (argc - iStart); i++) { | 6769 for (int32_t i = 0; i < (argc - iStart); i++) { |
6545 argsValue.push_back(args.GetValue(i + iStart)); | 6770 argsValue.push_back(args.GetValue(i + iStart)); |
6546 if (FXJSE_Value_IsArray(argsValue[i].get())) { | 6771 if (FXJSE_Value_IsArray(argsValue[i].get())) { |
6547 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 6772 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
6548 FXJSE_Value_GetObjectProp(argsValue[i].get(), "length", | 6773 FXJSE_Value_GetObjectProp(argsValue[i].get(), "length", |
6549 lengthValue.get()); | 6774 lengthValue.get()); |
6550 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); | 6775 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); |
6551 iCount += ((iLength > 2) ? (iLength - 2) : 0); | 6776 iCount += ((iLength > 2) ? (iLength - 2) : 0); |
6552 } else { | 6777 } else { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6592 } else if (FXJSE_Value_IsObject(argsValue[i].get())) { | 6817 } else if (FXJSE_Value_IsObject(argsValue[i].get())) { |
6593 GetObjectDefaultValue(argsValue[i].get(), resultValues[index]); | 6818 GetObjectDefaultValue(argsValue[i].get(), resultValues[index]); |
6594 index++; | 6819 index++; |
6595 } else { | 6820 } else { |
6596 FXJSE_Value_Set(resultValues[index], argsValue[i].get()); | 6821 FXJSE_Value_Set(resultValues[index], argsValue[i].get()); |
6597 index++; | 6822 index++; |
6598 } | 6823 } |
6599 } | 6824 } |
6600 } | 6825 } |
6601 | 6826 |
6827 // static | |
6602 void CXFA_FM2JSContext::GetObjectDefaultValue(CFXJSE_Value* pObjectValue, | 6828 void CXFA_FM2JSContext::GetObjectDefaultValue(CFXJSE_Value* pObjectValue, |
6603 CFXJSE_Value* pDefaultValue) { | 6829 CFXJSE_Value* pDefaultValue) { |
6604 CXFA_Node* pNode = | 6830 CXFA_Node* pNode = |
6605 ToNode((CXFA_Object*)FXJSE_Value_ToObject(pObjectValue, nullptr)); | 6831 ToNode((CXFA_Object*)FXJSE_Value_ToObject(pObjectValue, nullptr)); |
6606 if (pNode) { | 6832 if (pNode) { |
6607 pNode->Script_Som_DefaultValue(pDefaultValue, FALSE, (XFA_ATTRIBUTE)-1); | 6833 pNode->Script_Som_DefaultValue(pDefaultValue, FALSE, (XFA_ATTRIBUTE)-1); |
6608 } else { | 6834 } else { |
6609 FXJSE_Value_SetNull(pDefaultValue); | 6835 FXJSE_Value_SetNull(pDefaultValue); |
6610 } | 6836 } |
6611 } | 6837 } |
6838 | |
6839 // static | |
6612 FX_BOOL CXFA_FM2JSContext::SetObjectDefaultValue(CFXJSE_Value* pObjectValue, | 6840 FX_BOOL CXFA_FM2JSContext::SetObjectDefaultValue(CFXJSE_Value* pObjectValue, |
6613 CFXJSE_Value* hNewValue) { | 6841 CFXJSE_Value* hNewValue) { |
6614 CXFA_Node* pNode = | 6842 CXFA_Node* pNode = |
6615 ToNode((CXFA_Object*)FXJSE_Value_ToObject(pObjectValue, nullptr)); | 6843 ToNode((CXFA_Object*)FXJSE_Value_ToObject(pObjectValue, nullptr)); |
6616 if (pNode) { | 6844 if (pNode) { |
6617 pNode->Script_Som_DefaultValue(hNewValue, TRUE, (XFA_ATTRIBUTE)-1); | 6845 pNode->Script_Som_DefaultValue(hNewValue, TRUE, (XFA_ATTRIBUTE)-1); |
6618 return TRUE; | 6846 return TRUE; |
6619 } | 6847 } |
6620 return FALSE; | 6848 return FALSE; |
6621 } | 6849 } |
6850 | |
6851 // static | |
6622 void CXFA_FM2JSContext::GenerateSomExpression(const CFX_ByteStringC& szName, | 6852 void CXFA_FM2JSContext::GenerateSomExpression(const CFX_ByteStringC& szName, |
6623 int32_t iIndexFlags, | 6853 int32_t iIndexFlags, |
6624 int32_t iIndexValue, | 6854 int32_t iIndexValue, |
6625 FX_BOOL bIsStar, | 6855 FX_BOOL bIsStar, |
6626 CFX_ByteString& szSomExp) { | 6856 CFX_ByteString& szSomExp) { |
6627 if (bIsStar) { | 6857 if (bIsStar) { |
6628 szSomExp = szName + "[*]"; | 6858 szSomExp = szName + "[*]"; |
6629 return; | 6859 return; |
6630 } | 6860 } |
6631 if (iIndexFlags == 0) { | 6861 if (iIndexFlags == 0) { |
6632 szSomExp = szName; | 6862 szSomExp = szName; |
6633 return; | 6863 return; |
6634 } | 6864 } |
6635 if (iIndexFlags == 1 || iIndexValue == 0) { | 6865 if (iIndexFlags == 1 || iIndexValue == 0) { |
6636 szSomExp = szName + "[" + | 6866 szSomExp = szName + "[" + |
6637 CFX_ByteString::FormatInteger(iIndexValue, FXFORMAT_SIGNED) + | 6867 CFX_ByteString::FormatInteger(iIndexValue, FXFORMAT_SIGNED) + |
6638 "]"; | 6868 "]"; |
6639 } else if (iIndexFlags == 2) { | 6869 } else if (iIndexFlags == 2) { |
6640 szSomExp = (iIndexValue < 0) ? (szName + "[-") : (szName + "[+"); | 6870 szSomExp = (iIndexValue < 0) ? (szName + "[-") : (szName + "[+"); |
6641 iIndexValue = (iIndexValue < 0) ? (0 - iIndexValue) : iIndexValue; | 6871 iIndexValue = (iIndexValue < 0) ? (0 - iIndexValue) : iIndexValue; |
6642 szSomExp += CFX_ByteString::FormatInteger(iIndexValue); | 6872 szSomExp += CFX_ByteString::FormatInteger(iIndexValue); |
6643 szSomExp += "]"; | 6873 szSomExp += "]"; |
6644 } else { | 6874 } else { |
6645 szSomExp = (iIndexValue < 0) ? (szName + "[") : (szName + "[-"); | 6875 szSomExp = (iIndexValue < 0) ? (szName + "[") : (szName + "[-"); |
6646 iIndexValue = (iIndexValue < 0) ? (0 - iIndexValue) : iIndexValue; | 6876 iIndexValue = (iIndexValue < 0) ? (0 - iIndexValue) : iIndexValue; |
6647 szSomExp += CFX_ByteString::FormatInteger(iIndexValue); | 6877 szSomExp += CFX_ByteString::FormatInteger(iIndexValue); |
6648 szSomExp += "]"; | 6878 szSomExp += "]"; |
6649 } | 6879 } |
6650 } | 6880 } |
6881 | |
6882 // static | |
6651 FX_BOOL CXFA_FM2JSContext::GetObjectByName( | 6883 FX_BOOL CXFA_FM2JSContext::GetObjectByName( |
6652 CFXJSE_Value* pThis, | 6884 CFXJSE_Value* pThis, |
6653 CFXJSE_Value* accessorValue, | 6885 CFXJSE_Value* accessorValue, |
6654 const CFX_ByteStringC& szAccessorName) { | 6886 const CFX_ByteStringC& szAccessorName) { |
6655 FX_BOOL bFlags = FALSE; | 6887 FX_BOOL bFlags = FALSE; |
6656 CXFA_FM2JSContext* pContext = | 6888 CXFA_FM2JSContext* pContext = |
6657 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6889 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
6658 CXFA_Document* pDoc = pContext->GetDocument(); | 6890 CXFA_Document* pDoc = pContext->GetDocument(); |
6659 if (!pDoc) { | 6891 if (!pDoc) { |
6660 return bFlags; | 6892 return bFlags; |
6661 } | 6893 } |
6662 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); | 6894 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); |
6663 XFA_RESOLVENODE_RS resoveNodeRS; | 6895 XFA_RESOLVENODE_RS resoveNodeRS; |
6664 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | | 6896 uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | |
6665 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; | 6897 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; |
6666 int32_t iRet = pScriptContext->ResolveObjects( | 6898 int32_t iRet = pScriptContext->ResolveObjects( |
6667 pScriptContext->GetThisObject(), | 6899 pScriptContext->GetThisObject(), |
6668 CFX_WideString::FromUTF8(szAccessorName).AsStringC(), resoveNodeRS, | 6900 CFX_WideString::FromUTF8(szAccessorName).AsStringC(), resoveNodeRS, |
6669 dwFlags); | 6901 dwFlags); |
6670 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { | 6902 if (iRet >= 1 && resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { |
6671 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( | 6903 FXJSE_Value_Set(accessorValue, pScriptContext->GetJSValueFromMap( |
6672 resoveNodeRS.nodes.GetAt(0))); | 6904 resoveNodeRS.nodes.GetAt(0))); |
6673 bFlags = TRUE; | 6905 bFlags = TRUE; |
6674 } | 6906 } |
6675 return bFlags; | 6907 return bFlags; |
6676 } | 6908 } |
6909 | |
6910 // static | |
6677 int32_t CXFA_FM2JSContext::ResolveObjects(CFXJSE_Value* pThis, | 6911 int32_t CXFA_FM2JSContext::ResolveObjects(CFXJSE_Value* pThis, |
6678 CFXJSE_Value* pRefValue, | 6912 CFXJSE_Value* pRefValue, |
6679 const CFX_ByteStringC& bsSomExp, | 6913 const CFX_ByteStringC& bsSomExp, |
6680 XFA_RESOLVENODE_RS& resoveNodeRS, | 6914 XFA_RESOLVENODE_RS& resoveNodeRS, |
6681 FX_BOOL bdotAccessor, | 6915 FX_BOOL bdotAccessor, |
6682 FX_BOOL bHasNoResolveName) { | 6916 FX_BOOL bHasNoResolveName) { |
6683 CFX_WideString wsSomExpression = CFX_WideString::FromUTF8(bsSomExp); | 6917 CFX_WideString wsSomExpression = CFX_WideString::FromUTF8(bsSomExp); |
6684 int32_t iRet = -1; | 6918 int32_t iRet = -1; |
6685 CXFA_FM2JSContext* pContext = | 6919 CXFA_FM2JSContext* pContext = |
6686 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6920 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
6687 CXFA_Document* pDoc = pContext->GetDocument(); | 6921 CXFA_Document* pDoc = pContext->GetDocument(); |
6688 if (!pDoc) { | 6922 if (!pDoc) { |
6689 return iRet; | 6923 return iRet; |
6690 } | 6924 } |
6691 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); | 6925 CXFA_ScriptContext* pScriptContext = pDoc->GetScriptContext(); |
6692 CXFA_Object* pNode = NULL; | 6926 CXFA_Object* pNode = nullptr; |
6693 uint32_t dFlags = 0UL; | 6927 uint32_t dFlags = 0UL; |
6694 if (bdotAccessor) { | 6928 if (bdotAccessor) { |
6695 if (FXJSE_Value_IsNull(pRefValue)) { | 6929 if (FXJSE_Value_IsNull(pRefValue)) { |
6696 pNode = pScriptContext->GetThisObject(); | 6930 pNode = pScriptContext->GetThisObject(); |
6697 dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; | 6931 dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent; |
6698 } else { | 6932 } else { |
6699 pNode = (CXFA_Object*)FXJSE_Value_ToObject(pRefValue, nullptr); | 6933 pNode = (CXFA_Object*)FXJSE_Value_ToObject(pRefValue, nullptr); |
6700 ASSERT(pNode); | 6934 ASSERT(pNode); |
6701 if (bHasNoResolveName) { | 6935 if (bHasNoResolveName) { |
6702 CFX_WideString wsName; | 6936 CFX_WideString wsName; |
(...skipping 15 matching lines...) Expand all Loading... | |
6718 } | 6952 } |
6719 } | 6953 } |
6720 } else { | 6954 } else { |
6721 pNode = (CXFA_Object*)FXJSE_Value_ToObject(pRefValue, nullptr); | 6955 pNode = (CXFA_Object*)FXJSE_Value_ToObject(pRefValue, nullptr); |
6722 dFlags = XFA_RESOLVENODE_AnyChild; | 6956 dFlags = XFA_RESOLVENODE_AnyChild; |
6723 } | 6957 } |
6724 iRet = pScriptContext->ResolveObjects(pNode, wsSomExpression.AsStringC(), | 6958 iRet = pScriptContext->ResolveObjects(pNode, wsSomExpression.AsStringC(), |
6725 resoveNodeRS, dFlags); | 6959 resoveNodeRS, dFlags); |
6726 return iRet; | 6960 return iRet; |
6727 } | 6961 } |
6962 | |
6963 // static | |
6728 void CXFA_FM2JSContext::ParseResolveResult( | 6964 void CXFA_FM2JSContext::ParseResolveResult( |
6729 CFXJSE_Value* pThis, | 6965 CFXJSE_Value* pThis, |
6730 const XFA_RESOLVENODE_RS& resoveNodeRS, | 6966 const XFA_RESOLVENODE_RS& resoveNodeRS, |
6731 CFXJSE_Value* pParentValue, | 6967 CFXJSE_Value* pParentValue, |
6732 CFXJSE_Value**& resultValues, | 6968 CFXJSE_Value**& resultValues, |
6733 int32_t& iSize, | 6969 int32_t& iSize, |
6734 FX_BOOL& bAttribute) { | 6970 FX_BOOL& bAttribute) { |
6735 CXFA_FM2JSContext* pContext = | 6971 CXFA_FM2JSContext* pContext = |
6736 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 6972 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
6737 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 6973 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
6738 iSize = 0; | 6974 iSize = 0; |
6739 resultValues = NULL; | 6975 resultValues = nullptr; |
6740 if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { | 6976 if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { |
6741 bAttribute = FALSE; | 6977 bAttribute = FALSE; |
6742 iSize = resoveNodeRS.nodes.GetSize(); | 6978 iSize = resoveNodeRS.nodes.GetSize(); |
6743 resultValues = FX_Alloc(CFXJSE_Value*, iSize); | 6979 resultValues = FX_Alloc(CFXJSE_Value*, iSize); |
6744 for (int32_t i = 0; i < iSize; i++) { | 6980 for (int32_t i = 0; i < iSize; i++) { |
6745 resultValues[i] = new CFXJSE_Value(pIsolate); | 6981 resultValues[i] = new CFXJSE_Value(pIsolate); |
6746 FXJSE_Value_Set( | 6982 FXJSE_Value_Set( |
6747 resultValues[i], | 6983 resultValues[i], |
6748 pContext->GetDocument()->GetScriptContext()->GetJSValueFromMap( | 6984 pContext->GetDocument()->GetScriptContext()->GetJSValueFromMap( |
6749 resoveNodeRS.nodes.GetAt(i))); | 6985 resoveNodeRS.nodes.GetAt(i))); |
(...skipping 12 matching lines...) Expand all Loading... | |
6762 } else { | 6998 } else { |
6763 iSize = iRet; | 6999 iSize = iRet; |
6764 resultValues = FX_Alloc(CFXJSE_Value*, iSize); | 7000 resultValues = FX_Alloc(CFXJSE_Value*, iSize); |
6765 for (int32_t i = 0; i < iSize; i++) { | 7001 for (int32_t i = 0; i < iSize; i++) { |
6766 resultValues[i] = new CFXJSE_Value(pIsolate); | 7002 resultValues[i] = new CFXJSE_Value(pIsolate); |
6767 FXJSE_Value_Set(resultValues[i], objectProperties[i]); | 7003 FXJSE_Value_Set(resultValues[i], objectProperties[i]); |
6768 } | 7004 } |
6769 } | 7005 } |
6770 } | 7006 } |
6771 } | 7007 } |
7008 | |
7009 // static | |
6772 int32_t CXFA_FM2JSContext::ValueToInteger(CFXJSE_Value* pThis, | 7010 int32_t CXFA_FM2JSContext::ValueToInteger(CFXJSE_Value* pThis, |
6773 CFXJSE_Value* pValue) { | 7011 CFXJSE_Value* pValue) { |
6774 CXFA_FM2JSContext* pContext = | 7012 CXFA_FM2JSContext* pContext = |
6775 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 7013 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
6776 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 7014 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
6777 int32_t iValue = 0; | 7015 int32_t iValue = 0; |
6778 if (FXJSE_Value_IsArray(pValue)) { | 7016 if (FXJSE_Value_IsArray(pValue)) { |
6779 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 7017 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
6780 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 7018 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
6781 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 7019 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
(...skipping 16 matching lines...) Expand all Loading... | |
6798 return iValue; | 7036 return iValue; |
6799 } else if (FXJSE_Value_IsUTF8String(pValue)) { | 7037 } else if (FXJSE_Value_IsUTF8String(pValue)) { |
6800 CFX_ByteString szValue; | 7038 CFX_ByteString szValue; |
6801 FXJSE_Value_ToUTF8String(pValue, szValue); | 7039 FXJSE_Value_ToUTF8String(pValue, szValue); |
6802 iValue = FXSYS_atoi(szValue.c_str()); | 7040 iValue = FXSYS_atoi(szValue.c_str()); |
6803 } else { | 7041 } else { |
6804 iValue = FXJSE_Value_ToInteger(pValue); | 7042 iValue = FXJSE_Value_ToInteger(pValue); |
6805 } | 7043 } |
6806 return iValue; | 7044 return iValue; |
6807 } | 7045 } |
6808 FX_DOUBLE CXFA_FM2JSContext::StringToDouble( | 7046 |
6809 const CFX_ByteStringC& szStringVal) { | 7047 // static |
6810 return XFA_ByteStringToDouble(szStringVal); | |
6811 } | |
6812 FX_FLOAT CXFA_FM2JSContext::ValueToFloat(CFXJSE_Value* pThis, | 7048 FX_FLOAT CXFA_FM2JSContext::ValueToFloat(CFXJSE_Value* pThis, |
6813 CFXJSE_Value* arg) { | 7049 CFXJSE_Value* arg) { |
6814 CXFA_FM2JSContext* pContext = | 7050 CXFA_FM2JSContext* pContext = |
6815 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 7051 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
6816 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 7052 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
6817 FX_FLOAT fRet = 0.0f; | 7053 FX_FLOAT fRet = 0.0f; |
6818 if (FXJSE_Value_IsArray(arg)) { | 7054 if (FXJSE_Value_IsArray(arg)) { |
6819 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 7055 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
6820 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 7056 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
6821 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 7057 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
6822 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue.get()); | 7058 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue.get()); |
6823 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsObjectValue.get()); | 7059 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsObjectValue.get()); |
6824 if (FXJSE_Value_IsNull(propertyValue.get())) { | 7060 if (FXJSE_Value_IsNull(propertyValue.get())) { |
6825 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 7061 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
6826 } else { | 7062 } else { |
6827 CFX_ByteString propertyStr; | 7063 CFX_ByteString propertyStr; |
6828 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); | 7064 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); |
6829 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), | 7065 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), |
6830 newPropertyValue.get()); | 7066 newPropertyValue.get()); |
6831 } | 7067 } |
6832 fRet = ValueToFloat(pThis, newPropertyValue.get()); | 7068 fRet = ValueToFloat(pThis, newPropertyValue.get()); |
6833 } else if (FXJSE_Value_IsObject(arg)) { | 7069 } else if (FXJSE_Value_IsObject(arg)) { |
6834 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 7070 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
6835 GetObjectDefaultValue(arg, newPropertyValue.get()); | 7071 GetObjectDefaultValue(arg, newPropertyValue.get()); |
6836 fRet = ValueToFloat(pThis, newPropertyValue.get()); | 7072 fRet = ValueToFloat(pThis, newPropertyValue.get()); |
6837 } else if (FXJSE_Value_IsUTF8String(arg)) { | 7073 } else if (FXJSE_Value_IsUTF8String(arg)) { |
6838 CFX_ByteString bsOutput; | 7074 CFX_ByteString bsOutput; |
6839 FXJSE_Value_ToUTF8String(arg, bsOutput); | 7075 FXJSE_Value_ToUTF8String(arg, bsOutput); |
6840 fRet = (FX_FLOAT)StringToDouble(bsOutput.AsStringC()); | 7076 fRet = (FX_FLOAT)XFA_ByteStringToDouble(bsOutput.AsStringC()); |
6841 } else if (FXJSE_Value_IsUndefined(arg)) { | 7077 } else if (FXJSE_Value_IsUndefined(arg)) { |
6842 fRet = 0; | 7078 fRet = 0; |
6843 } else { | 7079 } else { |
6844 fRet = FXJSE_Value_ToFloat(arg); | 7080 fRet = FXJSE_Value_ToFloat(arg); |
6845 } | 7081 } |
6846 return fRet; | 7082 return fRet; |
6847 } | 7083 } |
7084 | |
7085 // static | |
6848 FX_DOUBLE CXFA_FM2JSContext::ValueToDouble(CFXJSE_Value* pThis, | 7086 FX_DOUBLE CXFA_FM2JSContext::ValueToDouble(CFXJSE_Value* pThis, |
6849 CFXJSE_Value* arg) { | 7087 CFXJSE_Value* arg) { |
6850 CXFA_FM2JSContext* pContext = | 7088 CXFA_FM2JSContext* pContext = |
6851 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 7089 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
6852 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 7090 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
6853 FX_DOUBLE dRet = 0; | 7091 FX_DOUBLE dRet = 0; |
6854 if (FXJSE_Value_IsArray(arg)) { | 7092 if (FXJSE_Value_IsArray(arg)) { |
6855 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 7093 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
6856 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 7094 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
6857 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 7095 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
6858 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue.get()); | 7096 FXJSE_Value_GetObjectPropByIdx(arg, 1, propertyValue.get()); |
6859 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsObjectValue.get()); | 7097 FXJSE_Value_GetObjectPropByIdx(arg, 2, jsObjectValue.get()); |
6860 if (FXJSE_Value_IsNull(propertyValue.get())) { | 7098 if (FXJSE_Value_IsNull(propertyValue.get())) { |
6861 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 7099 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
6862 } else { | 7100 } else { |
6863 CFX_ByteString propertyStr; | 7101 CFX_ByteString propertyStr; |
6864 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); | 7102 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); |
6865 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), | 7103 FXJSE_Value_GetObjectProp(jsObjectValue.get(), propertyStr.AsStringC(), |
6866 newPropertyValue.get()); | 7104 newPropertyValue.get()); |
6867 } | 7105 } |
6868 dRet = ValueToDouble(pThis, newPropertyValue.get()); | 7106 dRet = ValueToDouble(pThis, newPropertyValue.get()); |
6869 } else if (FXJSE_Value_IsObject(arg)) { | 7107 } else if (FXJSE_Value_IsObject(arg)) { |
6870 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); | 7108 std::unique_ptr<CFXJSE_Value> newPropertyValue(new CFXJSE_Value(pIsolate)); |
6871 GetObjectDefaultValue(arg, newPropertyValue.get()); | 7109 GetObjectDefaultValue(arg, newPropertyValue.get()); |
6872 dRet = ValueToDouble(pThis, newPropertyValue.get()); | 7110 dRet = ValueToDouble(pThis, newPropertyValue.get()); |
6873 } else if (FXJSE_Value_IsUTF8String(arg)) { | 7111 } else if (FXJSE_Value_IsUTF8String(arg)) { |
6874 CFX_ByteString bsOutput; | 7112 CFX_ByteString bsOutput; |
6875 FXJSE_Value_ToUTF8String(arg, bsOutput); | 7113 FXJSE_Value_ToUTF8String(arg, bsOutput); |
6876 dRet = StringToDouble(bsOutput.AsStringC()); | 7114 dRet = XFA_ByteStringToDouble(bsOutput.AsStringC()); |
6877 } else if (FXJSE_Value_IsUndefined(arg)) { | 7115 } else if (FXJSE_Value_IsUndefined(arg)) { |
6878 dRet = 0; | 7116 dRet = 0; |
6879 } else { | 7117 } else { |
6880 dRet = FXJSE_Value_ToDouble(arg); | 7118 dRet = FXJSE_Value_ToDouble(arg); |
6881 } | 7119 } |
6882 return dRet; | 7120 return dRet; |
6883 } | 7121 } |
6884 | 7122 |
7123 // static | |
6885 void CXFA_FM2JSContext::ValueToUTF8String(CFXJSE_Value* arg, | 7124 void CXFA_FM2JSContext::ValueToUTF8String(CFXJSE_Value* arg, |
6886 CFX_ByteString& szOutputString) { | 7125 CFX_ByteString& szOutputString) { |
6887 if (FXJSE_Value_IsNull(arg) || FXJSE_Value_IsUndefined(arg)) { | 7126 if (FXJSE_Value_IsNull(arg) || FXJSE_Value_IsUndefined(arg)) { |
6888 szOutputString = ""; | 7127 szOutputString = ""; |
6889 } else if (FXJSE_Value_IsBoolean(arg)) { | 7128 } else if (FXJSE_Value_IsBoolean(arg)) { |
6890 szOutputString = FXJSE_Value_ToBoolean(arg) ? "1" : "0"; | 7129 szOutputString = FXJSE_Value_ToBoolean(arg) ? "1" : "0"; |
6891 } else { | 7130 } else { |
6892 szOutputString = ""; | 7131 szOutputString = ""; |
6893 FXJSE_Value_ToUTF8String(arg, szOutputString); | 7132 FXJSE_Value_ToUTF8String(arg, szOutputString); |
6894 } | 7133 } |
6895 } | 7134 } |
6896 | 7135 |
6897 CXFA_FM2JSContext::CXFA_FM2JSContext() | 7136 CXFA_FM2JSContext::CXFA_FM2JSContext(v8::Isolate* pScriptIsolate, |
6898 : m_pFMClass(nullptr), m_pDocument(nullptr) {} | 7137 CFXJSE_Context* pScriptContext, |
6899 | 7138 CXFA_Document* pDoc) |
6900 CXFA_FM2JSContext::~CXFA_FM2JSContext() { | 7139 : m_pIsolate(pScriptIsolate), |
6901 } | 7140 m_pFMClass(FXJSE_DefineClass(pScriptContext, &formcalc_fm2js_descriptor)), |
6902 | 7141 m_pValue(new CFXJSE_Value(pScriptIsolate)), |
6903 void CXFA_FM2JSContext::Initialize(v8::Isolate* pScriptIsolate, | 7142 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()); | 7143 FXJSE_Value_SetNull(m_pValue.get()); |
6911 FXJSE_Value_SetObject(m_pValue.get(), this, m_pFMClass); | 7144 FXJSE_Value_SetObject(m_pValue.get(), this, m_pFMClass); |
6912 } | 7145 } |
6913 | 7146 |
7147 CXFA_FM2JSContext::~CXFA_FM2JSContext() {} | |
7148 | |
6914 void CXFA_FM2JSContext::GlobalPropertyGetter(CFXJSE_Value* pValue) { | 7149 void CXFA_FM2JSContext::GlobalPropertyGetter(CFXJSE_Value* pValue) { |
6915 FXJSE_Value_Set(pValue, m_pValue.get()); | 7150 FXJSE_Value_Set(pValue, m_pValue.get()); |
6916 } | 7151 } |
6917 | 7152 |
6918 void CXFA_FM2JSContext::ThrowScriptErrorMessage(int32_t iStringID, ...) { | 7153 void CXFA_FM2JSContext::ThrowScriptErrorMessage(int32_t iStringID, ...) { |
6919 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); | 7154 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); |
6920 ASSERT(pAppProvider); | 7155 ASSERT(pAppProvider); |
6921 CFX_WideString wsFormat; | 7156 CFX_WideString wsFormat; |
6922 pAppProvider->LoadString(iStringID, wsFormat); | 7157 pAppProvider->LoadString(iStringID, wsFormat); |
6923 CFX_WideString wsMessage; | 7158 CFX_WideString wsMessage; |
6924 va_list arg_ptr; | 7159 va_list arg_ptr; |
6925 va_start(arg_ptr, iStringID); | 7160 va_start(arg_ptr, iStringID); |
6926 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); | 7161 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); |
6927 va_end(arg_ptr); | 7162 va_end(arg_ptr); |
6928 FXJSE_ThrowMessage( | 7163 FXJSE_ThrowMessage( |
6929 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); | 7164 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); |
6930 } | 7165 } |
OLD | NEW |